mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 08:24:00 +01:00
Bug fixes: 503 error on import, Artists/songs with quotes in the name, logger.log removed
This commit is contained in:
+10
-5
@@ -201,9 +201,6 @@ def initialize():
|
|||||||
NZBSORG_UID = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_uid', '')
|
NZBSORG_UID = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_uid', '')
|
||||||
NZBSORG_HASH = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_hash', '')
|
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
|
# Put the log dir in the data dir for now
|
||||||
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||||
if not os.path.exists(LOG_DIR):
|
if not os.path.exists(LOG_DIR):
|
||||||
@@ -223,6 +220,9 @@ def initialize():
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error("Can't connect to the database: %s" % e)
|
logger.error("Can't connect to the database: %s" % e)
|
||||||
|
|
||||||
|
# Get the currently installed version
|
||||||
|
CURRENT_VERSION = versioncheck.getVersion()
|
||||||
|
|
||||||
__INITIALIZED__ = True
|
__INITIALIZED__ = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -341,14 +341,19 @@ def start():
|
|||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
|
|
||||||
|
# Start our scheduled background tasks
|
||||||
|
|
||||||
SCHED.add_cron_job(updater.dbUpdate, hour=4, minute=0, second=0)
|
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(searcher.searchNZB, minutes=NZB_SEARCH_INTERVAL)
|
||||||
SCHED.add_interval_job(itunesimport.scanMusic, minutes=LIBRARYSCAN_INTERVAL)
|
SCHED.add_interval_job(itunesimport.scanMusic, minutes=LIBRARYSCAN_INTERVAL)
|
||||||
|
SCHED.add_interval_job(versioncheck.checkGithub, minutes=300)
|
||||||
SCHED.add_interval_job(versioncheck.checkGithub, minutes=60)
|
|
||||||
|
|
||||||
SCHED.start()
|
SCHED.start()
|
||||||
|
|
||||||
|
# Check for new versions
|
||||||
|
versioncheck.checkGithub()
|
||||||
|
|
||||||
|
|
||||||
started = True
|
started = True
|
||||||
|
|
||||||
def dbcheck():
|
def dbcheck():
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ def importartist(artistlist):
|
|||||||
for name in artistlist:
|
for name in artistlist:
|
||||||
logger.info(u"Querying MusicBrainz for: "+name)
|
logger.info(u"Querying MusicBrainz for: "+name)
|
||||||
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=1))
|
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=1))
|
||||||
|
time.sleep(1)
|
||||||
for result in artistResults:
|
for result in artistResults:
|
||||||
if result.artist.name == 'Various Artists':
|
if result.artist.name == 'Various Artists':
|
||||||
logger.info(u"Top result is Various Artists. Skipping.")
|
logger.info(u"Top result is Various Artists. Skipping.")
|
||||||
@@ -90,6 +91,7 @@ def importartist(artistlist):
|
|||||||
artistid = u.extractUuid(result.artist.id)
|
artistid = u.extractUuid(result.artist.id)
|
||||||
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
|
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
|
||||||
artist = ws.Query().getArtistById(artistid, inc)
|
artist = ws.Query().getArtistById(artistid, inc)
|
||||||
|
time.sleep(1)
|
||||||
conn=sqlite3.connect(headphones.DB_FILE)
|
conn=sqlite3.connect(headphones.DB_FILE)
|
||||||
c=conn.cursor()
|
c=conn.cursor()
|
||||||
c.execute('SELECT ArtistID from artists')
|
c.execute('SELECT ArtistID from artists')
|
||||||
@@ -105,7 +107,7 @@ def importartist(artistlist):
|
|||||||
|
|
||||||
inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True)
|
inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True)
|
||||||
results = ws.Query().getReleaseById(releaseid, inc)
|
results = ws.Query().getReleaseById(releaseid, inc)
|
||||||
|
time.sleep(1)
|
||||||
logger.info(u"Now adding album: " + results.title+ " to the database")
|
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('INSERT INTO albums VALUES( ?, ?, ?, ?, ?, CURRENT_DATE, ?, ?)', (artistid, results.artist.name, results.title, results.asin, results.getEarliestReleaseDate(), u.extractUuid(results.id), 'Skipped'))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -121,8 +123,6 @@ def importartist(artistlist):
|
|||||||
|
|
||||||
for track in results.tracks:
|
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)))
|
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()
|
conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
+2
-2
@@ -46,7 +46,7 @@ def getReleaseGroup(rgid):
|
|||||||
|
|
||||||
inc = ws.ReleaseGroupIncludes(releases=True)
|
inc = ws.ReleaseGroupIncludes(releases=True)
|
||||||
releaseGroup = q.getReleaseGroupById(rgid, inc)
|
releaseGroup = q.getReleaseGroupById(rgid, inc)
|
||||||
|
time.sleep(1)
|
||||||
# I think for now we have to make separate queries for each release, in order
|
# 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.)
|
# to get more detailed release info (ASIN, track count, etc.)
|
||||||
for release in releaseGroup.releases:
|
for release in releaseGroup.releases:
|
||||||
@@ -55,6 +55,7 @@ def getReleaseGroup(rgid):
|
|||||||
inc = ws.ReleaseIncludes(tracks=True)
|
inc = ws.ReleaseIncludes(tracks=True)
|
||||||
|
|
||||||
releaseResult = q.getReleaseById(releaseid, inc)
|
releaseResult = q.getReleaseById(releaseid, inc)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
release_dict = {
|
release_dict = {
|
||||||
'asin': bool(releaseResult.asin),
|
'asin': bool(releaseResult.asin),
|
||||||
@@ -63,7 +64,6 @@ def getReleaseGroup(rgid):
|
|||||||
}
|
}
|
||||||
|
|
||||||
releaselist.append(release_dict)
|
releaselist.append(release_dict)
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
a = multikeysort(releaselist, ['-asin', '-tracks'])
|
a = multikeysort(releaselist, ['-asin', '-tracks'])
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -113,7 +113,7 @@ class WebInterface(object):
|
|||||||
while i < len(results):
|
while i < len(results):
|
||||||
c.execute('''SELECT TrackTitle from tracks WHERE AlbumID="%s"''' % results[i][2])
|
c.execute('''SELECT TrackTitle from tracks WHERE AlbumID="%s"''' % results[i][2])
|
||||||
totaltracks = len(c.fetchall())
|
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())
|
havetracks = len(c.fetchall())
|
||||||
try:
|
try:
|
||||||
percent = (havetracks*100)/totaltracks
|
percent = (havetracks*100)/totaltracks
|
||||||
@@ -167,7 +167,7 @@ class WebInterface(object):
|
|||||||
<th> </th>
|
<th> </th>
|
||||||
</tr>''' % (results[0][0], results[0][1], results[0][2], AlbumID, results[0][0], albumart))
|
</tr>''' % (results[0][0], results[0][1], results[0][2], AlbumID, results[0][0], albumart))
|
||||||
while i < len(results):
|
while i < len(results):
|
||||||
c.execute('''SELECT TrackTitle from have WHERE ArtistName like "%s" AND AlbumTitle like "%s" AND TrackTitle like "%s"''' % (results[i][1], results[i][2], results[i][3]))
|
c.execute('''SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle like ? AND TrackTitle like ?''', (results[i][1], results[i][2], results[i][3]))
|
||||||
trackmatches = c.fetchall()
|
trackmatches = c.fetchall()
|
||||||
if len(trackmatches):
|
if len(trackmatches):
|
||||||
have = '<img src="images/checkmark.png" width="20px">'
|
have = '<img src="images/checkmark.png" width="20px">'
|
||||||
@@ -193,12 +193,14 @@ class WebInterface(object):
|
|||||||
def findArtist(self, name):
|
def findArtist(self, name):
|
||||||
|
|
||||||
page = [templates._header]
|
page = [templates._header]
|
||||||
|
page.append(templates._logobar)
|
||||||
|
page.append(templates._nav)
|
||||||
if len(name) == 0 or name == 'Add an artist':
|
if len(name) == 0 or name == 'Add an artist':
|
||||||
raise cherrypy.HTTPRedirect("home")
|
raise cherrypy.HTTPRedirect("home")
|
||||||
else:
|
else:
|
||||||
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=8))
|
artistResults = ws.Query().getArtists(ws.ArtistFilter(string.replace(name, '&', '%38'), limit=8))
|
||||||
if len(artistResults) == 0:
|
if len(artistResults) == 0:
|
||||||
logger.log(u"No results found for " + name)
|
logger.info(u"No results found for " + name)
|
||||||
page.append('''No results!<a class="blue" href="home">Go back</a>''')
|
page.append('''No results!<a class="blue" href="home">Go back</a>''')
|
||||||
return page
|
return page
|
||||||
elif len(artistResults) > 1:
|
elif len(artistResults) > 1:
|
||||||
@@ -222,6 +224,8 @@ class WebInterface(object):
|
|||||||
|
|
||||||
def artistInfo(self, artistid):
|
def artistInfo(self, artistid):
|
||||||
page = [templates._header]
|
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)
|
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
|
||||||
artist = ws.Query().getArtistById(artistid, inc)
|
artist = ws.Query().getArtistById(artistid, inc)
|
||||||
page.append('''Artist Name: %s </br> ''' % artist.name)
|
page.append('''Artist Name: %s </br> ''' % artist.name)
|
||||||
@@ -235,12 +239,14 @@ class WebInterface(object):
|
|||||||
def addArtist(self, artistid):
|
def addArtist(self, artistid):
|
||||||
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
|
inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
|
||||||
artist = ws.Query().getArtistById(artistid, inc)
|
artist = ws.Query().getArtistById(artistid, inc)
|
||||||
|
time.sleep(1)
|
||||||
conn=sqlite3.connect(headphones.DB_FILE)
|
conn=sqlite3.connect(headphones.DB_FILE)
|
||||||
c=conn.cursor()
|
c=conn.cursor()
|
||||||
c.execute('SELECT ArtistID from artists')
|
c.execute('SELECT ArtistID from artists')
|
||||||
artistlist = c.fetchall()
|
artistlist = c.fetchall()
|
||||||
if any(artistid in x for x in artistlist):
|
if any(artistid in x for x in artistlist):
|
||||||
page = [templates._header]
|
page = [templates._header]
|
||||||
|
page.append
|
||||||
page.append('''%s has already been added. Go <a href="home">back</a>.''' % artist.name)
|
page.append('''%s has already been added. Go <a href="home">back</a>.''' % artist.name)
|
||||||
logger.info(artist.name + u" is already in the database!")
|
logger.info(artist.name + u" is already in the database!")
|
||||||
c.close()
|
c.close()
|
||||||
@@ -256,7 +262,7 @@ class WebInterface(object):
|
|||||||
|
|
||||||
inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True)
|
inc = ws.ReleaseIncludes(artist=True, releaseEvents= True, tracks= True, releaseGroup=True)
|
||||||
results = ws.Query().getReleaseById(releaseid, inc)
|
results = ws.Query().getReleaseById(releaseid, inc)
|
||||||
|
time.sleep(1)
|
||||||
logger.info(u"Now adding album: " + results.title+ " to the database")
|
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('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))
|
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:
|
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)))
|
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()
|
conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user