本文整理汇总了Python中musicbrainzngs.get_recording_by_id函数的典型用法代码示例。如果您正苦于以下问题:Python get_recording_by_id函数的具体用法?Python get_recording_by_id怎么用?Python get_recording_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_recording_by_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testGetRecording
def testGetRecording(self):
musicbrainzngs.get_recording_by_id("93468a09-9662-4886-a227-56a2ad1c5246")
self.assertEqual("http://musicbrainz.org/ws/2/recording/93468a09-9662-4886-a227-56a2ad1c5246", self.opener.get_url())
# one include
musicbrainzngs.get_recording_by_id("93468a09-9662-4886-a227-56a2ad1c5246", includes=["artists"])
self.assertEqual("http://musicbrainz.org/ws/2/recording/93468a09-9662-4886-a227-56a2ad1c5246?inc=artists", self.opener.get_url())
开发者ID:sxalexander,项目名称:python-musicbrainzngs,代码行数:7,代码来源:test_getentity.py
示例2: get_album_name
def get_album_name( recording_id,
log ):
"""
`recording_id` should be a Musicbrainz ID value for a recording (track) as
a string. Returns None on failure, else returns the recording's album's
name as it is most commonly known in the Musicbrainz DB as a string
"""
try:
result = musicbrainzngs.get_recording_by_id( recording_id, includes=['releases'] )
except Exception as exc:
log.warning("get_album_name(): web service call failed: %s" % exc)
return None
most_common_album_name = None
try:
# Find the most commonly occuring name for the release (album)
release_name_occurences = dict()
for release in result['recording']['release-list']:
if release['title'] not in release_name_occurences:
release_name_occurences[release['title']] = 1
else:
release_name_occurences[release['title']] += 1
most_common_album_name = \
max( release_name_occurences, key=release_name_occurences.get )
except Exception as e:
log.warning("get_album_name(): result parsing failed: %s: %s\nresult was %s" % ( type(e), e, str(result) ))
return None
return most_common_album_name
开发者ID:dezzroy,项目名称:music-tagger,代码行数:27,代码来源:online_resources.py
示例3: main
def main(collectionid):
# work -> list recordings
mapping = collections.defaultdict(list)
# map from an id to a name
recordingnames = {}
worknames = {}
for i, releaseid in enumerate(compmusic.musicbrainz.get_releases_in_collection(collectionid)):
print i, releaseid
try:
rel = mb.get_release_by_id(releaseid, includes=["recordings"])
except:
continue
rel = rel["release"]
for medium in rel.get("medium-list", []):
for track in medium.get("track-list", []):
recid = track["recording"]["id"]
recordingnames[recid] = track["recording"]["title"]
recording = mb.get_recording_by_id(recid, includes=["work-rels"])
recording = recording["recording"]
for work in recording.get("work-relation-list", []):
workid = work["work"]["id"]
worknames[workid] = work["work"]["title"]
mapping[workid].append(recid)
data = []
for k, v in mapping.items():
data.append((k, v))
data = sorted(data, key=lambda x: len(x[1]), reverse=True)
all_d = {"recordingnames": recordingnames,
"worknames": worknames,
"data": data
}
json.dump(all_d, open("works_by_recording.json", "w"))
开发者ID:EQ4,项目名称:pycompmusic,代码行数:34,代码来源:works_by_recording.py
示例4: getRecrodingListForAWork
def getRecrodingListForAWork( workMBID, m):
# get list of recording IDa for work ID
recordingIDsList = m.recordingids_for_work(workMBID)
existingVocalRecordings = [];
for recID in recordingIDsList:
recording = mb.get_recording_by_id(recID, includes=["artist-rels", "releases"])
# check if we have the realease of the recording in the database
listExistingReleases = getExistigReleasesForRecording(recording, recID)
if len(listExistingReleases) == 0:
continue
# check if we have vocals
if not isRecordingWithVocals(recording, recID):
print "no vocals in recording ID: ", recID
else:
existingVocalRecordings.append(recID)
return existingVocalRecordings
开发者ID:georgid,项目名称:symbTr2MusicBrainzMatcher,代码行数:29,代码来源:parseMachedMburlFIles.py
示例5: main
def main(path, fake_release_mbid):
releases = {}
# Get all the mbid of the recordings
onlyfiles = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
for i in onlyfiles:
head, tail = os.path.split(i)
filename, file_extension = os.path.splitext(i)
if file_extension == '.mp3':
c = eyed3.load(os.path.join(path, i))
mbid = c.tag.unique_file_ids.get("http://musicbrainz.org").render()[33:]
try:
rel = mb.get_recording_by_id(mbid, includes=["releases"])
release = None
if len(rel['recording']['release-list']):
# create release
release = rel['recording']['release-list'][0]['id']
else:
release = fake_release_mbid
# use *fake* release
if release not in releases:
releases[release] = []
releases[release].append(mbid)
except:
print("couldn't find a release for the recording %s" % mbid)
continue
coll = Collection.objects.get(mbid="544f7aec-dba6-440c-943f-103cf344efbb")
r = makam_importer.MakamReleaseImporter(coll)
for i in releases.keys():
r.import_release(i, "")
for j in releases[i]:
r.add_and_get_recording(j)
开发者ID:MTG,项目名称:dunya,代码行数:31,代码来源:createrecordings.py
示例6: stats_for_recording
def stats_for_recording(self, recordingid):
""" Given a recording id, get its work (if it exists) and
the composer and lyricist of the work """
self.recordings.add(recordingid)
recording = mb.get_recording_by_id(recordingid, includes=["work-rels", "artist-rels"])
recording = recording["recording"]
for relation in recording.get("artist-relation-list", []):
artist = relation.get("artist", {}).get("id")
if artist:
self.artists.add(artist)
for relation in recording.get("work-relation-list", []):
workid = relation.get("work", {}).get("id")
self.works.add(workid)
self.work_recording_counts[workid] += 1
work = mb.get_work_by_id(workid, includes=["artist-rels"])
work = work["work"]
for artist in work.get("artist-relation-list", []):
t = artist["type"]
aid = artist.get("artist", {}).get("id")
if aid:
if t == "composer":
self.composers.add(aid)
elif t == "lyricist":
self.lyricists.add(aid)
开发者ID:EQ4,项目名称:pycompmusic,代码行数:25,代码来源:stats.py
示例7: _recurse_relations
def _recurse_relations(self, mb_track_id, oldest_release, relation_type):
x = musicbrainzngs.get_recording_by_id(
mb_track_id,
includes=['releases', 'recording-rels'])
if 'recording-relation-list' in x['recording'].keys():
# recurse down into edits and remasters.
# Note remasters are deprecated in musicbrainz, but some entries
# may still exist.
for subrecording in x['recording']['recording-relation-list']:
if ('direction' in subrecording.keys() and
subrecording['direction'] == 'backward'):
continue
(oldest_release, relation_type) = self._recurse_relations(
subrecording['target'],
oldest_release,
subrecording['type'])
for release in x['recording']['release-list']:
if 'date' not in release.keys():
# A release without a date. Skip over it.
continue
release_date = self._make_date_values(release['date'])
if (oldest_release['year'] is None or
oldest_release['year'] > release_date['year']):
oldest_release = release_date
elif oldest_release['year'] == release_date['year']:
if ('month' in release_date.keys() and
'month' in oldest_release.keys() and
oldest_release['month'] > release_date['month']):
oldest_release = release_date
return (oldest_release, relation_type)
开发者ID:tweitzel,项目名称:beets-recordingdate,代码行数:30,代码来源:recordingdate.py
示例8: get_recording_by_id
def get_recording_by_id(mbid):
recording = cache.get(mbid)
if not recording:
try:
recording = musicbrainzngs.get_recording_by_id(mbid, includes=['artists', 'releases', 'media'])['recording']
except ResponseError as e:
raise DataUnavailable(e)
cache.set(mbid, recording, time=CACHE_TIMEOUT)
return recording
开发者ID:Freso,项目名称:messybrainz-server,代码行数:9,代码来源:musicbrainz.py
示例9: track_for_id
def track_for_id(trackid):
"""Fetches a track by its MusicBrainz ID. Returns a TrackInfo object
or None if no track is found.
"""
try:
res = musicbrainzngs.get_recording_by_id(trackid, TRACK_INCLUDES)
except musicbrainzngs.ResponseError:
log.debug('Track ID match failed.')
return None
return track_info(res['recording'])
开发者ID:paulprovost,项目名称:beets,代码行数:10,代码来源:mb.py
示例10: make_query
def make_query(self, params):
if params["type"] == "artist":
return musicbrainzngs.get_artist_by_id(params["mbid"])
elif params["type"] == "album":
return musicbrainzngs.get_release_by_id(params["mbid"])
elif params["type"] == "tracklist":
return musicbrainzngs.get_release_by_id(params["mbid"],
includes=["recordings"])["release"]["medium-list"][0]["track-list"]
elif params["type"] == "track":
return musicbrainzngs.get_recording_by_id(params["mbid"], includes=["artists"])
开发者ID:kborrell,项目名称:mymusic_sitw,代码行数:11,代码来源:musicbrainz_manager.py
示例11: track_for_id
def track_for_id(trackid):
"""Fetches a track by its MusicBrainz ID. Returns a TrackInfo object
or None if no track is found. May raise a MusicBrainzAPIError.
"""
try:
res = musicbrainzngs.get_recording_by_id(trackid, TRACK_INCLUDES)
except musicbrainzngs.ResponseError:
log.debug("Track ID match failed.")
return None
except musicbrainzngs.MusicBrainzError as exc:
raise MusicBrainzAPIError(exc, "get recording by ID", trackid, traceback.format_exc())
return track_info(res["recording"])
开发者ID:rubyeye37,项目名称:beets,代码行数:12,代码来源:mb.py
示例12: get_performance_credit_for_recording
def get_performance_credit_for_recording(self, recordingid):
recording = mb.get_recording_by_id(recordingid, includes=["releases"])
recording = recording["recording"]
ret = []
for release in recording.get("release-list", []):
relid = release["id"]
mbrelease = mb.get_release_by_id(relid, includes=["artist-credits", "recordings"])
mbrelease = mbrelease["release"]
for medium in mbrelease.get("medium-list", []):
for track in medium.get("track-list", []):
if track["recording"]["id"] == recordingid:
ret.append(track["recording"]["artist-credit-phrase"])
return list(set(ret))
开发者ID:EQ4,项目名称:pycompmusic,代码行数:13,代码来源:sertanscores.py
示例13: get_musicbrainz
def get_musicbrainz(self, obj):
results = []
includes = ['releases','artists']
for e in obj.results_acoustid:
media_id = e['id']
try:
result = musicbrainzngs.get_recording_by_id(id=media_id, includes=includes)
results.append(result)
except Exception, e:
print e
pass
开发者ID:hzlf,项目名称:openbroadcast,代码行数:15,代码来源:__old_process.py
示例14: match_recording
def match_recording(mbids):
release_list = []
mbid_rec = {}
for mbid in mbids:
try:
mbid_info = mb.get_recording_by_id(mbid,['artists','releases'],['official'])['recording']
except mb.musicbrainz.ResponseError :
logging.warning('{0} is an invalid MusicBrainz ID. Skipping...'.format(mbid))
continue
mbid_rlist = mbid_info['release-list']
mbid_rec[mbid] = mbid_info
for item in mbid_rlist:
item['trackid'] = mbid
release_list.extend(mbid_rlist)
return (mbid_rec, release_list)
开发者ID:AndreaGiardini,项目名称:audioclick,代码行数:15,代码来源:mblookup.py
示例15: track_for_id
def track_for_id(releaseid):
"""Fetches a track by its MusicBrainz ID. Returns a TrackInfo object
or None if no track is found. May raise a MusicBrainzAPIError.
"""
trackid = _parse_id(releaseid)
if not trackid:
log.debug(u'Invalid MBID ({0}).', releaseid)
return
try:
res = musicbrainzngs.get_recording_by_id(trackid, TRACK_INCLUDES)
except musicbrainzngs.ResponseError:
log.debug(u'Track ID match failed.')
return None
except musicbrainzngs.MusicBrainzError as exc:
raise MusicBrainzAPIError(exc, u'get recording by ID', trackid,
traceback.format_exc())
return track_info(res['recording'])
开发者ID:artemutin,项目名称:beets,代码行数:17,代码来源:mb.py
示例16: getOnlyVocalRecording
def getOnlyVocalRecording(recordingIDsList):
existingVocalRecordings = [];
for recID in recordingIDsList:
recording = mb.get_recording_by_id(recID, includes=["artist-rels", "releases"])
# check if we have the realease of the recording in the database
listExistingReleases = getExistigReleasesForRecording(recording, recID)
if len(listExistingReleases) == 0:
continue
# check if we have vocals
if not isRecordingWithVocals(recording, recID):
print "no vocals in recording ID: ", recID
else:
existingVocalRecordings.append(recID)
开发者ID:georgid,项目名称:symbTr2MusicBrainzMatcher,代码行数:20,代码来源:parseMachedMburlFIles.py
示例17: from_musicbrainz
def from_musicbrainz(self, audio_in):
try: # audio file input
mbid, duration, sampling_frequency, bit_rate = \
Recording.get_file_metadata(audio_in)
audio_meta = {'mbid': mbid, 'path': audio_in, 'duration': duration,
'sampling_frequency': sampling_frequency,
'bit_rate': bit_rate}
except (IOError, AttributeError):
audio_meta = {'mbid': audio_in}
audio_meta['url'] = u'http://musicbrainz.org/recording/{}'.format(
audio_meta['mbid'])
meta = mb.get_recording_by_id(audio_meta['mbid'], includes=['artists', 'artist-rels', 'releases', 'tags', 'work-rels'])['recording']
audio_meta['title'] = meta['title']
# releases
audio_meta['releases'] = self._get_releases(meta)
# artist credits
audio_meta['artist_credits'] = self._get_artist_credits(meta)
# performers
audio_meta['artists'] = self._get_artist_relations(meta)
# works
if 'work-relation-list' in meta.keys(): # has work
audio_meta['works'] = self._get_works(meta)
# get makam/usul/for from work attributes
if self.get_work_attributes and 'works' in audio_meta.keys():
self._get_attributes_from_works(audio_meta)
# get makam/usul/for tags
self._get_recording_attribute_tags(audio_meta, meta)
# infer voicing/instrumentation
audio_meta['instrumentation_voicing'] = InstrumentationVoicing.\
get_voicing_instrumentation(audio_meta)
return audio_meta
开发者ID:sertansenturk,项目名称:tomato,代码行数:40,代码来源:recording.py
示例18: _recording_details
def _recording_details(recording_ids):
'''
We need to store more information . As of now , storing only release id to get the album art in future
'''
mbids = {}
song_details = {}
for rid in recording_ids:
release_ids = []
try:
data = musicbrainzngs.get_recording_by_id(rid,includes=['releases'])['recording']
for i in data['release-list']:
try:
if i['status'] == 'Official':
release_ids.append(i['id'])
except:
pass
mbids[rid] = release_ids
song_details[rid] = data['release-list']
except musicbrainzngs.WebServiceError as exc:
print("Something went wrong with the request: %s" % exc)
raise MusicUtilsException('4','Something wrong with the request. ')
return (mbids,song_details)
开发者ID:nirvik,项目名称:audioTag,代码行数:22,代码来源:musicbrainz.py
示例19: album
def album(self, mbid):
dbcfg = self.mc.get('database')
dl = _mysql.connect(host=dbcfg['host'],user=dbcfg['username'],passwd=dbcfg['password'],db=dbcfg['database'])
query = "select * from Albums where MBID='" + _mysql.escape_string(mbid) + "';"
dl.query(query)
ret = {}
r = dl.store_result()
c = r.num_rows()
for i in range(0, c):
dd = r.fetch_row(1,1)[0]
ret = dd
if len(ret) == 0:
try:
info = musicbrainzngs.get_release_by_id(mbid, includes=['artists', 'url-rels', 'recordings'])
except:
info = {}
if 'release' in info:
rinfo = info['release']
trackstoadd = []
if 'medium-list' in rinfo:
for disc in rinfo['medium-list']:
if not('track-list' in disc):
continue
for trackinfo in disc['track-list']:
item = trackinfo['recording']
if 'number' in trackinfo:
item['tracknumber'] = trackinfo['number']
if 'position' in trackinfo:
item['tracknumber'] = trackinfo['position']
mbinfo = musicbrainzngs.get_recording_by_id(item['id'], includes=['artists'])
try:
item['artist'] = mbinfo['recording']['artist-credit'][0]['artist']['id']
except:
item['artist'] = ''
trackstoadd.append(item)
ret['Title'] = ""
ret['MBID'] = ""
ret['ASIN'] = ""
if 'title' in rinfo:
ret['Title'] = rinfo['title'].encode('utf8', 'ignore')
if 'id' in rinfo:
ret['MBID'] = rinfo['id'].encode('utf8', 'ignore')
if 'asin' in rinfo:
ret['ASIN'] = rinfo['asin'].encode('utf8', 'ignore')
try:
ret['ReleaseDate'] = rinfo['release-event-list'][0]['date'].encode('utf8', 'ignore')
except:
ret['ReleaseDate'] = ''
try:
artist_mbid = rinfo['artist-credit'][0]['artist']['id'].encode('utf8', 'ignore')
except:
artist_mbid = ''
artist_info = self.artist(artist_mbid)
query = "select ID from Artists where MBID='" + artist_mbid + "';"
artist_id = "0"
dl.query(query)
r = dl.store_result()
if r.num_rows() > 0:
dd = r.fetch_row(1,1)[0]
artist_id = dd['ID']
query = "insert ignore into Albums (MBID, Title, Artist, ASIN, ReleaseDate) values ('" + _mysql.escape_string(ret['MBID']) + "', '" + _mysql.escape_string(ret['Title']) + "', '" + _mysql.escape_string(artist_id) + "', '" + _mysql.escape_string(ret['ASIN']) + "', '" + _mysql.escape_string(ret['ReleaseDate']) + "');"
ret = {}
dl.query(query)
query = "select * from Albums where MBID='" + _mysql.escape_string(mbid) + "';"
dl.query(query)
ret = {}
r = dl.store_result()
c = r.num_rows()
for i in range(0, c):
dd = r.fetch_row(1,1)[0]
ret = dd
if 'ID' in ret:
for trackinfo in trackstoadd:
query = "select ID from Artists where MBID='" + trackinfo['artist'] + "';"
dl.query(query)
r = dl.store_result()
artist_id = '0'
if r.num_rows() > 0:
dd = r.fetch_row(1,1)[0]
artist_id = dd['ID']
if 'length' in trackinfo:
track_length = (int(trackinfo['length']) / 1000)
else:
track_length = 0
query = "insert ignore into Tracks (MBID, Title, Length, TrackNo, LastFM, Artist, Album)"
query = query + " values ('" + _mysql.escape_string(trackinfo['id']) + "', '" + _mysql.escape_string(trackinfo['title'].encode('utf8', 'ignore')) + "', '" + str(track_length) + "', '" + _mysql.escape_string(trackinfo['tracknumber']) + "', '', '" + artist_id + "', '" + ret['ID'] + "');"
dl.query(query)
tracks = []
if 'ID' in ret:
aid = ret['ID']
else:
aid = '0'
query = "select * from Tracks where Album='" + str(aid) + "' order by TrackNo"
dl.query(query)
r = dl.store_result()
c = r.num_rows()
#.........这里部分代码省略.........
开发者ID:ads04r,项目名称:MoonShine,代码行数:101,代码来源:moonshine.py
示例20: getAlbumArtistNames
def getAlbumArtistNames(album,artist, apihandle, song=None):
'''
Given a supposed album and artist, determine the real ones
'''
def searchWhatAlbums(args):
if len(args)==0:
return []
whatResponse = apihandle.request(action='browse',searchstr=args[0])
if whatResponse['status']=='success':
args.pop(0)
return searchWhatAlbums(args)+[x for x in whatResponse['response']['results'] if 'artist' in x and 'groupName' in x]
return []
mbAlbums = []
parens = re.compile('[\(\[].*[\)\]]')
if song is not None:
includes = ['recordings']
artists = set(re.split(' &|and|ft\.?|featuring|feat\.? ',artist))
if len(artists) > 1:
artists.add(artist)
for ar in artists:
mbAlbums += [dict(list(x.items())+[("artist-credit-phrase", releases['artist-credit-phrase'])]) for releases in mb.search_recordings(query=song, limit=int(50*mbMultiplier), artistname=mbquote(ar), release=mbquote(album))['recording-list'] for x in releases['release-list']]
mbAlbums += mb.search_releases(artist=mbquote(ar),query=mbquote(album),limit=int(25*mbMultiplier))['release-list']
lastfmres = [x['mbid'] for x in lookup('lastfm','songsearch',{'artist':ar, 'song':song})['results']['trackmatches']['track'] if 'mbid' in x and len(x['mbid'])>0]
if len(lastfmres)>0:
for lastfmRecId in set(lastfmres):
try:
lastfmAlbum = mb.get_recording_by_id(id=lastfmRecId,includes=['releases','artist-credits'])
for alb in lastfmAlbum['recording'].pop('release-list'):
alb['medium-list'] = [{}]
alb['medium-list'][0]['track-list'] = []
alb['medium-list'][0]['track-list'].append(lastfmAlbum)
alb['artist-credit-phrase'] = lastfmAlbum['recording']['artist-credit-phrase']
mbAlbums.append(alb)
except Exception as e:
print(e)
else:
includes = []
mbArtists = mb.search_artists(query=mbquote(artist),limit=int(40*mbMultiplier))['artist-list']
mbAlbums += mb.search_releases(artist=mbquote(artist),query=mbquote(album),limit=int(50*mbMultiplier))['release-list']
for mbArtist in mbArtists:
if Levenshtein.ratio(artist.lower(),mbArtist['name'].lower()) > 0.75:
mbAlbums+=[ dict(list(x.items())+[('artist-credit-phrase',mbArtist['name'])]) for x in mb.browse_releases(artist=mbArtist['id'],includes=includes,limit=25)['release-list']]
if (len(album)<7 and ('/' in album or ' & ' in album) and 's' in album.lower() and 't' in album.lower()) or ('self' in album.lower() and 'titled' in album.lower()):
mbAlbums += mb.search_releases(artist=mbquote(artist),query=mbquote(artist),limit=int(25*mbMultiplier))['release-list']
temp = []
for x in mbAlbums[:]:
if x["id"] in temp and not ('medium-list' in x and len(x['medium-list'])>0 and all('track-list' in z and len(z['track-list'])>0 for z in x['medium-list'])):
mbAlbums.remove(x)
else:
temp.append(x['id'])
print("Done searching musicbrainz for album suggestions, have "+str(len(mbAlbums))+" to rank")
ranks = {}
for x in mbAlbums:
ranks[x['id']] = Levenshtein.ratio(album.lower(),x['title'].lower())
if song is not None:
x['song'] = {}
temp = ([(y['recording']['title'] if 'recording' in y else y['title'],
int(float(
y['recording']['length'] if 'recording' in y and 'length' in y['recording']
else (y['track_or_recording_length'] if 'track_or_recording_length' in x
else y['length'] if 'length' in x else 0)
)/1000.))
for tracklist in x['medium-list']
for y in tracklist['track-list']]
if 'medium-list' in x and len(x['medium-list'])>0 and all('track-list' in z and len(z['track-list'])>0 for z in x['medium-list'])
else getSongs(
{"artist":x['artist-credit-phrase'],
"groupName":x['title']}))
x['song']['name'], x['song']['duration'] = (max(temp,
key=lambda y: Levenshtein.ratio(y[0].lower(),song.lower())) if len(temp)>0 else ("",-1))
if ranks[x['id']] < Levenshtein.ratio(x['song']['name'].lower(),song.lower()):
ranks[x['id']] /= 6
ranks[x['id']] += (Levenshtein.ratio(x['song']['name'].lower(),song.lower())
+ Levenshtein.ratio(parens.sub('',x['song']['name'].lower()),parens.sub('',song.lower())) )*5/12
else:
ranks[x['id']] /= 3
ranks[x['id']] += (Levenshtein.ratio(x['song']['name'].lower(),song.lower())
+ Levenshtein.ratio(parens.sub('',x['song']['name'].lower()),parens.sub('',song.lower())) )/3
ranks[x['id']] += Levenshtein.ratio(artist.lower(),x['artist-credit-phrase'].lower())*7/6
if len(ranks) == 0:
return None
mbAlbumId, mbAlbumRank = max(ranks.items(),key=(lambda x:x[1]))
mbAlbum = [x for x in mbAlbums if x['id']==mbAlbumId][0]
print("For the artist and album derived from the provided dir ("+artist+" and "+album+" respectively),\nthe following artist and album was matched on musicbrains:")
print("Artist: "+mbAlbum['artist-credit-phrase'])
print("Album: "+mbAlbum['title'])
whatAlbums = searchWhatAlbums([mbAlbum['title']+' '+mbAlbum['artist-credit-phrase'], artist+' '+album])
if len(whatAlbums) == 0:
whatAlbums = searchWhatAlbums([artist,album,mbAlbum['title'],mbAlbum['artist-credit-phrase']])
if len(whatAlbums) == 0:
return None
whatAlbums = sorted(whatAlbums, key=(lambda x:
Levenshtein.ratio(x['groupName'],mbAlbum['title'])
+Levenshtein.ratio(x['groupName'].lower(),album.lower())*3/8
+Levenshtein.ratio(x['artist'],mbAlbum['artist-credit-phrase'])
+Levenshtein.ratio(x['artist'].lower(),artist.lower())*5/8),
reverse=True)#[:min(10,len(whatAlbums))]
whatAlbum = whatAlbums[0]
whatAlbum['artist-credit-phrase'] = mbAlbum['artist-credit-phrase']
#.........这里部分代码省略.........
开发者ID:aristeia,项目名称:zarvox,代码行数:101,代码来源:libzarv.py
注:本文中的musicbrainzngs.get_recording_by_id函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论