diff --git a/headphones/__init__.py b/headphones/__init__.py index 292bd8fa..75c65bb5 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -200,9 +200,6 @@ def initialize(): NZBSORG = bool(check_setting_int(CFG, 'NZBsorg', 'nzbsorg', 0)) NZBSORG_UID = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_uid', '') NZBSORG_HASH = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_hash', '') - - # Get the currently installed version - CURRENT_VERSION = versioncheck.getVersion() # Put the log dir in the data dir for now LOG_DIR = os.path.join(DATA_DIR, 'logs') @@ -222,6 +219,9 @@ def initialize(): dbcheck() except Exception, e: logger.error("Can't connect to the database: %s" % e) + + # Get the currently installed version + CURRENT_VERSION = versioncheck.getVersion() __INITIALIZED__ = True return True @@ -340,15 +340,20 @@ def start(): global __INITIALIZED__, started if __INITIALIZED__: + + # Start our scheduled background tasks SCHED.add_cron_job(updater.dbUpdate, hour=4, minute=0, second=0) SCHED.add_interval_job(searcher.searchNZB, minutes=NZB_SEARCH_INTERVAL) SCHED.add_interval_job(itunesimport.scanMusic, minutes=LIBRARYSCAN_INTERVAL) - - SCHED.add_interval_job(versioncheck.checkGithub, minutes=60) + SCHED.add_interval_job(versioncheck.checkGithub, minutes=300) SCHED.start() + # Check for new versions + versioncheck.checkGithub() + + started = True def dbcheck(): diff --git a/headphones/itunesimport.py b/headphones/itunesimport.py index e6de812a..f36e0dd6 100644 --- a/headphones/itunesimport.py +++ b/headphones/itunesimport.py @@ -82,6 +82,7 @@ def importartist(artistlist): for name in artistlist: logger.info(u"Querying MusicBrainz for: "+name) artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=1)) + time.sleep(1) for result in artistResults: if result.artist.name == 'Various Artists': logger.info(u"Top result is Various Artists. Skipping.") @@ -90,6 +91,7 @@ def importartist(artistlist): artistid = u.extractUuid(result.artist.id) inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True) artist = ws.Query().getArtistById(artistid, inc) + time.sleep(1) conn=sqlite3.connect(headphones.DB_FILE) c=conn.cursor() c.execute('SELECT ArtistID from artists') @@ -105,7 +107,7 @@ def importartist(artistlist): inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True) results = ws.Query().getReleaseById(releaseid, inc) - + time.sleep(1) logger.info(u"Now adding album: " + results.title+ " to the database") c.execute('INSERT INTO albums VALUES( ?, ?, ?, ?, ?, CURRENT_DATE, ?, ?)', (artistid, results.artist.name, results.title, results.asin, results.getEarliestReleaseDate(), u.extractUuid(results.id), 'Skipped')) conn.commit() @@ -121,8 +123,6 @@ def importartist(artistlist): for track in results.tracks: c.execute('INSERT INTO tracks VALUES( ?, ?, ?, ?, ?, ?, ?, ?)', (artistid, results.artist.name, results.title, results.asin, u.extractUuid(results.id), track.title, track.duration, u.extractUuid(track.id))) - time.sleep(1) - time.sleep(1) conn.commit() c.close() \ No newline at end of file diff --git a/headphones/mb.py b/headphones/mb.py index 8082e086..3abf5696 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -46,7 +46,7 @@ def getReleaseGroup(rgid): inc = ws.ReleaseGroupIncludes(releases=True) releaseGroup = q.getReleaseGroupById(rgid, inc) - + time.sleep(1) # I think for now we have to make separate queries for each release, in order # to get more detailed release info (ASIN, track count, etc.) for release in releaseGroup.releases: @@ -55,6 +55,7 @@ def getReleaseGroup(rgid): inc = ws.ReleaseIncludes(tracks=True) releaseResult = q.getReleaseById(releaseid, inc) + time.sleep(1) release_dict = { 'asin': bool(releaseResult.asin), @@ -63,7 +64,6 @@ def getReleaseGroup(rgid): } releaselist.append(release_dict) - time.sleep(1) a = multikeysort(releaselist, ['-asin', '-tracks']) diff --git a/headphones/webserve.py b/headphones/webserve.py index 8be52c10..4eab7a8e 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -113,7 +113,7 @@ class WebInterface(object): while i < len(results): c.execute('''SELECT TrackTitle from tracks WHERE AlbumID="%s"''' % results[i][2]) totaltracks = len(c.fetchall()) - c.execute('''SELECT TrackTitle from have WHERE ArtistName like "%s" AND AlbumTitle like "%s"''' % (results[i][4], results[i][0])) + c.execute('''SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle like ?''', (results[i][4], results[i][0])) havetracks = len(c.fetchall()) try: percent = (havetracks*100)/totaltracks @@ -167,7 +167,7 @@ class WebInterface(object):
'
@@ -193,12 +193,14 @@ class WebInterface(object):
def findArtist(self, name):
page = [templates._header]
+ page.append(templates._logobar)
+ page.append(templates._nav)
if len(name) == 0 or name == 'Add an artist':
raise cherrypy.HTTPRedirect("home")
else:
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=8))
if len(artistResults) == 0:
- logger.log(u"No results found for " + name)
+ logger.info(u"No results found for " + name)
page.append('''No results!Go back''')
return page
elif len(artistResults) > 1:
@@ -222,6 +224,8 @@ class WebInterface(object):
def artistInfo(self, artistid):
page = [templates._header]
+ page.append(templates._logobar)
+ page.append(templates._nav)
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
artist = ws.Query().getArtistById(artistid, inc)
page.append('''Artist Name: %s ''' % artist.name)
@@ -235,12 +239,14 @@ class WebInterface(object):
def addArtist(self, artistid):
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
artist = ws.Query().getArtistById(artistid, inc)
+ time.sleep(1)
conn=sqlite3.connect(headphones.DB_FILE)
c=conn.cursor()
c.execute('SELECT ArtistID from artists')
artistlist = c.fetchall()
if any(artistid in x for x in artistlist):
page = [templates._header]
+ page.append
page.append('''%s has already been added. Go back.''' % artist.name)
logger.info(artist.name + u" is already in the database!")
c.close()
@@ -256,7 +262,7 @@ class WebInterface(object):
inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True)
results = ws.Query().getReleaseById(releaseid, inc)
-
+ time.sleep(1)
logger.info(u"Now adding album: " + results.title+ " to the database")
c.execute('INSERT INTO albums VALUES( ?, ?, ?, ?, ?, CURRENT_DATE, ?, ?)', (artistid, results.artist.name, results.title, results.asin, results.getEarliestReleaseDate(), u.extractUuid(results.id), 'Skipped'))
c.execute('SELECT ReleaseDate, DateAdded from albums WHERE AlbumID="%s"' % u.extractUuid(results.id))
@@ -270,7 +276,6 @@ class WebInterface(object):
for track in results.tracks:
c.execute('INSERT INTO tracks VALUES( ?, ?, ?, ?, ?, ?, ?, ?)', (artistid, results.artist.name, results.title, results.asin, u.extractUuid(results.id), track.title, track.duration, u.extractUuid(track.id)))
- time.sleep(1)
conn.commit()
c.close()