当前位置: 首页>>代码示例>>Python>>正文


Python Query.getTrackById方法代码示例

本文整理汇总了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:]
            })
开发者ID:canidae,项目名称:imp,代码行数:32,代码来源:convert.py


注:本文中的musicbrainz2.webservice.Query.getTrackById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。