1
0
mirror of https://github.com/moparisthebest/SickRage synced 2025-01-05 19:08:02 -05:00

Last set of fixes to correct this problem

This commit is contained in:
echel0n 2014-05-03 02:58:04 -07:00
parent ac65eab3c0
commit 33be93288a
2 changed files with 50 additions and 15 deletions

View File

@ -55,6 +55,9 @@ def get_scene_numbering(indexer_id, indexer, season, episode, fallback_to_xem=Tr
if indexer_id is None or season is None or episode is None: if indexer_id is None or season is None or episode is None:
return (season, episode) return (season, episode)
indexer_id = int(indexer_id)
indexer = int(indexer)
result = find_scene_numbering(indexer_id, indexer, season, episode) result = find_scene_numbering(indexer_id, indexer, season, episode)
if result: if result:
return result return result
@ -73,6 +76,9 @@ def find_scene_numbering(indexer_id, indexer, season, episode):
if indexer_id is None or season is None or episode is None: if indexer_id is None or season is None or episode is None:
return (season, episode) return (season, episode)
indexer_id = int(indexer_id)
indexer = int(indexer)
myDB = db.DBConnection() myDB = db.DBConnection()
rows = myDB.select( rows = myDB.select(
@ -90,6 +96,9 @@ def get_indexer_numbering(indexer_id, indexer, sceneSeason, sceneEpisode, fallba
if indexer_id is None or sceneSeason is None or sceneEpisode is None: if indexer_id is None or sceneSeason is None or sceneEpisode is None:
return (sceneSeason, sceneEpisode) return (sceneSeason, sceneEpisode)
indexer_id = int(indexer_id)
indexer = int(indexer)
myDB = db.DBConnection() myDB = db.DBConnection()
rows = myDB.select( rows = myDB.select(
@ -112,6 +121,9 @@ def get_scene_numbering_for_show(indexer_id, indexer):
if indexer_id is None: if indexer_id is None:
return {} return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
myDB = db.DBConnection() myDB = db.DBConnection()
rows = myDB.select( rows = myDB.select(
@ -133,6 +145,9 @@ def set_scene_numbering(indexer_id, indexer, season, episode, sceneSeason=None,
if indexer_id is None or season is None or episode is None: if indexer_id is None or season is None or episode is None:
return return
indexer_id = int(indexer_id)
indexer = int(indexer)
myDB = db.DBConnection() myDB = db.DBConnection()
# sanity # sanity
@ -163,6 +178,9 @@ def find_xem_numbering(indexer_id, indexer, season, episode):
if indexer_id is None or season is None or episode is None: if indexer_id is None or season is None or episode is None:
return None return None
indexer_id = int(indexer_id)
indexer = int(indexer)
if _xem_refresh_needed(indexer_id, indexer): if _xem_refresh_needed(indexer_id, indexer):
_xem_refresh(indexer_id, indexer) _xem_refresh(indexer_id, indexer)
@ -188,6 +206,9 @@ def get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode
if indexer_id is None or sceneSeason is None or sceneEpisode is None: if indexer_id is None or sceneSeason is None or sceneEpisode is None:
return None return None
indexer_id = int(indexer_id)
indexer = int(indexer)
if _xem_refresh_needed(indexer_id, indexer): if _xem_refresh_needed(indexer_id, indexer):
_xem_refresh(indexer_id, indexer) _xem_refresh(indexer_id, indexer)
cacheDB = db.DBConnection('cache.db') cacheDB = db.DBConnection('cache.db')
@ -210,6 +231,9 @@ def _xem_refresh_needed(indexer_id, indexer):
if indexer_id is None: if indexer_id is None:
return False return False
indexer_id = int(indexer_id)
indexer = int(indexer)
cacheDB = db.DBConnection('cache.db') cacheDB = db.DBConnection('cache.db')
rows = cacheDB.select("SELECT last_refreshed FROM xem_refresh WHERE indexer = ? and indexer_id = ?", rows = cacheDB.select("SELECT last_refreshed FROM xem_refresh WHERE indexer = ? and indexer_id = ?",
[indexer, indexer_id]) [indexer, indexer_id])
@ -228,18 +252,21 @@ def _xem_refresh(indexer_id, indexer):
if indexer_id is None: if indexer_id is None:
return return
indexer_id = int(indexer_id)
indexer = int(indexer)
try: try:
logger.log( logger.log(
u'Looking up XEM scene mapping for show %s on %s' % (indexer_id, sickbeard.indexerApi(int(indexer)).name,), u'Looking up XEM scene mapping for show %s on %s' % (indexer_id, sickbeard.indexerApi(indexer).name,),
logger.DEBUG) logger.DEBUG)
data = requests.get("http://thexem.de/map/all?id=%s&origin=%s&destination=scene" % ( data = requests.get("http://thexem.de/map/all?id=%s&origin=%s&destination=scene" % (
indexer_id, sickbeard.indexerApi(int(indexer)).config['xem_origin'],), verify=False).json() indexer_id, sickbeard.indexerApi(indexer).config['xem_origin'],), verify=False).json()
if data is None or data == '': if data is None or data == '':
logger.log(u'No XEN data for show "%s on %s", trying TVTumbler' % ( logger.log(u'No XEN data for show "%s on %s", trying TVTumbler' % (
indexer_id, sickbeard.indexerApi(int(indexer)).name,), logger.MESSAGE) indexer_id, sickbeard.indexerApi(indexer).name,), logger.MESSAGE)
data = requests.get("http://show-api.tvtumbler.com/api/thexem/all?id=%s&origin=%s&destination=scene" % ( data = requests.get("http://show-api.tvtumbler.com/api/thexem/all?id=%s&origin=%s&destination=scene" % (
indexer_id, sickbeard.indexerApi(int(indexer)).config['xem_origin'],), verify=False).json() indexer_id, sickbeard.indexerApi(indexer).config['xem_origin'],), verify=False).json()
if data is None or data == '': if data is None or data == '':
logger.log(u'TVTumbler also failed for show "%s on %s". giving up.' % (indexer_id, indexer,), logger.log(u'TVTumbler also failed for show "%s on %s". giving up.' % (indexer_id, indexer,),
logger.MESSAGE) logger.MESSAGE)
@ -257,23 +284,23 @@ def _xem_refresh(indexer_id, indexer):
cacheDB.action( cacheDB.action(
"INSERT INTO xem_numbering (indexer, indexer_id, season, episode, scene_season, scene_episode) VALUES (?,?,?,?,?,?)", "INSERT INTO xem_numbering (indexer, indexer_id, season, episode, scene_season, scene_episode) VALUES (?,?,?,?,?,?)",
[indexer, indexer_id, entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'], [indexer, indexer_id, entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'],
entry[sickbeard.indexerApi(int(indexer)).config['xem_origin']]['episode'], entry[sickbeard.indexerApi(indexer).config['xem_origin']]['episode'],
entry['scene']['season'], entry['scene']['episode']]) entry['scene']['season'], entry['scene']['episode']])
if 'scene_2' in entry: # for doubles if 'scene_2' in entry: # for doubles
cacheDB.action( cacheDB.action(
"INSERT INTO xem_numbering (indexer, indexer_id, season, episode, scene_season, scene_episode) VALUES (?,?,?,?,?,?)", "INSERT INTO xem_numbering (indexer, indexer_id, season, episode, scene_season, scene_episode) VALUES (?,?,?,?,?,?)",
[indexer, indexer_id, entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'], [indexer, indexer_id, entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'],
entry[sickbeard.indexerApi(int(indexer)).config['xem_origin']]['episode'], entry[sickbeard.indexerApi(indexer).config['xem_origin']]['episode'],
entry['scene_2']['season'], entry['scene_2']['episode']]) entry['scene_2']['season'], entry['scene_2']['episode']])
else: else:
logger.log(u'Failed to get XEM scene data for show %s from %s because "%s"' % ( logger.log(u'Failed to get XEM scene data for show %s from %s because "%s"' % (
indexer_id, sickbeard.indexerApi(int(indexer)).name, result['message']), logger.DEBUG) indexer_id, sickbeard.indexerApi(indexer).name, result['message']), logger.DEBUG)
else: else:
logger.log(u"Empty lookup result - no XEM data for show %s on %s" % ( logger.log(u"Empty lookup result - no XEM data for show %s on %s" % (
indexer_id, sickbeard.indexerApi(int(indexer)).name,), logger.DEBUG) indexer_id, sickbeard.indexerApi(indexer).name,), logger.DEBUG)
except Exception, e: except Exception, e:
logger.log(u"Exception while refreshing XEM data for show " + str(indexer_id) + " on " + sickbeard.indexerApi( logger.log(u"Exception while refreshing XEM data for show " + str(indexer_id) + " on " + sickbeard.indexerApi(
int(indexer)).name + ": " + ex(e), logger.WARNING) indexer).name + ": " + ex(e), logger.WARNING)
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
return None return None
@ -287,6 +314,9 @@ def get_xem_numbering_for_show(indexer_id, indexer):
if indexer_id is None: if indexer_id is None:
return {} return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
if _xem_refresh_needed(indexer_id, indexer): if _xem_refresh_needed(indexer_id, indexer):
_xem_refresh(indexer_id, indexer) _xem_refresh(indexer_id, indexer)
@ -312,6 +342,9 @@ def get_xem_numbering_for_season(indexer_id, indexer, season):
if indexer_id is None or season is None: if indexer_id is None or season is None:
return {} return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
if _xem_refresh_needed(indexer_id, indexer): if _xem_refresh_needed(indexer_id, indexer):
_xem_refresh(indexer_id, indexer) _xem_refresh(indexer_id, indexer)

View File

@ -2831,10 +2831,11 @@ class Home:
t.epCounts = epCounts t.epCounts = epCounts
t.epCats = epCats t.epCats = epCats
#t.all_scene_exceptions = list(set((get_scene_exceptions(showObj.indexerid) or []) + (get_custom_exceptions(showObj.indexerid) or []))) indexerid = int(showObj.indexerid)
t.all_scene_exceptions = get_scene_exceptions(showObj.indexerid) indexer = int(showObj.indexer)
t.scene_numbering = get_scene_numbering_for_show(showObj.indexerid, int(showObj.indexer)) t.all_scene_exceptions = get_scene_exceptions(indexerid)
t.xem_numbering = get_xem_numbering_for_show(showObj.indexerid, int(showObj.indexer)) t.scene_numbering = get_scene_numbering_for_show(indexerid, indexer)
t.xem_numbering = get_xem_numbering_for_show(indexerid, indexer)
return _munge(t) return _munge(t)
@ -3397,14 +3398,15 @@ class Home:
(show, forSeason, forEpisode, sceneSeason, sceneEpisode), logger.DEBUG) (show, forSeason, forEpisode, sceneSeason, sceneEpisode), logger.DEBUG)
show = int(show) show = int(show)
indexer = int(ep_obj.indexer)
forSeason = int(forSeason) forSeason = int(forSeason)
forEpisode = int(forEpisode) forEpisode = int(forEpisode)
if sceneSeason is not None: sceneSeason = int(sceneSeason) if sceneSeason is not None: sceneSeason = int(sceneSeason)
if sceneEpisode is not None: sceneEpisode = int(sceneEpisode) if sceneEpisode is not None: sceneEpisode = int(sceneEpisode)
set_scene_numbering(show, forSeason, forEpisode, sceneSeason, sceneEpisode) set_scene_numbering(show, forSeason, forEpisode, sceneSeason, sceneEpisode)
sn = get_scene_numbering(show, int(ep_obj.indexer), forSeason, forEpisode) sn = get_scene_numbering(show, indexer, forSeason, forEpisode)
if sn: if sn:
(result['sceneSeason'], result['sceneEpisode']) = sn (result['sceneSeason'], result['sceneEpisode']) = sn
else: else: