mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-07 10:33:38 +00:00
Merge pull request #585 from adam111316/feature/ChangeGeneraliseXem
Change to generalize xem id fetching
This commit is contained in:
commit
36be843428
6 changed files with 27 additions and 27 deletions
|
@ -1,6 +1,6 @@
|
||||||
### 0.12.0 (2015-xx-xx xx:xx:xx UTC)
|
### 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)
|
### 0.11.0 (2015-xx-xx xx:xx:xx UTC)
|
||||||
|
|
|
@ -63,3 +63,7 @@ class indexerApi(object):
|
||||||
@property
|
@property
|
||||||
def indexers(self):
|
def indexers(self):
|
||||||
return dict((int(x['id']), x['name']) for x in indexerConfig.values())
|
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'])
|
||||||
|
|
|
@ -29,12 +29,12 @@ from sickbeard import name_cache
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
from sickbeard import db
|
from sickbeard import db
|
||||||
from sickbeard.classes import OrderedDefaultdict
|
from sickbeard.classes import OrderedDefaultdict
|
||||||
|
from sickbeard.indexers.indexer_api import get_xem_supported_indexers
|
||||||
|
|
||||||
exception_dict = {}
|
exception_dict = {}
|
||||||
anidb_exception_dict = {}
|
anidb_exception_dict = {}
|
||||||
xem_exception_dict = {}
|
xem_exception_dict = {}
|
||||||
xem_tvdb_ids_list = []
|
xem_ids_list = defaultdict(list)
|
||||||
xem_rage_ids_list = []
|
|
||||||
|
|
||||||
exceptionsCache = {}
|
exceptionsCache = {}
|
||||||
exceptionsSeasonCache = {}
|
exceptionsSeasonCache = {}
|
||||||
|
@ -346,12 +346,9 @@ def _xem_get_ids(indexer_name, xem_origin):
|
||||||
|
|
||||||
|
|
||||||
def get_xem_ids():
|
def get_xem_ids():
|
||||||
global xem_tvdb_ids_list
|
global xem_ids_list
|
||||||
global xem_rage_ids_list
|
|
||||||
|
|
||||||
xem_ids = _xem_get_ids('TheTVDB', 'tvdb')
|
for indexer in get_xem_supported_indexers().values():
|
||||||
if len(xem_ids):
|
xem_ids = _xem_get_ids(indexer['name'], indexer['xem_origin'])
|
||||||
xem_tvdb_ids_list = xem_ids
|
if len(xem_ids):
|
||||||
xem_ids = _xem_get_ids('TVRage', 'rage')
|
xem_ids_list[indexer['id']] = xem_ids
|
||||||
if len(xem_ids):
|
|
||||||
xem_rage_ids_list = xem_ids
|
|
||||||
|
|
|
@ -30,21 +30,21 @@ import sickbeard
|
||||||
from sickbeard import logger
|
from sickbeard import logger
|
||||||
from sickbeard import db
|
from sickbeard import db
|
||||||
from sickbeard.exceptions import ex
|
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):
|
def get_scene_numbering(indexer_id, indexer, season, episode, fallback_to_xem=True):
|
||||||
"""
|
"""
|
||||||
Returns a tuple, (season, episode), with the scene numbering (if there is one),
|
Returns a tuple, (season, episode), with the scene numbering (if there is one),
|
||||||
otherwise returns the xem numbering (if fallback_to_xem is set), otherwise
|
otherwise returns the xem numbering (if fallback_to_xem is set), otherwise
|
||||||
returns the TVDB and TVRAGE numbering.
|
returns the TVDB and TVRAGE numbering.
|
||||||
(so the return values will always be set)
|
(so the return values will always be set)
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
@param season: int
|
@param season: int
|
||||||
@param episode: int
|
@param episode: int
|
||||||
@param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering
|
@param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering
|
||||||
@return: (int, int) a tuple with (season, episode)
|
@return: (int, int) a tuple with (season, episode)
|
||||||
"""
|
"""
|
||||||
if None is indexer_id or None is season or None is episode:
|
if None is indexer_id or None is season or None is episode:
|
||||||
return season, episode
|
return season, episode
|
||||||
|
@ -193,7 +193,7 @@ def set_scene_numbering(indexer_id, indexer, season=None, episode=None, absolute
|
||||||
"""
|
"""
|
||||||
Set scene numbering for a season/episode.
|
Set scene numbering for a season/episode.
|
||||||
To clear the scene numbering, leave both sceneSeason and sceneEpisode as None.
|
To clear the scene numbering, leave both sceneSeason and sceneEpisode as None.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if None is indexer_id:
|
if None is indexer_id:
|
||||||
return
|
return
|
||||||
|
@ -224,7 +224,7 @@ def find_xem_numbering(indexer_id, indexer, season, episode):
|
||||||
"""
|
"""
|
||||||
Returns the scene numbering, as retrieved from xem.
|
Returns the scene numbering, as retrieved from xem.
|
||||||
Refreshes/Loads as needed.
|
Refreshes/Loads as needed.
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
@param season: int
|
@param season: int
|
||||||
@param episode: int
|
@param episode: int
|
||||||
|
@ -276,11 +276,11 @@ def find_xem_absolute_numbering(indexer_id, indexer, absolute_number):
|
||||||
def get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode):
|
def get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode):
|
||||||
"""
|
"""
|
||||||
Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering
|
Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
@param sceneSeason: int
|
@param sceneSeason: int
|
||||||
@param sceneEpisode: int
|
@param sceneEpisode: int
|
||||||
@return: (int, int) a tuple of (season, episode)
|
@return: (int, int) a tuple of (season, episode)
|
||||||
"""
|
"""
|
||||||
if None is indexer_id or None is sceneSeason or None is sceneEpisode:
|
if None is indexer_id or None is sceneSeason or None is sceneEpisode:
|
||||||
return sceneSeason, sceneEpisode
|
return sceneSeason, sceneEpisode
|
||||||
|
@ -452,7 +452,7 @@ def get_xem_absolute_numbering_for_show(indexer_id, indexer):
|
||||||
def xem_refresh(indexer_id, indexer, force=False):
|
def xem_refresh(indexer_id, indexer, force=False):
|
||||||
"""
|
"""
|
||||||
Refresh data from xem for a tv show
|
Refresh data from xem for a tv show
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
"""
|
"""
|
||||||
if None is indexer_id:
|
if None is indexer_id:
|
||||||
|
@ -461,7 +461,7 @@ def xem_refresh(indexer_id, indexer, force=False):
|
||||||
indexer_id = int(indexer_id)
|
indexer_id = int(indexer_id)
|
||||||
indexer = int(indexer)
|
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
|
return
|
||||||
|
|
||||||
# XEM API URL
|
# XEM API URL
|
||||||
|
|
|
@ -29,7 +29,6 @@ from sickbeard import generic_queue
|
||||||
from sickbeard import name_cache
|
from sickbeard import name_cache
|
||||||
from sickbeard.exceptions import ex
|
from sickbeard.exceptions import ex
|
||||||
from sickbeard.blackandwhitelist import BlackAndWhiteList
|
from sickbeard.blackandwhitelist import BlackAndWhiteList
|
||||||
from sickbeard.indexers.indexer_config import INDEXER_TVDB
|
|
||||||
|
|
||||||
|
|
||||||
class ShowQueue(generic_queue.GenericQueue):
|
class ShowQueue(generic_queue.GenericQueue):
|
||||||
|
@ -471,8 +470,7 @@ class QueueItemAdd(ShowQueueItem):
|
||||||
# Load XEM data to DB for show
|
# Load XEM data to DB for show
|
||||||
sickbeard.scene_numbering.xem_refresh(self.show.indexerid, self.show.indexer, force=True)
|
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
|
# 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\
|
if not self.scene and self.show.indexerid in sickbeard.scene_exceptions.xem_ids_list[self.show.indexer]:
|
||||||
+ sickbeard.scene_exceptions.xem_rage_ids_list:
|
|
||||||
logger.log(u'Alternative scene episode numbers were disabled during add show. Edit show to enable them for searching.')
|
logger.log(u'Alternative scene episode numbers were disabled during add show. Edit show to enable them for searching.')
|
||||||
|
|
||||||
# update internal name cache
|
# update internal name cache
|
||||||
|
@ -509,7 +507,7 @@ class QueueItemRefresh(ShowQueueItem):
|
||||||
self.show.populateCache()
|
self.show.populateCache()
|
||||||
|
|
||||||
# Load XEM data to DB for show
|
# 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)
|
sickbeard.scene_numbering.xem_refresh(self.show.indexerid, self.show.indexer)
|
||||||
|
|
||||||
self.inProgress = False
|
self.inProgress = False
|
||||||
|
|
|
@ -26,6 +26,7 @@ import datetime
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import random
|
import random
|
||||||
import traceback
|
import traceback
|
||||||
|
import itertools
|
||||||
|
|
||||||
from mimetypes import MimeTypes
|
from mimetypes import MimeTypes
|
||||||
from Cheetah.Template import Template
|
from Cheetah.Template import Template
|
||||||
|
@ -1276,7 +1277,7 @@ class Home(MainHandler):
|
||||||
|
|
||||||
with showObj.lock:
|
with showObj.lock:
|
||||||
t.show = showObj
|
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()
|
return t.respond()
|
||||||
|
|
||||||
|
@ -2281,7 +2282,7 @@ class NewHomeAddShows(Home):
|
||||||
t.blacklist = []
|
t.blacklist = []
|
||||||
t.groups = []
|
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()
|
return t.respond()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue