def track_info(recording, index=None, medium=None, medium_index=None, medium_total=None):
 info = beets.autotag.hooks.TrackInfo(recording['title'], recording['id'], index=index, medium=medium, medium_index=medium_index, medium_total=medium_total, data_source=u'MusicBrainz', data_url=track_url(recording['id']))
 if recording.get('artist-credit'):
  (info.artist, info.artist_sort, info.artist_credit) = _flatten_artist_credit(recording['artist-credit'])
  artist = recording['artist-credit'][0]['artist']
  info.artist_id = artist['id']
 if recording.get('length'):
  info.length = (int(recording['length']) / 1000.0)
 lyricist = []
 composer = []
 for work_relation in recording.get('work-relation-list', ()):
  if (work_relation['type'] != 'performance'):
   continue
  for artist_relation in work_relation['work'].get('artist-relation-list', ()):
   if ('type' in artist_relation):
    type = artist_relation['type']
    if (type == 'lyricist'):
     lyricist.append(artist_relation['artist']['name'])
    elif (type == 'composer'):
     composer.append(artist_relation['artist']['name'])
 if lyricist:
  info.lyricist = u', '.join(lyricist)
 if composer:
  info.composer = u', '.join(composer)
 arranger = []
 for artist_relation in recording.get('artist-relation-list', ()):
  if ('type' in artist_relation):
   type = artist_relation['type']
   if (type == 'arranger'):
    arranger.append(artist_relation['artist']['name'])
 if arranger:
  info.arranger = u', '.join(arranger)
 info.decode()
 return info

def track_info ( recording , index = None , medium = None , medium_index = None , medium_total = None ) : info = beets . autotag . hooks . TrackInfo ( recording [ 'title' ] , recording [ 'id' ] , index = index , medium = medium , medium_index = medium_index , medium_total = medium_total , data_source = u'MusicBrainz' , data_url = track_url ( recording [ 'id' ] ) ) if recording . get ( 'artist-credit' ) : ( info . artist , info . artist_sort , info . artist_credit ) = _flatten_artist_credit ( recording [ 'artist-credit' ] ) artist = recording [ 'artist-credit' ] [ 0 ] [ 'artist' ] info . artist_id = artist [ 'id' ] if recording . get ( 'length' ) : info . length = ( int ( recording [ 'length' ] ) / 1000.0 ) lyricist = [ ] composer = [ ] for work_relation in recording . get ( 'work-relation-list' , ( ) ) : if ( work_relation [ 'type' ] != 'performance' ) : continue for artist_relation in work_relation [ 'work' ] . get ( 'artist-relation-list' , ( ) ) : if ( 'type' in artist_relation ) : type = artist_relation [ 'type' ] if ( type == 'lyricist' ) : lyricist . append ( artist_relation [ 'artist' ] [ 'name' ] ) elif ( type == 'composer' ) : composer . append ( artist_relation [ 'artist' ] [ 'name' ] ) if lyricist : info . lyricist = u', ' . join ( lyricist ) if composer : info . composer = u', ' . join ( composer ) arranger = [ ] for artist_relation in recording . get ( 'artist-relation-list' , ( ) ) : if ( 'type' in artist_relation ) : type = artist_relation [ 'type' ] if ( type == 'arranger' ) : arranger . append ( artist_relation [ 'artist' ] [ 'name' ] ) if arranger : info . arranger = u', ' . join ( arranger ) info . decode ( ) return info
translates a musicbrainz recording result dictionary into a beets trackinfo object .