示例#1
0
def fill_hdf5_from_musicbrainz(h5,connect):
    """
    Fill an open hdf5 using the musicbrainz server and data.
    We assume this code is run after fill_hdf5_from_artist/song
    because we need artist_mbid, artist_name, release and title
    INPUT
       h5        - open song file (append mode)
       connect   - open pg connection to musicbrainz_db
    """
    # get info from h5 song file
    ambid = h5.root.metadata.songs.cols.artist_mbid[0]
    artist_name = h5.root.metadata.songs.cols.artist_name[0]
    release = h5.root.metadata.songs.cols.release[0]
    title = h5.root.metadata.songs.cols.title[0]
    # get the musicbrainz table, fill it
    musicbrainz = h5.root.musicbrainz.songs
    musicbrainz.cols.year[0] = QUERYMB.find_year_safemode(connect,ambid,title,release,artist_name)
    # fill the musicbrainz arrays
    group = h5.root.musicbrainz
    musicbrainz.cols.idx_artist_mbtags[0] = 0
    tags,tagcount = QUERYMB.get_artist_tags(connect, ambid, maxtags=20)
    group.artist_mbtags.append( np.array(tags,dtype='string') )
    group.artist_mbtags_count.append( np.array(tagcount,dtype='float64') )
    # done, flush
    musicbrainz.flush()
示例#2
0
def fill_hdf5_from_musicbrainz(h5, connect):
    """
    Fill an open hdf5 using the musicbrainz server and data.
    We assume this code is run after fill_hdf5_from_artist/song
    because we need artist_mbid, artist_name, release and title
    INPUT
       h5        - open song file (append mode)
       connect   - open pg connection to musicbrainz_db
    """
    # get info from h5 song file
    ambid = h5.root.metadata.songs.cols.artist_mbid[0]
    artist_name = h5.root.metadata.songs.cols.artist_name[0]
    release = h5.root.metadata.songs.cols.release[0]
    title = h5.root.metadata.songs.cols.title[0]
    # get the musicbrainz table, fill it
    musicbrainz = h5.root.musicbrainz.songs
    musicbrainz.cols.year[0] = QUERYMB.find_year_safemode(
        connect, ambid, title, release, artist_name)
    # fill the musicbrainz arrays
    group = h5.root.musicbrainz
    musicbrainz.cols.idx_artist_mbtags[0] = 0
    tags, tagcount = QUERYMB.get_artist_tags(connect, ambid, maxtags=20)
    group.artist_mbtags.append(np.array(tags, dtype='string'))
    group.artist_mbtags_count.append(np.array(tagcount, dtype='float64'))
    # done, flush
    musicbrainz.flush()