diff --git a/data/css/style.css b/data/css/style.css
index 3aba9cad..e7f51eb7 100644
--- a/data/css/style.css
+++ b/data/css/style.css
@@ -96,6 +96,9 @@ h1{
.updatebar{
text-align: center;
}
+.version{
+ font-size: 12px;
+ }
a:link {
color: #5E2612;
text-decoration: none;
diff --git a/headphones/db.py b/headphones/db.py
new file mode 100644
index 00000000..502195dc
--- /dev/null
+++ b/headphones/db.py
@@ -0,0 +1,84 @@
+# Stolen from sick beards db.py.
+
+from __future__ import with_statement
+
+import os
+import sqlite3
+import threading
+import time
+
+import headphones
+
+from headphones import logger
+
+db_lock = threading.Lock()
+
+def dbFilename(filename="headphones.db"):
+
+ return os.path.join(headphones.DATA_DIR, filename)
+
+class DBConnection:
+
+ def __init__(self, filename="headphones.db"):
+
+ self.filename = filename
+ self.connection = sqlite3.connect(dbFilename(filename), 20)
+ self.connection.row_factory = sqlite3.Row
+
+ def action(self, query, args=None):
+
+ with db_lock:
+
+ if query == None:
+ return
+
+ sqlResult = None
+ attempt = 0
+
+ while attempt < 5:
+ try:
+ if args == None:
+ #logger.debug(self.filename+": "+query)
+ sqlResult = self.connection.execute(query)
+ else:
+ #logger.debug(self.filename+": "+query+" with args "+str(args))
+ sqlResult = self.connection.execute(query, args)
+ self.connection.commit()
+ break
+ except sqlite3.OperationalError, e:
+ if "unable to open database file" in e.message or "database is locked" in e.message:
+ logger.warn('Database Error: %s' % e)
+ attempt += 1
+ time.sleep(1)
+ else:
+ logger.error('Database error: %s' % e)
+ raise
+ except sqlite3.DatabaseError, e:
+ logger.error('Fatal Error executing %s :: %s' % (command, e))
+ raise
+
+ return sqlResult
+
+ def select(self, query, args=None):
+
+ sqlResults = self.action(query, args).fetchall()
+
+ if sqlResults == None:
+ return []
+
+ return sqlResults
+
+ def upsert(self, tableName, valueDict, keyDict):
+
+ changesBefore = self.connection.total_changes
+
+ genParams = lambda myDict : [x + " = ?" for x in myDict.keys()]
+
+ query = "UPDATE "+tableName+" SET " + ", ".join(genParams(valueDict)) + " WHERE " + " AND ".join(genParams(keyDict))
+
+ self.action(query, valueDict.values() + keyDict.values())
+
+ if self.connection.total_changes == changesBefore:
+ query = "INSERT INTO "+tableName+" (" + ", ".join(valueDict.keys() + keyDict.keys()) + ")" + \
+ " VALUES (" + ", ".join(["?"] * len(valueDict.keys() + keyDict.keys())) + ")"
+ self.action(query, valueDict.values() + keyDict.values())
\ No newline at end of file
diff --git a/headphones/helpers.py b/headphones/helpers.py
index 560402d1..03bea96c 100644
--- a/headphones/helpers.py
+++ b/headphones/helpers.py
@@ -1,6 +1,11 @@
+import time
+from operator import itemgetter
+import datetime
+
def multikeysort(items, columns):
- from operator import itemgetter
+
comparers = [ ((itemgetter(col[1:].strip()), -1) if col.startswith('-') else (itemgetter(col.strip()), 1)) for col in columns]
+
def comparer(left, right):
for fn, mult in comparers:
result = cmp(fn(left), fn(right))
@@ -8,6 +13,7 @@ def multikeysort(items, columns):
return mult * result
else:
return 0
+
return sorted(items, cmp=comparer)
def checked(variable):
@@ -55,4 +61,18 @@ def latinToAscii(unicrap):
pass
else:
r += str(i)
- return r
\ No newline at end of file
+ return r
+
+def convert_milliseconds(ms):
+
+ seconds = ms/1000
+ gmtime = time.gmtime(seconds)
+
+ minutes = time.strftime("%M:%S", gmtime)
+
+ return minutes
+
+def today():
+ today = datetime.date.today()
+ yyyymmdd = datetime.date.isoformat(today)
+ return yyyymmdd
\ No newline at end of file
diff --git a/headphones/importer.py b/headphones/importer.py
new file mode 100644
index 00000000..67f6f606
--- /dev/null
+++ b/headphones/importer.py
@@ -0,0 +1,155 @@
+from lib.pyItunes import *
+from lib.configobj import ConfigObj
+import time
+import os
+from lib.beets.mediafile import MediaFile
+
+import headphones
+from headphones import logger, helpers, db, mb
+
+various_artists_mbid = '89ad4ac3-39f7-470e-963a-56509c546377'
+
+def scanMusic(dir=None):
+
+ if not dir:
+ dir = headphones.MUSIC_DIR
+
+ results = []
+
+ for r,d,f in os.walk(unicode(dir)):
+ for files in f:
+ if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")):
+ results.append(os.path.join(r,files))
+
+ logger.info(u'%i music files found' % len(results))
+
+ if results:
+
+ lst = []
+
+ myDB = db.DBConnection()
+ myDB.action('''DELETE from have''')
+
+ for song in results:
+ try:
+ f = MediaFile(song)
+ except:
+ logger.info("Could not read file: '" + song + "'")
+ else:
+ if f.albumartist:
+ artist = f.albumartist
+ elif f.artist:
+ artist = f.artist
+ else:
+ continue
+
+ myDB.action('INSERT INTO have VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?)', [artist, f.album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid])
+ lst.append(artist)
+
+ artistlist = {}.fromkeys(lst).keys()
+ logger.info(u"Preparing to import %i artists" % len(artistlist))
+ artistlist_to_mbids(artistlist)
+
+def itunesImport(pathtoxml):
+
+ if os.path.splitext(pathtoxml)[1] == '.xml':
+ logger.info(u"Loading xml file from"+ pathtoxml)
+ pl = XMLLibraryParser(pathtoxml)
+ l = Library(pl.dictionary)
+ lst = []
+ for song in l.songs:
+ lst.append(song.artist)
+ rawlist = {}.fromkeys(lst).keys()
+ artistlist = [f for f in rawlist if f != None]
+
+ else:
+ rawlist = os.listdir(pathtoxml)
+ logger.info(u"Loading artists from directory:" +pathtoxml)
+ exclude = ['.ds_store', 'various artists', 'untitled folder', 'va']
+ artistlist = [f for f in rawlist if f.lower() not in exclude]
+
+ artistlist_to_mbids(artistlist)
+
+
+def artistlist_to_mbids(artistlist):
+
+ for artist in artistlist:
+
+ results = mb.findArtist(artist, limit=1)
+ artistid = results[0]['id']
+ if artistid != various_artists_mbid:
+ addArtisttoDB(artistid)
+
+
+def addArtisttoDB(artistid):
+
+ if artistid == various_artists_mbid:
+ logger.warn('Cannot import Various Artists.')
+ return
+
+ myDB = db.DBConnection()
+
+ artistlist = myDB.select('SELECT ArtistID, ArtistName from artists WHERE ArtistID=?', [artistid])
+
+ if any(artistid in x for x in artistlist):
+ logger.info(artistlist[0][1] + u" is already in the database, skipping")
+ return
+
+ artist = mb.getArtist(artistid)
+
+ if artist['artist_name'].startswith('The '):
+ sortname = artist['artist_name'][4:]
+ else:
+ sortname = artist['artist_name']
+
+
+
+ controlValueDict = {"ArtistID": artistid}
+ newValueDict = {"ArtistName": artist['artist_name'],
+ "ArtistSortName": sortname,
+ "DateAdded": helpers.today(),
+ "Status": "Loading"}
+
+ myDB.upsert("artists", newValueDict, controlValueDict)
+
+ for rg in artist['releasegroups']:
+
+ rgid = rg['id']
+
+ try:
+ releaseid = mb.getReleaseGroup(rgid)
+ except Exception, e:
+ logger.info('Unable to get release information for %s - it may not be a valid release group' % rg['title'])
+ continue
+
+ release = mb.getRelease(releaseid)
+
+ logger.info(u"Now adding album: " + release['title']+ " to the database")
+ controlValueDict = {"AlbumID": release['id']}
+ newValueDict = {"ArtistID": artistid,
+ "ArtistName": artist['artist_name'],
+ "AlbumTitle": rg['title'],
+ "AlbumASIN": release['asin'],
+ "ReleaseDate": release['date'],
+ "DateAdded": helpers.today(),
+ "Status": "Skipped"
+ }
+
+ myDB.upsert("albums", newValueDict, controlValueDict)
+
+ latestrelease = myDB.select("SELECT ReleaseDate, DateAdded from albums WHERE AlbumID=?", [release['id']])
+
+ if latestrelease[0][0] > latestrelease[0][1]:
+ logger.info(release['title'] + u" is an upcoming album. Setting its status to 'Wanted'...")
+ controlValueDict = {"AlbumID": release['id']}
+ newValueDict = {"Status": "Wanted"}
+ myDB.upsert("albums", newValueDict, controlValueDict)
+
+ for track in release['tracks']:
+
+ myDB.action('INSERT INTO tracks VALUES( ?, ?, ?, ?, ?, ?, ?, ?)', [artistid, artist['artist_name'], rg['title'], release['asin'], release['id'], track['title'], track['duration'], track['id']])
+
+ controlValueDict = {"ArtistID": artistid}
+ newValueDict = {"Status": "Active"}
+
+ myDB.upsert("artists", newValueDict, controlValueDict)
\ No newline at end of file
diff --git a/headphones/itunesimport.py b/headphones/itunesimport.py
deleted file mode 100644
index 292505eb..00000000
--- a/headphones/itunesimport.py
+++ /dev/null
@@ -1,133 +0,0 @@
-from lib.pyItunes import *
-from lib.configobj import ConfigObj
-import lib.musicbrainz2.webservice as ws
-import lib.musicbrainz2.model as m
-import lib.musicbrainz2.utils as u
-from headphones.mb import getReleaseGroup
-import string
-import time
-import os
-import sqlite3
-from lib.beets.mediafile import MediaFile
-
-import headphones
-from headphones import logger, helpers
-
-def scanMusic(dir=None):
-
- if not dir:
- dir = headphones.MUSIC_DIR
-
- results = []
-
- for r,d,f in os.walk(unicode(dir)):
- for files in f:
- if any(files.endswith(x) for x in (".mp3", ".flac", ".aac", ".ogg", ".ape")):
- results.append(os.path.join(r,files))
-
- logger.info(u'%i music files found' % len(results))
-
- if results:
-
- lst = []
-
- # open db connection to write songs you have
- conn=sqlite3.connect(headphones.DB_FILE)
- c=conn.cursor()
- c.execute('''DELETE from have''')
-
- for song in results:
- try:
- f = MediaFile(song)
- except:
- logger.info("Could not read file: '" + song + "'")
- else:
- if not f.artist:
- pass
- else:
- c.execute('INSERT INTO have VALUES( ?, ?, ?, ?, ?, ?, ?, ?, ?)', (f.artist, f.album, f.track, f.title, f.length, f.bitrate, f.genre, f.date, f.mb_trackid))
- lst.append(f.artist)
-
- conn.commit()
- c.close()
-
- artistlist = {}.fromkeys(lst).keys()
- logger.info(u"Preparing to import %i artists" % len(artistlist))
- importartist(artistlist)
-
-
-
-
-def itunesImport(pathtoxml):
- if os.path.splitext(pathtoxml)[1] == '.xml':
- logger.info(u"Loading xml file from"+ pathtoxml)
- pl = XMLLibraryParser(pathtoxml)
- l = Library(pl.dictionary)
- lst = []
- for song in l.songs:
- lst.append(song.artist)
- rawlist = {}.fromkeys(lst).keys()
- artistlist = [f for f in rawlist if f != None]
- importartist(artistlist)
- else:
- rawlist = os.listdir(pathtoxml)
- logger.info(u"Loading artists from directory:" +pathtoxml)
- exclude = ['.ds_store', 'various artists', 'untitled folder', 'va']
- artistlist = [f for f in rawlist if f.lower() not in exclude]
- importartist(artistlist)
-
-
-
-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.")
- else:
- logger.info(u"Found best match: "+result.artist.name+". Gathering album information...")
- 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')
- artistlist = c.fetchall()
- if any(artistid in x for x in artistlist):
- logger.info(result.artist.name + u" is already in the database, skipping")
- else:
- if artist.name.startswith('The '):
- sortname = artist.name[4:]
- else:
- sortname = artist.name
- c.execute('INSERT INTO artists VALUES( ?, ?, ?, CURRENT_DATE, ?)', (artistid, artist.name, sortname, 'Active'))
- for rg in artist.getReleaseGroups():
- rgid = u.extractUuid(rg.id)
-
- releaseid = getReleaseGroup(rgid)
- time.sleep(1)
-
- 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()
- c.execute('SELECT ReleaseDate, DateAdded from albums WHERE AlbumID="%s"' % u.extractUuid(results.id))
-
- latestrelease = c.fetchall()
-
- if latestrelease[0][0] > latestrelease[0][1]:
- logger.info(results.title + u" is an upcoming album. Setting its status to 'Wanted'...")
- c.execute('UPDATE albums SET Status = "Wanted" WHERE AlbumID="%s"' % u.extractUuid(results.id))
- else:
- pass
-
- 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)))
-
- conn.commit()
- c.close()
\ No newline at end of file
diff --git a/headphones/logger.py b/headphones/logger.py
index f7b1d4b0..f861a4c3 100644
--- a/headphones/logger.py
+++ b/headphones/logger.py
@@ -37,7 +37,7 @@ class RotatingLogger(object):
if not quiet:
consolehandler = logging.StreamHandler()
- consolehandler.setLevel(logging.DEBUG)
+ consolehandler.setLevel(logging.INFO)
consoleformatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(message)s', '%d-%b-%Y %H:%M:%S')
diff --git a/headphones/mb.py b/headphones/mb.py
index 3abf5696..f023ff23 100644
--- a/headphones/mb.py
+++ b/headphones/mb.py
@@ -1,4 +1,7 @@
+from __future__ import with_statement
+
import time
+import threading
import lib.musicbrainz2.webservice as ws
import lib.musicbrainz2.model as m
@@ -6,70 +9,194 @@ import lib.musicbrainz2.utils as u
from lib.musicbrainz2.webservice import WebServiceError
+from headphones import logger
from headphones.helpers import multikeysort
q = ws.Query()
-
+mb_lock = threading.Lock()
def findArtist(name, limit=1):
- artistlist = []
-
- artistResults = q.getArtists(ws.ArtistFilter(name=name, limit=limit))
-
- for result in artistResults:
-
- artistid = u.extractUuid(result.artist.id)
- artistlist.append([result.artist.name, artistid])
+ with mb_lock:
+
+ artistlist = []
+ attempt = 0
- return artistlist
+ while attempt < 5:
+
+ try:
+ artistResults = q.getArtists(ws.ArtistFilter(query=name, limit=limit))
+ break
+ except WebServiceError, e:
+ logger.warn('Attempt to retrieve information from MusicBrainz failed: %s' % e)
+ attempt += 1
+ time.sleep(1)
+
+ time.sleep(1)
+
+ for result in artistResults:
+
+ artistlist.append({
+ 'name': result.artist.name,
+ 'uniquename': result.artist.getUniqueName(),
+ 'id': u.extractUuid(result.artist.id),
+ 'url': result.artist.id,
+ 'score': result.score
+ })
+
+ return artistlist
def getArtist(artistid):
-
- rglist = []
-
- #Get all official release groups
- inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), ratings=False, releaseGroups=True)
- artist = q.getArtistById(artistid, inc)
+ with mb_lock:
- for rg in artist.getReleaseGroups():
+ artist_dict = {}
+
+ #Get all official release groups
+ inc = ws.ArtistIncludes(releases=(m.Release.TYPE_OFFICIAL, m.Release.TYPE_ALBUM), releaseGroups=True)
- rgid = u.extractUuid(rg.id)
- rglist.append([rg.title, rgid])
-
- return rglist
+ attempt = 0
+
+ while attempt < 5:
+
+ try:
+ artist = q.getArtistById(artistid, inc)
+ break
+ except WebServiceError, e:
+ logger.warn('Attempt to retrieve information from MusicBrainz failed: %s' % e)
+ attempt += 1
+ time.sleep(1)
+
+ time.sleep(1)
+
+ artist_dict['artist_name'] = artist.name
+ artist_dict['artist_sortname'] = artist.sortName
+ artist_dict['artist_uniquename'] = artist.getUniqueName()
+ artist_dict['artist_type'] = u.extractFragment(artist.type)
+ artist_dict['artist_begindate'] = artist.beginDate
+ artist_dict['artist_endDate'] = artist.endDate
+
+ releasegroups = []
+
+ for rg in artist.getReleaseGroups():
+
+ releasegroups.append({
+ 'title': rg.title,
+ 'id': u.extractUuid(rg.id),
+ 'url': rg.id,
+ 'type': u.getReleaseTypeName(rg.type)
+ })
+
+ artist_dict['releasegroups'] = releasegroups
+
+ return artist_dict
def getReleaseGroup(rgid):
-
- releaselist = []
+ """
+ Returns the best release out of any given release group
+ """
+ with mb_lock:
- 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:
-
- releaseid = u.extractUuid(release.id)
- inc = ws.ReleaseIncludes(tracks=True)
+ releaselist = []
+
+ inc = ws.ReleaseGroupIncludes(releases=True)
+
+ attempt = 0
+
+ while attempt < 5:
+
+ try:
+ releaseGroup = q.getReleaseGroupById(rgid, inc)
+ break
+ except WebServiceError, e:
+ logger.warn('Attempt to retrieve information from MusicBrainz failed: %s' % e)
+ attempt += 1
+ time.sleep(1)
+
+ 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:
+
+ inc = ws.ReleaseIncludes(tracks=True)
+
+ attempt = 0
+
+ while attempt < 5:
+
+ try:
+ releaseResult = q.getReleaseById(release.id, inc)
+ break
+ except WebServiceError, e:
+ logger.warn('Attempt to retrieve information for %s from MusicBrainz failed: %s' % (releaseResult.title, e))
+ attempt += 1
+ time.sleep(1)
+
+ if not releaseResult:
+ continue
+
+ time.sleep(1)
+
+ release_dict = {
+ 'asin': bool(releaseResult.asin),
+ 'tracks': len(releaseResult.getTracks()),
+ 'releaseid': u.extractUuid(releaseResult.id)
+ }
+
+ releaselist.append(release_dict)
+
+ a = multikeysort(releaselist, ['-asin', '-tracks'])
+
+ releaseid = a[0]['releaseid']
+
+ return releaseid
+
+def getRelease(releaseid):
+ """
+ Deep release search to get track info
+ """
+ with mb_lock:
+
+ release = {}
+
+ inc = ws.ReleaseIncludes(tracks=True, releaseEvents=True)
+
+ attempt = 0
+
+ while attempt < 5:
+
+ try:
+ results = q.getReleaseById(releaseid, inc)
+ break
+ except WebServiceError, e:
+ logger.warn('Attempt to retrieve information from MusicBrainz failed: %s' % e)
+ attempt += 1
+ time.sleep(1)
- releaseResult = q.getReleaseById(releaseid, inc)
time.sleep(1)
- release_dict = {
- 'asin': bool(releaseResult.asin),
- 'tracks': len(releaseResult.getTracks()),
- 'releaseid': u.extractUuid(releaseResult.id)
- }
+ release['title'] = results.title
+ release['id'] = u.extractUuid(results.id)
+ release['asin'] = results.asin
+ release['date'] = results.getEarliestReleaseDate()
- releaselist.append(release_dict)
-
- a = multikeysort(releaselist, ['-asin', '-tracks'])
-
- releaseid = a[0]['releaseid']
+ tracks = []
+
+ i = 1
+ for track in results.tracks:
+ tracks.append({
+ 'number': i,
+ 'title': track.title,
+ 'id': u.extractUuid(track.id),
+ 'url': track.id,
+ 'duration': track.duration
+ })
+ i += 1
+
+ release['tracks'] = tracks
+
+ return release
- return releaseid
def getExtras(artistid):
@@ -91,4 +218,4 @@ def getExtras(artistid):
print results.title
print u.getReleaseTypeName(results.releaseGroup.type)
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/headphones/searcher.py b/headphones/searcher.py
index 78543132..33abe979 100644
--- a/headphones/searcher.py
+++ b/headphones/searcher.py
@@ -1,23 +1,19 @@
import urllib
import string
import lib.feedparser as feedparser
-import sqlite3
import os, re
import headphones
-from headphones import logger
+from headphones import logger, db
def searchNZB(albumid=None):
- conn=sqlite3.connect(headphones.DB_FILE)
- c=conn.cursor()
+ myDB = db.DBConnection()
if albumid:
- c.execute('SELECT ArtistName, AlbumTitle, AlbumID, ReleaseDate from albums WHERE Status="Wanted" AND AlbumID="%s"' % albumid)
+ results = myDB.select('SELECT ArtistName, AlbumTitle, AlbumID, ReleaseDate from albums WHERE Status="Wanted" AND AlbumID=?', [albumid])
else:
- c.execute('SELECT ArtistName, AlbumTitle, AlbumID, ReleaseDate from albums WHERE Status="Wanted"')
-
- results = c.fetchall()
+ results = myDB.select('SELECT ArtistName, AlbumTitle, AlbumID, ReleaseDate from albums WHERE Status="Wanted"')
for albums in results:
@@ -176,10 +172,9 @@ def searchNZB(albumid=None):
logger.error(u"Unable to send link. Are you sure the host address is correct?")
break
- c.execute('UPDATE albums SET status = "Snatched" WHERE AlbumID="%s"' % albums[2])
- c.execute('INSERT INTO snatched VALUES( ?, ?, ?, ?, CURRENT_DATE, ?)', (albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"))
- conn.commit()
- c.close()
+ myDB.action('UPDATE albums SET status = "Snatched" WHERE AlbumID=?', [albums[2]])
+ myDB.action('INSERT INTO snatched VALUES( ?, ?, ?, ?, CURRENT_DATE, ?)', [albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"])
+
elif headphones.BLACKHOLE:
@@ -192,10 +187,9 @@ def searchNZB(albumid=None):
logger.error('Couldn\'t retrieve NZB: %s' % e)
break
- c.execute('UPDATE albums SET status = "Snatched" WHERE AlbumID="%s"' % albums[2])
- c.execute('INSERT INTO snatched VALUES( ?, ?, ?, ?, CURRENT_DATE, ?)', (albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"))
- conn.commit()
- c.close()
+ myDB.action('UPDATE albums SET status = "Snatched" WHERE AlbumID=?', [albums[2]])
+ myDB.action('INSERT INTO snatched VALUES( ?, ?, ?, ?, CURRENT_DATE, ?)', [albums[2], bestqual[0], bestqual[1], bestqual[2], "Snatched"])
+
diff --git a/headphones/templates.py b/headphones/templates.py
index 4dabac0d..1871cf7e 100644
--- a/headphones/templates.py
+++ b/headphones/templates.py
@@ -47,7 +47,7 @@ _footer = '''
-
+