• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python musicbrainzngs.get_release_by_id函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中musicbrainzngs.get_release_by_id函数的典型用法代码示例。如果您正苦于以下问题:Python get_release_by_id函数的具体用法?Python get_release_by_id怎么用?Python get_release_by_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_release_by_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getRelease

def getRelease(releaseid, include_artist_info=True):
    """
    Deep release search to get track info
    """
    with mb_lock:

        release = {}
        results = None

        try:
            if include_artist_info:
                results = musicbrainzngs.get_release_by_id(releaseid, ["artists", "release-groups", "media", "recordings"]).get('release')
            else:
                results = musicbrainzngs.get_release_by_id(releaseid, ["media", "recordings"]).get('release')
        except musicbrainzngs.WebServiceError as e:
            logger.warn('Attempt to retrieve information from MusicBrainz for release "%s" failed (%s)' % (releaseid, str(e)))
            time.sleep(5)

        if not results:
            return False

        release['title'] = unicode(results['title'])
        release['id'] = unicode(results['id'])
        release['asin'] = unicode(results['asin']) if 'asin' in results else None
        release['date'] = unicode(results['date']) if 'date' in results else None
        try:
            release['format'] = unicode(results['medium-list'][0]['format'])
        except:
            release['format'] = u'Unknown'

        try:
            release['country'] = unicode(results['country'])
        except:
            release['country'] = u'Unknown'

        if include_artist_info:

            if 'release-group' in results:
                release['rgid'] = unicode(results['release-group']['id'])
                release['rg_title'] = unicode(results['release-group']['title'])
                try:
                    release['rg_type'] = unicode(results['release-group']['type'])

                    if release['rg_type'] == 'Album' and 'secondary-type-list' in results['release-group']:
                        secondary_type = unicode(results['release-group']['secondary-type-list'][0])
                        if secondary_type != release['rg_type']:
                            release['rg_type'] = secondary_type

                except KeyError:
                    release['rg_type'] = u'Unknown'

            else:
                logger.warn("Release " + releaseid + "had no ReleaseGroup associated")

            release['artist_name'] = unicode(results['artist-credit'][0]['artist']['name'])
            release['artist_id'] = unicode(results['artist-credit'][0]['artist']['id'])

        release['tracks'] = getTracksFromRelease(results)

        return release
开发者ID:MichaelB1105,项目名称:filmreel,代码行数:60,代码来源:mb.py


示例2: testGetRelease

    def testGetRelease(self):
        musicbrainzngs.get_release_by_id("5e3524ca-b4a1-4e51-9ba5-63ea2de8f49b")
        self.assertEqual("http://musicbrainz.org/ws/2/release/5e3524ca-b4a1-4e51-9ba5-63ea2de8f49b", _common.opener.get_url())

        # one include
        musicbrainzngs.get_release_by_id("5e3524ca-b4a1-4e51-9ba5-63ea2de8f49b", includes=["artists"])
        self.assertEqual("http://musicbrainz.org/ws/2/release/5e3524ca-b4a1-4e51-9ba5-63ea2de8f49b?inc=artists", _common.opener.get_url())
开发者ID:inytar,项目名称:python-musicbrainz-ngs,代码行数:7,代码来源:test_getentity.py


示例3: 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


示例4: match_tracks_to_release

def match_tracks_to_release(title, tracks, mbid, name):
    '''
       Given a list of tracks, a candidate release mbid and name this function should return
       a score (0.0-1.0) of how well this list of tracks compares to the MB release.
    '''

    try:
        musicbrainzngs.set_useragent(config.USER_AGENT_STRING, config.USER_AGENT_VERSION, config.USER_AGENT_USER)
        rel = musicbrainzngs.get_release_by_id(mbid, includes=['recordings'])
    except musicbrainzngs.WebServiceError as exc:
        print "Something went wrong with the request: %s" % exc 
        return -1

#    print "--- %-40s %s" % (title.encode('utf-8'), name.encode('utf-8'))
    matches = []
    total = 0.0
    print 
    for i, t in enumerate(rel["release"]["medium-list"][0]["track-list"]):
        try:
            d = Levenshtein.ratio(clean_string(t['recording']['title']), tracks[i]['clean'])
            print "%.3f %2d %-40s | %s" % (d, i+1, clean_string(t['recording']['title']), tracks[i]['clean'])
            total += d
        except IndexError:
            return -1

    return total / len(tracks)
开发者ID:mayhem,项目名称:ia_matcher,代码行数:26,代码来源:mb_match.py


示例5: Fetch

    def Fetch( self, options ):
        if not self.valid:
            return

        self.fetch_attempts += 1

        # Get the song metadata from MB Web Service - invalid release if this fails
        try:
            self.data = ws.get_release_by_id( self.id, ["artist-credits", "recordings", "labels", "release-groups", "media"] )["release"]
        except ws.musicbrainz.ResponseError:
            utils.safeprint ( u"Connection Error!" )
            self.data = None
            return
        except ws.musicbrainz.NetworkError:
            utils.safeprint ( u"Connection Error!" )
            self.data = None
            return

        self.__ProcessData( options )

        # Get cover art for release - no CA if this fails
        try:
            cover = urllib2.urlopen( "http://coverartarchive.org/release/" + self.id + "/front-500", None, 10 )
        except urllib2.HTTPError:
            utils.safeprint( u"No cover art in CAA for \"{}\".".format( self.processed_data["album"] ) )
            self.art = None
        except ( urllib2.URLError, socket.timeout ):
            utils.safeprint( u"Connection Error!" )
            self.art = None
        else:
            self.art = self.__PackageCoverArt( cover.read() )

        # Successfully retrieved data
        self.fetched = True
        return self.id
开发者ID:LordSputnik,项目名称:mb-masstagger,代码行数:35,代码来源:release.py


示例6: 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


示例7: get_recordings_from_release

def get_recordings_from_release(release):
    rel = mb.get_release_by_id(release, includes=["recordings"])["release"]
    recordings = []
    for m in rel.get("medium-list", []):
        for t in m.get("track-list", []):
            recordings.append(t["recording"]["id"])
    return recordings
开发者ID:MTG,项目名称:pycompmusic,代码行数:7,代码来源:musicbrainz.py


示例8: clickevt_album

def clickevt_album(evt):
    window_name = mainwin['artistslist'].get_selected_items()[0]["artist"] + " - " + mainwin['albumslist'].get_selected_items()[0]["albums"];

    with gui.Window(name='downwin', title=u'' + window_name, height=down_win_height, width=down_win_width, left='323', top='137', bgcolor=u'#F0F0F0', fgcolor=u'#555555', ):
        gui.TextBox(name='downloadpath', value=pref.download_dir, height=form_height, left='5', top='0', width=down_input_width, parent='downwin', )
        gui.Button(label=u'Download all!', name='btn_down_all', height='35px', width=down_btn_width, left=down_input_width, top='5', default=True, fgcolor=u'#EEEEEE', bgcolor=u'#C0392B', parent='downwin', )
        gui.Button(label=u'Download selected!', name='button_down', height='35px', width=down_btn_width, left=down_btn_left, top='5', default=True, fgcolor=u'#EEEEEE', bgcolor=u'#C0392B', parent='downwin', )
        with gui.ListView(name='downloadlist', height=down_lv_songs_height, width=down_win_width, left='0', top=form_height, item_count=10, sort_column=0, onitemselected="print ('sel %s' % event.target.get_selected_items())", ):
            gui.ListColumn(name='trackposition', text='Nr.', width=50)
            gui.ListColumn(name='tracks', text='Tracks', width=300)
            gui.ListColumn(name='tracksfound', text='Tracks found', width=150)
            gui.ListColumn(name='id', text='', width=0)
        gui.Gauge(name='progressbar', height=down_gauge_height, left=0, top=down_gauge_top, width=down_win_width, value=0, )

    downwin = gui.get("downwin")
    downwin['btn_down_all'].onclick = download_all_songs
    plr = pleer.Pleer()
    # print(pleer.Pleer())


    tracksList = []
    (oldtracks_position, oldtracks_json) = mainwin["trackslist"].items()[0]

    tracks = m.get_release_by_id(oldtracks_json["id"], includes=["artists", "recordings"])
    print(tracks)
    for idx, track in enumerate(tracks["release"]["medium-list"][0]["track-list"]):
        print(idx)

        tracksList.append(plr.search(mainwin['artistslist'].get_selected_items()[0]["artist"] + " " + track["recording"]["title"], track))
        
    lv = downwin["downloadlist"]
    lv.items = tracksList
开发者ID:napcae,项目名称:steeb,代码行数:32,代码来源:steeb.py


示例9: strip_result

def strip_result(id,make_key,disc_index):
    try:
        result = musicbrainzngs.get_releases_by_discid(id,includes=["labels","recordings","artist-credits"])
        root=result['disc']['release-list'][0]
        discid=result['disc']['id']
    except musicbrainzngs.ResponseError:
        result = musicbrainzngs.get_release_by_id(id,includes=["labels","recordings","artist-credits"])
        root=result['release']
        discid=None
        
    disc_count=root['medium-count']
    track_list=root['medium-list'][disc_index]['track-list']
    track_count=root['medium-list'][disc_index]['track-count']
    disc_title=root['title']
    release=root['id']

    out=[]
    for track in track_list:
        title=track['recording']['title']
        item=dict(artists=track['artist-credit-phrase'],
                num=track['number'],
                title=title,
                key=make_key(track=track))
        out.append(item)
    out_dict=dict(title=disc_title,track_count=track_count,path=the_album,track_list=out,discid=discid,
                  disc_count=disc_count,release=release)
    return out_dict
开发者ID:phaustin,项目名称:music,代码行数:27,代码来源:find_tracks.py


示例10: get_mb_data

def get_mb_data(id):
    id, disc_id = re.search('^(?:http://.+/)?(.+?)(?:#disc(\d+))?$', id).groups()

    try:
        release = m.get_release_by_id(id, ['artists','recordings','artist-credits'])['release']
    except m.MusicBrainzError, exceptions.e:
        print 'Error:', exceptions.e
        sys.exit(1)
开发者ID:stassats,项目名称:mm,代码行数:8,代码来源:tag.py


示例11: _get_release

def _get_release(release_id):
    """Returns a release containing all recordings and artists or raises
    MusicBrainzError
    """

    assert is_mbid(release_id)

    return musicbrainzngs.get_release_by_id(
        release_id,
        includes=["recordings", "artists", "artist-credits"])["release"]
开发者ID:bossjones,项目名称:quodlibet,代码行数:10,代码来源:mb.py


示例12: album_for_id

def album_for_id(albumid):
    """Fetches an album by its MusicBrainz ID and returns an AlbumInfo
    object or None if the album is not found.
    """
    try:
        res = musicbrainzngs.get_release_by_id(albumid, RELEASE_INCLUDES)
    except musicbrainzngs.ResponseError:
        log.debug('Album ID match failed.')
        return None
    return album_info(res['release'])
开发者ID:paulprovost,项目名称:beets,代码行数:10,代码来源:mb.py


示例13: getReleaseFromMB

def getReleaseFromMB(releaseId):
    """Retrieves release info from MusicBrainz by releaseId."""

    if not _initialised:
        _initialise()

    release = m.get_release_by_id(
            releaseId,
            includes=["recordings", "artists", "artist-credits", "artist-rels"]
    )

    return release
开发者ID:satlank,项目名称:smg,代码行数:12,代码来源:mb.py


示例14: get_release_by_id

def get_release_by_id(release_id):
  attempt = 0;                                                                  # Set attempt number for album art
  while attempt < maxAttempt:  
    try:  
      result = MB.get_release_by_id( release_id )['release'];                   # Get information about the relase
    except:  
      attempt+=1;                                                               # Increment the attempt counter by one
      time.sleep(2);                                                            # Sleep 10 seconds
    else:  
      break;  
  if attempt == maxAttempt: return None;                                         # If MusicBrainz search fails three times, return 2
  return result;  
开发者ID:kwodzicki,项目名称:iTunes_Music_Converter,代码行数:12,代码来源:get_album_art.py


示例15: stats_for_release

 def stats_for_release(self, releaseid):
     self.releases.add(releaseid)
     rel = mb.get_release_by_id(releaseid, includes=["recordings", "artist-rels"])
     rel = rel["release"]
     for disc in rel["medium-list"]:
         for track in disc["track-list"]:
             recording = track["recording"]["id"]
             self.stats_for_recording(recording)
     for relation in rel.get("artist-relation-list", []):
         artist = relation.get("artist", {}).get("id")
         if artist:
             self.artists.add(artist)
开发者ID:EQ4,项目名称:pycompmusic,代码行数:12,代码来源:stats.py


示例16: fetch_album_from_id

def fetch_album_from_id(id):
    """Retrieves an album (aka release) from MusicBrainz, and parses
    the MusicBrainz data to return a dict of relevant information."""

    try:
        release = musicbrainzngs.get_release_by_id(
            id, includes=['artists', 'media', 'recordings',
            'release-groups', 'labels', 'artist-credits', 'aliases'])
        release = release["release"]
    except musicbrainzngs.MusicBrainzError:
        raise

    # These tags aren't hidden behind layers of data structures,
    # and can be fetched without doing copious error checking
    info = {
        "album"         : release.get("title"),
        "albumartist_credit" : \
            release.get("artist-credit-phrase"),
        "album_id"      : release.get("id"),
        "country"       : release.get("country"),
        "date"          : release.get("date"),
        "status"        : release.get("status"),
        "totaldiscs"    : release.get("medium-count")
    }

    # But these all are
    try: artist_info = release["artist-credit"][0]["artist"]
    except KeyError: artist_info = {}

    info["albumartist"] = artist_info.get("name")
    info["albumartist_id"] = artist_info.get("id")
    info["albumartist_sort"] = artist_info.get("sort-name")
        
    try: info["label"] = release["label-info-list"][0]["label"]["name"]
    except KeyError: info["label"] = None

    try: media = release["medium-list"][0]["format"]
    except KeyError: media = None

    releasegroup_info = release.get("release-group", {})
    info["releasegroup_id"] = releasegroup_info.get("id")
    info["originaldate"] = releasegroup_info.get("first-release-date")

    text_info = release.get("text-representation", {})
    info["language"] = text_info.get("language")
    info["script"] = text_info.get("script")
    
    # Produce information about discs and tracks
    medium_list = release.get("medium-list")
    info["contents"] = sort_album_contents(medium_list)

    return info
开发者ID:ademberbic,项目名称:tagger,代码行数:52,代码来源:online.py


示例17: complete_musicbrainz__

    def complete_musicbrainz__(self, results):
        
        completed_results = []
        
        i = 0
        
        for r in results:
            
            if i > 3:
                #pass
                break
            
            i+=1
            
            print
            print 'RESULT'
            
            
            releases = []
            
            recording = r['recording']
            for release in recording['release-list']:
                
                #print release['id']
                
                release = musicbrainzngs.get_release_by_id(id=release['id'], includes=['url-rels', 'release-groups'])
                
                #print 'RELEASE!:::::::::::::::::::::::::::::::::::::::::::::::::'
                #print release
                
                relations = []
                
                try:
                    for relation in release['release']['url-relation-list']:
                        #print "Relation: target: %s - url: %s" % (relation['type'], relation['target'])
                        relations.append(relation)
                        
                except Exception, e:
                    #print e
                    pass
                
                release['relations'] = relations
                    
                releases.append(release)
                

            # order releases by date
            releases = self.mb_order_by_releasedate(releases)
            
            r['release-list'] = releases 
            
            completed_results.append(r)
开发者ID:hzlf,项目名称:openbroadcast,代码行数:52,代码来源:__old_process.py


示例18: album_for_id

def album_for_id(albumid):
    """Fetches an album by its MusicBrainz ID and returns an AlbumInfo
    object or None if the album is not found. May raise a
    MusicBrainzAPIError.
    """
    try:
        res = musicbrainzngs.get_release_by_id(albumid, RELEASE_INCLUDES)
    except musicbrainzngs.ResponseError:
        log.debug("Album ID match failed.")
        return None
    except musicbrainzngs.MusicBrainzError as exc:
        raise MusicBrainzAPIError(exc, "get release by ID", albumid, traceback.format_exc())
    return album_info(res["release"])
开发者ID:rubyeye37,项目名称:beets,代码行数:13,代码来源:mb.py


示例19: 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


示例20: mb_shit

    def mb_shit(self, mb_id):
        self.mb = mb_id
        import musicbrainzngs
        musicbrainzngs.set_useragent('a','.1','foo')
        r = musicbrainzngs.get_release_by_id(self.mb, includes=["artists", "recordings"])['release']
        d = {}
        all_tracklist = []
        for disc in r['medium-list']:
            all_tracklist += disc['track-list']

        d['trackCount'], d['artistName'], d['releaseDate'], d['primaryGenreName'], d['collectionPrice'] = len(all_tracklist), r['artist-credit'][0]['artist']['name'], str(r['date'])[0:4] + '-01-01T00:00:00Z', 'MB', None
        d['trackDetails'] = [{'trackTimeMillis': int(rec['recording']['length'])} for rec in all_tracklist]
        self.mb_details = d
        self.title = r['title']
        self.details = [{'artistName': d['artistName'], 'releaseDate': d['releaseDate']}]
开发者ID:jrwang,项目名称:mediagrab,代码行数:15,代码来源:media.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python musicbrainzngs.search_artists函数代码示例发布时间:2022-05-27
下一篇:
Python musicbrainzngs.get_recording_by_id函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap