Exemplo n.º 1
0
 def __init__(self, secret=None, proxy=None, dir=None, name=None):
     self.__api_key = '542c2f7c651d929ece5a72f18db35a93'
     if not secret:
         secret = lastfm_kargs(dir=dir, name=name)[SECRET]
         proxy = lastfm_kargs(dir=dir, name=name)[PROXY]
     self.__secret = secret
     self.__proxy = proxy
     self.__timestamp = None
Exemplo n.º 2
0
def tag_artists(dir=None, name=None):
    session = open_db(dir=dir, name=name)()
    try:
        lastfm = LastFm(**lastfm_kargs(dir=dir, name=name))
        for artist in session.query(LastFmArtist).filter(LastFmArtist.tagged == False).all():
            tag_artist(session, lastfm, artist)
    finally:
        session.close()
Exemplo n.º 3
0
def tag_artists(dir=None, name=None):
    session = open_db(dir=dir, name=name)()
    try:
        lastfm = LastFm(**lastfm_kargs(dir=dir, name=name))
        for artist in session.query(LastFmArtist).filter(
                LastFmArtist.tagged == False).all():
            tag_artist(session, lastfm, artist)
    finally:
        session.close()
Exemplo n.º 4
0
def identify_artists(ignore, dir=None, name=None):
    LOG.info('Opening database.')
    session = open_db(dir=dir, name=name)()
    try:
        lastfm = LastFm(**lastfm_kargs(dir=dir, name=name))
        artists = session.query(LocalArtist).filter(LocalArtist.lastfm_artist == None).all()
        LOG.info('Read {0} artists.'.format(len(artists)))
        for artist in artists:
            if ignore:
                name = artist.name
            else:
                name = identify_artist(session, lastfm, artist)
            LOG.info('Identified {0} as {1}.'.format(artist.name, name))
            try:
                lastfm_artist = session.query(LastFmArtist).filter(LastFmArtist.name == name).one()
            except NoResultFound:
                lastfm_artist = LastFmArtist(name=name)
                session.add(lastfm_artist)
            artist.lastfm_artist = lastfm_artist
            session.commit()
    finally:
        session.close()