Merge pull request #585 from adam111316/feature/ChangeGeneraliseXem

Change to generalize xem id fetching
This commit is contained in:
adam111316 2015-12-10 20:18:15 +08:00
commit 36be843428
6 changed files with 27 additions and 27 deletions

View file

@ -1,6 +1,6 @@
### 0.12.0 (2015-xx-xx xx:xx:xx UTC)
*
* Change to generalize xem id fetching
### 0.11.0 (2015-xx-xx xx:xx:xx UTC)

View file

@ -63,3 +63,7 @@ class indexerApi(object):
@property
def indexers(self):
return dict((int(x['id']), x['name']) for x in indexerConfig.values())
def get_xem_supported_indexers():
return dict((key, value) for (key, value) in indexerConfig.items() if value['xem_origin'])

View file

@ -29,12 +29,12 @@ from sickbeard import name_cache
from sickbeard import logger
from sickbeard import db
from sickbeard.classes import OrderedDefaultdict
from sickbeard.indexers.indexer_api import get_xem_supported_indexers
exception_dict = {}
anidb_exception_dict = {}
xem_exception_dict = {}
xem_tvdb_ids_list = []
xem_rage_ids_list = []
xem_ids_list = defaultdict(list)
exceptionsCache = {}
exceptionsSeasonCache = {}
@ -346,12 +346,9 @@ def _xem_get_ids(indexer_name, xem_origin):
def get_xem_ids():
global xem_tvdb_ids_list
global xem_rage_ids_list
global xem_ids_list
xem_ids = _xem_get_ids('TheTVDB', 'tvdb')
for indexer in get_xem_supported_indexers().values():
xem_ids = _xem_get_ids(indexer['name'], indexer['xem_origin'])
if len(xem_ids):
xem_tvdb_ids_list = xem_ids
xem_ids = _xem_get_ids('TVRage', 'rage')
if len(xem_ids):
xem_rage_ids_list = xem_ids
xem_ids_list[indexer['id']] = xem_ids

View file

@ -30,7 +30,7 @@ import sickbeard
from sickbeard import logger
from sickbeard import db
from sickbeard.exceptions import ex
from sickbeard.indexers.indexer_config import INDEXER_TVDB
from sickbeard.scene_exceptions import xem_ids_list
def get_scene_numbering(indexer_id, indexer, season, episode, fallback_to_xem=True):
@ -461,7 +461,7 @@ def xem_refresh(indexer_id, indexer, force=False):
indexer_id = int(indexer_id)
indexer = int(indexer)
if not (indexer_id in sickbeard.scene_exceptions.xem_tvdb_ids_list if INDEXER_TVDB == indexer else sickbeard.scene_exceptions.xem_rage_ids_list):
if indexer_id not in xem_ids_list[indexer]:
return
# XEM API URL

View file

@ -29,7 +29,6 @@ from sickbeard import generic_queue
from sickbeard import name_cache
from sickbeard.exceptions import ex
from sickbeard.blackandwhitelist import BlackAndWhiteList
from sickbeard.indexers.indexer_config import INDEXER_TVDB
class ShowQueue(generic_queue.GenericQueue):
@ -471,8 +470,7 @@ class QueueItemAdd(ShowQueueItem):
# Load XEM data to DB for show
sickbeard.scene_numbering.xem_refresh(self.show.indexerid, self.show.indexer, force=True)
# check if show has XEM mapping and if user disabled scene numbering during add show, output availability to log
if not self.scene and self.show.indexerid in sickbeard.scene_exceptions.xem_tvdb_ids_list\
+ sickbeard.scene_exceptions.xem_rage_ids_list:
if not self.scene and self.show.indexerid in sickbeard.scene_exceptions.xem_ids_list[self.show.indexer]:
logger.log(u'Alternative scene episode numbers were disabled during add show. Edit show to enable them for searching.')
# update internal name cache
@ -509,7 +507,7 @@ class QueueItemRefresh(ShowQueueItem):
self.show.populateCache()
# Load XEM data to DB for show
if self.show.indexerid in sickbeard.scene_exceptions.xem_tvdb_ids_list if INDEXER_TVDB == self.show.indexer else sickbeard.scene_exceptions.xem_rage_ids_list:
if self.show.indexerid in sickbeard.scene_exceptions.xem_ids_list[self.show.indexer]:
sickbeard.scene_numbering.xem_refresh(self.show.indexerid, self.show.indexer)
self.inProgress = False

View file

@ -26,6 +26,7 @@ import datetime
import dateutil.parser
import random
import traceback
import itertools
from mimetypes import MimeTypes
from Cheetah.Template import Template
@ -1276,7 +1277,7 @@ class Home(MainHandler):
with showObj.lock:
t.show = showObj
t.show_has_scene_map = showObj.indexerid in sickbeard.scene_exceptions.xem_tvdb_ids_list + sickbeard.scene_exceptions.xem_rage_ids_list
t.show_has_scene_map = showObj.indexerid in sickbeard.scene_exceptions.xem_ids_list[showObj.indexer]
return t.respond()
@ -2281,7 +2282,7 @@ class NewHomeAddShows(Home):
t.blacklist = []
t.groups = []
t.show_scene_maps = sickbeard.scene_exceptions.xem_tvdb_ids_list + sickbeard.scene_exceptions.xem_rage_ids_list
t.show_scene_maps = list(itertools.chain(*sickbeard.scene_exceptions.xem_ids_list.values()))
return t.respond()