cloudtunes-server/cloudtunes/library/utils.py
def compress_tracks_to_json(tracks):
    """
    Serialize tracks to a list with fields as defined in `FIELDS_ORDER`.

    """
    collection = defaultdict(partial(defaultdict, list))
    for track in tracks:
        source = track['source'][0]  # [dy]
        source_id = None
        if source == 'y':
            source_id = track['youtube']['id']

        artist = track.get('artist') or UNTITLED_ARTIST
        album = track.get('album') or UNTITLED_ALBUM

        collection[artist][album].append((
            str(track['_id']),
            source,
            source_id,
            track['title'],
            track.get('number') or 0,
            track.get('mbid'),
            track.get('artist_mbid'),
            track.get('album_mbid')
        ))

    return collection

    Serialize tracks to a list with fields as defined in `FIELDS_ORDER`.

    
Serialize tracks to a list with fields as defined in `FIELDS_ORDER`.
Serialize tracks to a list with fields as defined in ` FIELDS_ORDER ` .
def compress_tracks_to_json(tracks):
    collection = defaultdict(partial(defaultdict, list))
    for track in tracks:
        source = track['source'][0]  
        source_id = None
        if source == 'y':
            source_id = track['youtube']['id']
        artist = track.get('artist') or UNTITLED_ARTIST
        album = track.get('album') or UNTITLED_ALBUM
        collection[artist][album].append((
            str(track['_id']),
            source,
            source_id,
            track['title'],
            track.get('number') or 0,
            track.get('mbid'),
            track.get('artist_mbid'),
            track.get('album_mbid')
        ))
    return collection
def compress_tracks_to_json ( tracks ) : collection = defaultdict ( partial ( defaultdict , list ) ) for track in tracks : source = track [ 'source' ] [ 0 ] source_id = None if source == 'y' : source_id = track [ 'youtube' ] [ 'id' ] artist = track . get ( 'artist' ) or UNTITLED_ARTIST album = track . get ( 'album' ) or UNTITLED_ALBUM collection [ artist ] [ album ] . append ( ( str ( track [ '_id' ] ) , source , source_id , track [ 'title' ] , track . get ( 'number' ) or 0 , track . get ( 'mbid' ) , track . get ( 'artist_mbid' ) , track . get ( 'album_mbid' ) ) ) return collection
Serialize tracks to a list with fields as defined in `FIELDS_ORDER`.
Serialize tracks to a list with fields as defined in ` FIELDS_ORDER ` .
"""
    Serialize tracks to a list with fields as defined in `FIELDS_ORDER`.

    """ # [dy]
tracks