1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Fixed sickrage/sickrage-issues#105 - old code that needed updating that was causing unicode issues.

This commit is contained in:
echel0n 2014-12-15 14:28:22 -08:00
parent b255f5d0f8
commit f713567d60

View File

@ -79,6 +79,7 @@ from concurrent.futures import ThreadPoolExecutor
route_locks = {} route_locks = {}
class html_entities(CheetahFilter): class html_entities(CheetahFilter):
def filter(self, val, **dummy_kw): def filter(self, val, **dummy_kw):
if isinstance(val, unicode): if isinstance(val, unicode):
@ -92,6 +93,7 @@ class html_entities(CheetahFilter):
return filtered return filtered
class PageTemplate(CheetahTemplate): class PageTemplate(CheetahTemplate):
def __init__(self, rh, *args, **kwargs): def __init__(self, rh, *args, **kwargs):
kwargs['file'] = os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME + "/interfaces/default/", kwargs['file']) kwargs['file'] = os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME + "/interfaces/default/", kwargs['file'])
@ -141,6 +143,7 @@ class PageTemplate(CheetahTemplate):
kwargs['cacheDirForModuleFiles'] = os.path.join(sickbeard.CACHE_DIR, 'cheetah') kwargs['cacheDirForModuleFiles'] = os.path.join(sickbeard.CACHE_DIR, 'cheetah')
return super(PageTemplate, self).compile(*args, **kwargs) return super(PageTemplate, self).compile(*args, **kwargs)
class BaseHandler(RequestHandler): class BaseHandler(RequestHandler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(BaseHandler, self).__init__(*args, **kwargs) super(BaseHandler, self).__init__(*args, **kwargs)
@ -243,6 +246,7 @@ class WebHandler(BaseHandler):
# post uses get method # post uses get method
post = get post = get
class LoginHandler(BaseHandler): class LoginHandler(BaseHandler):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(LoginHandler, self).__init__(*args, **kwargs) super(LoginHandler, self).__init__(*args, **kwargs)
@ -252,7 +256,7 @@ class LoginHandler(BaseHandler):
self.redirect('/home/') self.redirect('/home/')
else: else:
t = PageTemplate(rh=self, file="login.tmpl") t = PageTemplate(rh=self, file="login.tmpl")
self.finish(ek.ss(t)) self.finish(t.respond())
def post(self, *args, **kwargs): def post(self, *args, **kwargs):
@ -261,8 +265,8 @@ class LoginHandler(BaseHandler):
username = sickbeard.WEB_USERNAME username = sickbeard.WEB_USERNAME
password = sickbeard.WEB_PASSWORD password = sickbeard.WEB_PASSWORD
if (self.get_argument('username') == username or not username) and ( if (self.get_argument('username') == username or not username) \
self.get_argument('password') == password or not password): and (self.get_argument('password') == password or not password):
api_key = sickbeard.API_KEY api_key = sickbeard.API_KEY
if api_key: if api_key:
@ -292,14 +296,11 @@ class KeyHandler(BaseHandler):
username = sickbeard.WEB_USERNAME username = sickbeard.WEB_USERNAME
password = sickbeard.WEB_PASSWORD password = sickbeard.WEB_PASSWORD
if (self.get_argument('u', None) == username or not username) \ if (self.get_argument('u', None) == username or not username) and \
and (self.get_argument('p', None) == password or not password): (self.get_argument('p', None) == password or not password):
api_key = sickbeard.API_KEY api_key = sickbeard.API_KEY
self.finish({ self.finish({'success': api_key is not None, 'api_key': api_key})
'success': api_key is not None,
'api_key': api_key
})
except: except:
logger.log('Failed doing key request: %s' % (traceback.format_exc()), logger.ERROR) logger.log('Failed doing key request: %s' % (traceback.format_exc()), logger.ERROR)
self.finish({'success': False, 'error': 'Failed returning results'}) self.finish({'success': False, 'error': 'Failed returning results'})
@ -457,14 +458,14 @@ class WebRoot(WebHandler):
myDB = db.DBConnection() myDB = db.DBConnection()
sql_results = myDB.select( sql_results = myDB.select(
"SELECT *, tv_shows.status as show_status FROM tv_episodes, tv_shows WHERE season != 0 AND airdate >= ? AND airdate < ? AND tv_shows.indexer_id = tv_episodes.showid AND tv_episodes.status NOT IN (" + ','.join( "SELECT *, tv_shows.status AS show_status FROM tv_episodes, tv_shows WHERE season != 0 AND airdate >= ? AND airdate < ? AND tv_shows.indexer_id = tv_episodes.showid AND tv_episodes.status NOT IN (" + ','.join(
['?'] * len(qualList)) + ")", [today, next_week] + qualList) ['?'] * len(qualList)) + ")", [today, next_week] + qualList)
for cur_result in sql_results: for cur_result in sql_results:
done_show_list.append(int(cur_result["showid"])) done_show_list.append(int(cur_result["showid"]))
more_sql_results = myDB.select( more_sql_results = myDB.select(
"SELECT *, tv_shows.status as show_status FROM tv_episodes outer_eps, tv_shows WHERE season != 0 AND showid NOT IN (" + ','.join( "SELECT *, tv_shows.status AS show_status FROM tv_episodes outer_eps, tv_shows WHERE season != 0 AND showid NOT IN (" + ','.join(
['?'] * len( ['?'] * len(
done_show_list)) + ") AND tv_shows.indexer_id = outer_eps.showid AND airdate = (SELECT airdate FROM tv_episodes inner_eps WHERE inner_eps.season != 0 AND inner_eps.showid = outer_eps.showid AND inner_eps.airdate >= ? ORDER BY inner_eps.airdate ASC LIMIT 1) AND outer_eps.status NOT IN (" + ','.join( done_show_list)) + ") AND tv_shows.indexer_id = outer_eps.showid AND airdate = (SELECT airdate FROM tv_episodes inner_eps WHERE inner_eps.season != 0 AND inner_eps.showid = outer_eps.showid AND inner_eps.airdate >= ? ORDER BY inner_eps.airdate ASC LIMIT 1) AND outer_eps.status NOT IN (" + ','.join(
['?'] * len(Quality.DOWNLOADED + Quality.SNATCHED)) + ")", ['?'] * len(Quality.DOWNLOADED + Quality.SNATCHED)) + ")",
@ -472,7 +473,7 @@ class WebRoot(WebHandler):
sql_results += more_sql_results sql_results += more_sql_results
more_sql_results = myDB.select( more_sql_results = myDB.select(
"SELECT *, tv_shows.status as show_status FROM tv_episodes, tv_shows WHERE season != 0 AND tv_shows.indexer_id = tv_episodes.showid AND airdate < ? AND airdate >= ? AND tv_episodes.status = ? AND tv_episodes.status NOT IN (" + ','.join( "SELECT *, tv_shows.status AS show_status FROM tv_episodes, tv_shows WHERE season != 0 AND tv_shows.indexer_id = tv_episodes.showid AND airdate < ? AND airdate >= ? AND tv_episodes.status = ? AND tv_episodes.status NOT IN (" + ','.join(
['?'] * len(qualList)) + ")", [today, recently, WANTED] + qualList) ['?'] * len(qualList)) + ")", [today, recently, WANTED] + qualList)
sql_results += more_sql_results sql_results += more_sql_results
@ -592,6 +593,7 @@ class WebRoot(WebHandler):
return ical return ical
@route('/ui(/?.*)') @route('/ui(/?.*)')
class UI(WebRoot): class UI(WebRoot):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -1056,7 +1058,7 @@ class Home(WebRoot):
myDB = db.DBConnection() myDB = db.DBConnection()
seasonResults = myDB.select( seasonResults = myDB.select(
"SELECT DISTINCT season FROM tv_episodes WHERE showid = ? ORDER BY season desc", "SELECT DISTINCT season FROM tv_episodes WHERE showid = ? ORDER BY season DESC",
[showObj.indexerid] [showObj.indexerid]
) )
@ -2580,7 +2582,7 @@ class Manage(Home, WebRoot):
myDB = db.DBConnection() myDB = db.DBConnection()
status_results = myDB.select( status_results = myDB.select(
"SELECT show_name, tv_shows.indexer_id as indexer_id FROM tv_episodes, tv_shows WHERE tv_episodes.status IN (" + ','.join( "SELECT show_name, tv_shows.indexer_id AS indexer_id FROM tv_episodes, tv_shows WHERE tv_episodes.status IN (" + ','.join(
['?'] * len( ['?'] * len(
status_list)) + ") AND season != 0 AND tv_episodes.showid = tv_shows.indexer_id ORDER BY show_name", status_list)) + ") AND season != 0 AND tv_episodes.showid = tv_shows.indexer_id ORDER BY show_name",
status_list) status_list)
@ -3191,7 +3193,7 @@ class Manage(Home, WebRoot):
toRemove = toRemove.split("|") if toRemove is not None else [] toRemove = toRemove.split("|") if toRemove is not None else []
for release in toRemove: for release in toRemove:
myDB.action("DELETE FROM failed WHERE release = ?", [release]) myDB.action("DELETE FROM failed WHERE failed.release = ?", [release])
if toRemove: if toRemove:
return self.redirect('/manage/failedDownloads/') return self.redirect('/manage/failedDownloads/')