def getTagTopArtists(tag, limit=50): myDB = db.DBConnection() results = myDB.select('SELECT ArtistID from artists') url = 'http://ws.audioscrobbler.com/2.0/?method=tag.gettopartists&limit=%s&tag=%s&api_key=%s' % ( limit, tag, api_key) data = urllib2.urlopen(url, timeout=20).read() try: d = minidom.parseString(data) except: logger.error("Could not parse artist list from last.fm data") return artists = d.getElementsByTagName("artist") artistlist = [] for artist in artists: mbidnode = artist.getElementsByTagName("mbid")[0].childNodes for node in mbidnode: artist_mbid = node.data try: if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) except: continue from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid)
def getArtists(): myDB = db.DBConnection() results = myDB.select("SELECT ArtistID from artists") if not headphones.LASTFM_USERNAME: logger.warn("Last.FM username not set, not importing artists.") return logger.info("Fetching artists from Last.FM for username: %s", headphones.LASTFM_USERNAME) data = request_lastfm("library.getartists", limit=10000, user=headphones.LASTFM_USERNAME) if data and "artists" in data: artistlist = [] artists = data["artists"]["artist"] logger.debug("Fetched %d artists from Last.FM", len(artists)) for artist in artists: artist_mbid = artist["mbid"] if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid) logger.info("Imported %d new artists from Last.FM", len(artistlist))
def getArtists(): myDB = db.DBConnection() results = myDB.select("SELECT ArtistID from artists") if not headphones.CONFIG.LASTFM_USERNAME: logger.warn("Last.FM username not set, not importing artists.") return logger.info("Fetching artists from Last.FM for username: %s", headphones.CONFIG.LASTFM_USERNAME) data = request_lastfm("library.getartists", limit=10000, user=headphones.CONFIG.LASTFM_USERNAME) if data and "artists" in data: artistlist = [] artists = data["artists"]["artist"] logger.debug("Fetched %d artists from Last.FM", len(artists)) for artist in artists: artist_mbid = artist["mbid"] if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid) logger.info("Imported %d new artists from Last.FM", len(artistlist))
def getArtists(): myDB = db.DBConnection() results = myDB.select('SELECT ArtistID from artists') if not headphones.LASTFM_USERNAME: return else: username = headphones.LASTFM_USERNAME url = 'http://ws.audioscrobbler.com/2.0/?method=library.getartists&limit=10000&api_key=%s&user=%s' % (api_key, username) data = urllib.urlopen(url).read() d = minidom.parseString(data) artists = d.getElementsByTagName("artist") artistlist = [] for artist in artists: mbidnode = artist.getElementsByTagName("mbid")[0].childNodes for node in mbidnode: artist_mbid = node.data try: if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) except: continue from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid)
def getTagTopArtists(tag, limit=50): myDB = db.DBConnection() results = myDB.select("SELECT ArtistID from artists") logger.info("Fetching top artists from Last.FM for tag: %s", tag) data = request_lastfm("tag.gettopartists", limit=limit, tag=tag) if data and "topartists" in data: artistlist = [] artists = data["topartists"]["artist"] logger.debug("Fetched %d artists from Last.FM", len(artists)) for artist in artists: try: artist_mbid = artist["mbid"] except KeyError: continue if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid) logger.debug("Added %d new artists from Last.FM", len(artistlist))
def getTagTopArtists(tag, limit=50): myDB = db.DBConnection() results = myDB.select('SELECT ArtistID from artists') url = 'http://ws.audioscrobbler.com/2.0/?method=tag.gettopartists&limit=%s&tag=%s&api_key=%s' % (limit, tag, api_key) data = urllib2.urlopen(url, timeout=20).read() try: d = minidom.parseString(data) except: logger.error("Could not parse artist list from last.fm data") return artists = d.getElementsByTagName("artist") artistlist = [] for artist in artists: mbidnode = artist.getElementsByTagName("mbid")[0].childNodes for node in mbidnode: artist_mbid = node.data try: if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) except: continue from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid)
def getArtists(): myDB = db.DBConnection() results = myDB.select('SELECT ArtistID from artists') if not headphones.LASTFM_USERNAME: return else: username = headphones.LASTFM_USERNAME url = 'http://ws.audioscrobbler.com/2.0/?method=library.getartists&limit=10000&api_key=%s&user=%s' % ( api_key, username) data = urllib.urlopen(url).read() d = minidom.parseString(data) artists = d.getElementsByTagName("artist") artistlist = [] for artist in artists: mbidnode = artist.getElementsByTagName("mbid")[0].childNodes for node in mbidnode: artist_mbid = node.data try: if not any(artist_mbid in x for x in results): artistlist.append(artist_mbid) except: continue from headphones import importer for artistid in artistlist: importer.addArtisttoDB(artistid)
def _refreshArtist(self, **kwargs): if 'id' not in kwargs: self.data = 'Missing parameter: id' return else: self.id = kwargs['id'] try: importer.addArtisttoDB(self.id) except Exception, e: self.data = e
def _refreshArtist(self, **kwargs): if "id" not in kwargs: self.data = "Missing parameter: id" return else: self.id = kwargs["id"] try: importer.addArtisttoDB(self.id) except Exception, e: self.data = e
def dbUpdate(forcefull=False): myDB = db.DBConnection() active_artists = myDB.select( 'SELECT ArtistID, ArtistName from artists WHERE Status="Active" or Status="Loading" order by LastUpdated ASC') logger.info('Starting update for %i active artists', len(active_artists)) for artist in active_artists: artistid = artist[0] importer.addArtisttoDB(artistid=artistid, extrasonly=False, forcefull=forcefull) logger.info('Active artist update complete')
def dbUpdate(forcefull=False): myDB = db.DBConnection() activeartists = myDB.select('SELECT ArtistID, ArtistName from artists WHERE Status="Active" or Status="Loading" order by LastUpdated ASC') logger.info('Starting update for %i active artists' % len(activeartists)) for artist in activeartists: artistid = artist[0] importer.addArtisttoDB(artistid=artistid, extrasonly=False, forcefull=forcefull) logger.info('Active artist update complete')
def dbUpdate(): myDB = db.DBConnection() activeartists = myDB.select('SELECT ArtistID, ArtistName from artists WHERE Status="Active" or Status="Loading" order by ArtistSortName collate nocase') logger.info('Starting update for %i active artists' % len(activeartists)) for artist in activeartists: artistid = artist[0] importer.addArtisttoDB(artistid) logger.info('Update complete')
def refreshArtist(self, ArtistID): importer.addArtisttoDB(ArtistID) raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)