1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-17 06:45:05 -05:00

Merge pull request #625 from adam111316/anime

Add support for animes with a different series name per tvdb season
This commit is contained in:
echel0n 2014-07-06 03:24:54 -07:00
commit 9428dfadf6
2 changed files with 22 additions and 11 deletions

View File

@ -23,7 +23,7 @@ import threading
import regexes import regexes
import sickbeard import sickbeard
from sickbeard import logger, helpers, scene_numbering, common, exceptions from sickbeard import logger, helpers, scene_numbering, common, exceptions, scene_exceptions
from dateutil import parser from dateutil import parser
nameparser_lock = threading.Lock() nameparser_lock = threading.Lock()
@ -521,8 +521,9 @@ class ParseResult(object):
new_absolute_numbers = [] new_absolute_numbers = []
if self.show.is_anime and len(self.ab_episode_numbers): if self.show.is_anime and len(self.ab_episode_numbers):
scene_season = scene_exceptions.get_scene_exception_by_name(self.series_name)[1]
for epAbsNo in self.ab_episode_numbers: for epAbsNo in self.ab_episode_numbers:
ab = scene_numbering.get_indexer_absolute_numbering(self.show.indexerid, self.show.indexer, epAbsNo) ab = scene_numbering.get_indexer_absolute_numbering(self.show.indexerid, self.show.indexer, epAbsNo, True, scene_season)
if ab: if ab:
try: try:
(s, e) = helpers.get_all_episodes_from_absolute_number(self.show, None, [ab]) (s, e) = helpers.get_all_episodes_from_absolute_number(self.show, None, [ab])

View File

@ -167,7 +167,7 @@ def get_indexer_numbering(indexer_id, indexer, sceneSeason, sceneEpisode, fallba
return (sceneSeason, sceneEpisode) return (sceneSeason, sceneEpisode)
def get_indexer_absolute_numbering(indexer_id, indexer, sceneAbsoluteNumber, fallback_to_xem=True): def get_indexer_absolute_numbering(indexer_id, indexer, sceneAbsoluteNumber, fallback_to_xem=True, scene_season=None):
""" """
Returns a tuple, (season, episode, absolute_number) with the TVDB and TVRAGE numbering for (sceneAbsoluteNumber) Returns a tuple, (season, episode, absolute_number) with the TVDB and TVRAGE numbering for (sceneAbsoluteNumber)
(this works like the reverse of get_absolute_numbering) (this works like the reverse of get_absolute_numbering)
@ -179,15 +179,20 @@ def get_indexer_absolute_numbering(indexer_id, indexer, sceneAbsoluteNumber, fal
indexer = int(indexer) indexer = int(indexer)
myDB = db.DBConnection() myDB = db.DBConnection()
if scene_season is None:
rows = myDB.select( rows = myDB.select(
"SELECT absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_absolute_number = ?", "SELECT absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_absolute_number = ?",
[indexer, indexer_id, sceneAbsoluteNumber]) [indexer, indexer_id, sceneAbsoluteNumber])
else:
rows = myDB.select(
"SELECT absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_absolute_number = ? and scene_season = ?",
[indexer, indexer_id, sceneAbsoluteNumber, scene_season])
if rows: if rows:
return int(rows[0]["absolute_number"]) return int(rows[0]["absolute_number"])
else: else:
if fallback_to_xem: if fallback_to_xem:
return get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNumber) return get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNumber, scene_season)
return sceneAbsoluteNumber return sceneAbsoluteNumber
@ -303,7 +308,7 @@ def get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode
return (sceneSeason, sceneEpisode) return (sceneSeason, sceneEpisode)
def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNumber): def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNumber, scene_season=None):
""" """
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
@ -320,9 +325,14 @@ def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNum
xem_refresh(indexer_id, indexer) xem_refresh(indexer_id, indexer)
myDB = db.DBConnection() myDB = db.DBConnection()
if scene_season is None:
rows = myDB.select( rows = myDB.select(
"SELECT absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number = ?", "SELECT absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number = ?",
[indexer, indexer_id, sceneAbsoluteNumber]) [indexer, indexer_id, sceneAbsoluteNumber])
else:
rows = myDB.select(
"SELECT absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number = ? and scene_season = ?",
[indexer, indexer_id, sceneAbsoluteNumber, scene_season])
if rows: if rows:
return int(rows[0]["absolute_number"]) return int(rows[0]["absolute_number"])