Ejemplo n.º 1
0
def finalize_update(artistid, artistname, errors=False):
    # Moving this little bit to it's own function so we can update have tracks & latest album when deleting extras

    myDB = db.DBConnection()

    latestalbum = myDB.action('SELECT AlbumTitle, ReleaseDate, AlbumID from albums WHERE ArtistID=? order by ReleaseDate DESC', [artistid]).fetchone()
    totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND AlbumID IN (SELECT AlbumID FROM albums WHERE Status != "Ignored")', [artistid]))
    #havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ?', [artist['artist_name']]))
    havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE ArtistID=? AND Location IS NOT NULL', [artistid])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND Matched = "Failed"', [artistname]))

    controlValueDict = {"ArtistID": artistid}

    if latestalbum:
        newValueDict = {"Status": "Active",
                        "LatestAlbum": latestalbum['AlbumTitle'],
                        "ReleaseDate": latestalbum['ReleaseDate'],
                        "AlbumID": latestalbum['AlbumID'],
                        "TotalTracks": totaltracks,
                        "HaveTracks": havetracks}
    else:
        newValueDict = {"Status": "Active",
                        "TotalTracks": totaltracks,
                        "HaveTracks": havetracks}

    if not errors:
        newValueDict['LastUpdated'] = helpers.now()

    myDB.upsert("artists", newValueDict, controlValueDict)
Ejemplo n.º 2
0
	def log(self, message, level):

		logger = logging.getLogger('headphones')
		
		threadname = threading.currentThread().getName()
		
		if level != 'DEBUG':
			headphones.LOG_LIST.insert(0, (helpers.now(), message, level, threadname))
		
		message = threadname + ' : ' + message

		if level == 'DEBUG':
			logger.debug(message)
		elif level == 'INFO':
			logger.info(message)
		elif level == 'WARNING':
			logger.warn(message)
		else:
			logger.error(message)
Ejemplo n.º 3
0
    controlValueDict = {"ArtistID": artistid}

    if latestalbum:
        newValueDict = {
            "Status": "Active",
            "LatestAlbum": latestalbum["AlbumTitle"],
            "ReleaseDate": latestalbum["ReleaseDate"],
            "AlbumID": latestalbum["AlbumID"],
            "TotalTracks": totaltracks,
            "HaveTracks": havetracks,
        }
    else:
        newValueDict = {"Status": "Active", "TotalTracks": totaltracks, "HaveTracks": havetracks}

    if not errors:
        newValueDict["LastUpdated"] = helpers.now()

    myDB.upsert("artists", newValueDict, controlValueDict)

    logger.info(u"Seeing if we need album art for: %s" % artist["artist_name"])
    cache.getThumb(ArtistID=artistid)

    if errors:
        logger.info(
            "[%s] Finished updating artist: %s but with errors, so not marking it as updated in the database"
            % (artist["artist_name"], artist["artist_name"])
        )
    else:
        myDB.action("DELETE FROM newartists WHERE ArtistName = ?", [artist["artist_name"]])
        logger.info(u"Updating complete for: %s" % artist["artist_name"])
Ejemplo n.º 4
0
    controlValueDict = {"ArtistID":     artistid}
    
    if latestalbum:
        newValueDict = {"Status":           "Active",
                        "LatestAlbum":      latestalbum['AlbumTitle'],
                        "ReleaseDate":      latestalbum['ReleaseDate'],
                        "AlbumID":          latestalbum['AlbumID'],
                        "TotalTracks":      totaltracks,
                        "HaveTracks":       havetracks}
    else:
        newValueDict = {"Status":           "Active",
                        "TotalTracks":      totaltracks,
                        "HaveTracks":       havetracks}
                        
    if not errors:
        newValueDict['LastUpdated'] = helpers.now()
    
    myDB.upsert("artists", newValueDict, controlValueDict)
    
    logger.info(u"Seeing if we need album art for: " + artist['artist_name'])
    cache.getThumb(ArtistID=artistid)
    
    if errors:
        logger.info("Finished updating artist: " + artist['artist_name'] + " but with errors, so not marking it as updated in the database")
    else:
        logger.info(u"Updating complete for: " + artist['artist_name'])
    
def addReleaseById(rid):
    
    myDB = db.DBConnection()
Ejemplo n.º 5
0
 def test_notify(self):
     return self._notifyTwitter(
         "This is a test notification from Headphones at " + helpers.now(),
         force=True)
Ejemplo n.º 6
0
 def notify_download(self, title):
     if headphones.CONFIG.TWITTER_ENABLED:
         self._notifyTwitter(common.notifyStrings[
                                 common.NOTIFY_DOWNLOAD] + ': ' +
                             title + ' at ' + helpers.now())
Ejemplo n.º 7
0
 def notify_snatch(self, title):
     if headphones.CONFIG.TWITTER_ONSNATCH:
         self._notifyTwitter(
             common.notifyStrings[
                 common.NOTIFY_SNATCH] + ': ' + title + ' at ' +
             helpers.now())
Ejemplo n.º 8
0
    def emit(self, record):
        message = self.format(record)
        message = message.replace("\n", "<br />")

        headphones.LOG_LIST.insert(0, (helpers.now(), message, record.levelname, record.threadName))
Ejemplo n.º 9
0
 def notify_download(self, title):
     if headphones.CONFIG.TWITTER_ENABLED:
         self._notifyTwitter(common.notifyStrings[
                                 common.NOTIFY_DOWNLOAD] + ': ' + title + ' at ' + helpers.now())
Ejemplo n.º 10
0
 def notify_snatch(self, title):
     if headphones.CONFIG.TWITTER_ONSNATCH:
         self._notifyTwitter(
             common.notifyStrings[common.NOTIFY_SNATCH] + ': ' + title + ' at ' + helpers.now())
Ejemplo n.º 11
0
 def test_notify(self):
     return self._notifyTwitter("This is a test notification from Headphones at " + helpers.now(), force=True)
Ejemplo n.º 12
0
    def emit(self, record):
        message = self.format(record)
        message = message.replace("\n", "<br />")

        headphones.LOG_LIST.insert(
            0, (helpers.now(), message, record.levelname, record.threadName))
Ejemplo n.º 13
0
            "Status": "Active",
            "LatestAlbum": latestalbum['AlbumTitle'],
            "ReleaseDate": latestalbum['ReleaseDate'],
            "AlbumID": latestalbum['AlbumID'],
            "TotalTracks": totaltracks,
            "HaveTracks": havetracks
        }
    else:
        newValueDict = {
            "Status": "Active",
            "TotalTracks": totaltracks,
            "HaveTracks": havetracks
        }

    if not errors:
        newValueDict['LastUpdated'] = helpers.now()

    myDB.upsert("artists", newValueDict, controlValueDict)

    logger.info(u"Seeing if we need album art for: " + artist['artist_name'])
    cache.getThumb(ArtistID=artistid)

    if errors:
        logger.info(
            "Finished updating artist: " + artist['artist_name'] +
            " but with errors, so not marking it as updated in the database")
    else:
        logger.info(u"Updating complete for: " + artist['artist_name'])


def addReleaseById(rid):