mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-08 04:39:29 +01:00
Bug fixes: 503 error on import, Artists/songs with quotes in the name, logger.log removed
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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()
|
||||
@@ -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'])
|
||||
|
||||
|
||||
@@ -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):
|
||||
<th> </th>
|
||||
</tr>''' % (results[0][0], results[0][1], results[0][2], AlbumID, results[0][0], albumart))
|
||||
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()
|
||||
if len(trackmatches):
|
||||
have = '<img src="images/checkmark.png" width="20px">'
|
||||
@@ -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!<a class="blue" href="home">Go back</a>''')
|
||||
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 </br> ''' % 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 <a href="home">back</a>.''' % 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()
|
||||
|
||||
Reference in New Issue
Block a user