示例#1
0
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)
示例#2
0
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))
示例#3
0
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))
示例#4
0
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)
示例#5
0
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))
示例#6
0
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)
示例#7
0
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)
示例#8
0
文件: api.py 项目: kiteboy/headphones
    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
示例#9
0
	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
示例#10
0
    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
示例#11
0
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')
示例#12
0
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')
示例#13
0
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')
示例#14
0
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')
示例#15
0
 def refreshArtist(self, ArtistID):
     importer.addArtisttoDB(ArtistID)
     raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
示例#16
0
	def refreshArtist(self, ArtistID):
		importer.addArtisttoDB(ArtistID)	
		raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)