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()
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()
def test_artist_tags(self): basicConfig(level=DEBUG) lastfm = LastFm(dir=TEST_DIR) pprint(lastfm.artist_tags('Talking Heads'), indent=2) print(list(lastfm.tags_for_artist('Jaga Jazzist')))
def test_track_search(self): basicConfig(level=DEBUG) lastfm = LastFm(dir=TEST_DIR) pprint(lastfm.track_search('all i need is a miracle'), indent=2) print(list(lastfm.artists_for_track('once more in the')))