本文整理汇总了Python中musicbrainz2.webservice.Query.getTrackById方法的典型用法代码示例。如果您正苦于以下问题:Python Query.getTrackById方法的具体用法?Python Query.getTrackById怎么用?Python Query.getTrackById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类musicbrainz2.webservice.Query
的用法示例。
在下文中一共展示了Query.getTrackById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EasyID3
# 需要导入模块: from musicbrainz2.webservice import Query [as 别名]
# 或者: from musicbrainz2.webservice.Query import getTrackById [as 别名]
elif filename.endswith('.mp3'):
file_metadata = EasyID3(filename)
decode_command = ['lame', '--decode', filename, wavefile]
else:
print "Don't know to handle this file"
continue
print 'Looking up track on AcoustID/MusicBrainz'
print '--------------------------------------------------------------------------------'
# TODO: max 3 requests/sec to AcoustID/MusicBrainz, just sleeping a sec for the time being
time.sleep(1)
acoustid_duration, acoustid_fingerprint = acoustid.fingerprint_file(filename) # TODO: use fingerprint & duration to check for duplicates in database? seems like matching fingerprints is not trivial
acoustid_result = acoustid.parse_lookup_result(acoustid.lookup(acoustid_key, acoustid_fingerprint, acoustid_duration))
mb_metadata = []
for result in acoustid_result:
track = mb.getTrackById(result[1], TrackIncludes(artist=True, releases=True)) # TODO: needs to be limited, what if we get 20 results from acoustid?
releases = []
for release in track.getReleases():
releases.append({
'name': release.getTitle(),
'tracknum': release.getTracksOffset() + 1,
'musicbrainz_release_id': release.getId()[release.getId().rfind('/') + 1:]
})
mb_metadata.append({
'artist': track.getArtist().getName(),
'title': track.getTitle(),
'releases': releases,
'musicbrainz_track_id': result[1],
'musicbrainz_artist_id': track.getArtist().getId()[track.getArtist().getId().rfind('/') + 1:]
})