Added interfaces to staticdir in webstart, searcher excludes Various Artists from search (also cleaned up term encoding), default usenet retention in postprocessor/preprocess

This commit is contained in:
Remy
2011-08-09 21:02:47 -07:00
parent d44f2f1fc2
commit 07ffe8691c
3 changed files with 29 additions and 8 deletions

View File

@@ -111,6 +111,12 @@ def verify(albumid, albumpath):
tracks = myDB.select('SELECT * from tracks WHERE AlbumID=?', [albumid])
downloaded_track_list = []
try:
albumpath = str(albumpath)
except UnicodeEncodeError:
albumpath = unicode(albumpath).encode('unicode_escape')
for r,d,f in os.walk(albumpath):
for files in f:
if any(files.endswith('.' + x) for x in headphones.MEDIA_FORMATS):

View File

@@ -74,17 +74,22 @@ def searchNZB(albumid=None, new=False):
dic = {'...':'', ' & ':' ', ' = ': ' ', '?':'', '$':'s', ' + ':' ', '"':'', ',':''}
cleanartistalbum = helpers.latinToAscii(helpers.replace_all(albums[0]+' '+albums[1], dic))
cleanalbum = helpers.latinToAscii(helpers.replace_all(albums[1], dic))
cleanartist = helpers.latinToAscii(helpers.replace_all(albums[0], dic))
# FLAC usually doesn't have a year for some reason so I'll leave it out:
term = re.sub('[\.\-\/]', ' ', '%s' % (cleanartistalbum)).encode('utf-8')
altterm = re.sub('[\.\-\/]', ' ', '%s %s' % (cleanartistalbum, year)).encode('utf-8')
artistterm = re.sub('[\.\-\/]', ' ', '%s' % (cleanartist)).encode('utf-8')
# FLAC usually doesn't have a year for some reason so I'll leave it out
# Various Artist albums might be listed as VA, so I'll leave that out too
# Only use the year if the term could return a bunch of different albums, i.e. self-titled albums
if albums[0] in albums[1] or len(albums[0]) < 4 or len(albums[1]) < 4:
term = altterm
term = cleanartist + ' ' + cleanalbum + ' ' + year
elif albums[0] == 'Various Artists':
term = cleanalbum + ' ' + year
else:
term = cleanartist + ' ' + cleanalbum
# Replace bad characters in the term and unicode it
term = re.sub('[\.\-\/]', ' ', term).encode('utf-8')
artistterm = re.sub('[\.\-\/]', ' ', cleanartist).encode('utf-8')
logger.info("Searching for %s since it was marked as wanted" % term)
@@ -459,6 +464,12 @@ def getresultNZB(result):
return nzb
def preprocess(resultlist):
if not headphones.USENET_RETENTION:
usenet_retention = 1000
else:
usenet_retention = int(headphones.USENET_RETENTION)
for result in resultlist:
nzb = getresultNZB(result)
if nzb:
@@ -467,7 +478,7 @@ def preprocess(resultlist):
node = d.documentElement
nzbfiles = d.getElementsByTagName("file")
for nzbfile in nzbfiles:
if nzbfile.getAttribute("date") < (time.time() - int(headphones.USENET_RETENTION) * 86400):
if nzbfile.getAttribute("date") < (time.time() - usenet_retention * 86400):
logger.error('NZB contains a file out of your retention. Skipping.')
continue
#TODO: Do we want rar checking in here to try to keep unknowns out?

View File

@@ -22,6 +22,10 @@ def initialize(options={}):
'/': {
'tools.staticdir.root': os.path.join(headphones.PROG_DIR, 'data')
},
'/interfaces':{
'tools.staticdir.on': True,
'tools.staticdir.dir': "interfaces"
},
'/images':{
'tools.staticdir.on': True,
'tools.staticdir.dir': "images"