1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-04 15:12:23 -05:00

Fix for issue #946 - Adding of shows via webAPI was failing.

Improvements made to Indexer's API modules, better error handling for missing or incomplete shows, shows that don't have actor or banner info are now properly error handled as well.
This commit is contained in:
echel0n 2014-11-24 18:47:14 -08:00
parent a9b44a156d
commit 9a33ddf85c
7 changed files with 270 additions and 203 deletions

View File

@ -39,7 +39,7 @@ from lib.dateutil.parser import parse
from lib.cachecontrol import CacheControl, caches
from tvdb_ui import BaseUI, ConsoleUI
from tvdb_exceptions import (tvdb_error, tvdb_userabort, tvdb_shownotfound,
from tvdb_exceptions import (tvdb_error, tvdb_userabort, tvdb_shownotfound, tvdb_showincomplete,
tvdb_seasonnotfound, tvdb_episodenotfound, tvdb_attributenotfound)
@ -627,10 +627,9 @@ class Tvdb:
"""Loads a URL using caching, returns an ElementTree of the source
"""
try:
src = self._loadUrl(url, params=params, language=language).values()[0]
return src
except:
return []
return self._loadUrl(url, params=params, language=language).values()[0]
except Exception, e:
raise tvdb_error(e)
def _setItem(self, sid, seas, ep, attrib, value):
"""Creates a new episode, creating Show(), Season() and
@ -681,11 +680,7 @@ class Tvdb:
log().debug("Searching for show %s" % series)
self.config['params_getSeries']['seriesname'] = series
try:
seriesFound = self._getetsrc(self.config['url_getSeries'], self.config['params_getSeries']).values()[0]
return seriesFound
except:
return []
return self._getetsrc(self.config['url_getSeries'], self.config['params_getSeries']).values()[0]
def _getSeries(self, series):
"""This searches TheTVDB.com for the series name,
@ -694,13 +689,13 @@ class Tvdb:
BaseUI is used to select the first result.
"""
allSeries = self.search(series)
if not allSeries:
log().debug('Series result returned zero')
raise tvdb_shownotfound("Show search returned zero results (cannot find show on TVDB)")
if not isinstance(allSeries, list):
allSeries = [allSeries]
if len(allSeries) == 0:
log().debug('Series result returned zero')
raise tvdb_shownotfound("Show-name search returned zero results (cannot find show on TVDB)")
if self.config['custom_ui'] is not None:
log().debug("Using custom UI %s" % (repr(self.config['custom_ui'])))
CustomUI = self.config['custom_ui']
@ -735,9 +730,12 @@ class Tvdb:
"""
log().debug('Getting season banners for %s' % (sid))
bannersEt = self._getetsrc(self.config['url_seriesBanner'] % (sid))
banners = {}
try:
if not bannersEt:
log().debug('Banners result returned zero')
return
banners = {}
for cur_banner in bannersEt['banner']:
bid = cur_banner['id']
btype = cur_banner['bannertype']
@ -764,8 +762,6 @@ class Tvdb:
log().debug("Transforming %s to %s" % (k, new_key))
new_url = self.config['url_artworkPrefix'] % (v)
banners[btype][btype2][bid][new_key] = new_url
except:
pass
self._setShowData(sid, "_banners", banners)
@ -796,8 +792,11 @@ class Tvdb:
log().debug("Getting actors for %s" % (sid))
actorsEt = self._getetsrc(self.config['url_actorsInfo'] % (sid))
if not actorsEt:
log().debug('Actors result returned zero')
return
cur_actors = Actors()
try:
for curActorItem in actorsEt["actor"]:
curActor = Actor()
for k, v in curActorItem.items():
@ -809,8 +808,6 @@ class Tvdb:
v = self._cleanData(v)
curActor[k] = v
cur_actors.append(curActor)
except:
pass
self._setShowData(sid, '_actors', cur_actors)
@ -840,8 +837,11 @@ class Tvdb:
self.config['url_seriesInfo'] % (sid, getShowInLanguage)
)
if not seriesInfoEt:
log().debug('Series result returned zero')
raise tvdb_shownotfound("Show search returned zero results (cannot find show on TVDB)")
# get series data
try:
for k, v in seriesInfoEt['series'].items():
if v is not None:
if k in ['banner', 'fanart', 'poster']:
@ -850,8 +850,6 @@ class Tvdb:
v = self._cleanData(v)
self._setShowData(sid, k, v)
except:
return False
# get episode data
if getEpInfo:
@ -865,18 +863,17 @@ class Tvdb:
# Parse episode data
log().debug('Getting all episodes of %s' % (sid))
if self.config['useZip']:
url = self.config['url_epInfo_zip'] % (sid, language)
else:
url = self.config['url_epInfo'] % (sid, language)
try:
epsEt = self._getetsrc(url, language=language)
episodes = epsEt["episode"]
except:
return False
if not epsEt:
log().debug('Series results incomplete')
raise tvdb_showincomplete("Show search returned incomplete results (cannot find complete show on TVDB)")
episodes = epsEt["episode"]
if not isinstance(episodes, list):
episodes = [episodes]
@ -940,7 +937,7 @@ class Tvdb:
# Item is integer, treat as show id
if key not in self.shows:
self._getShowData(key, self.config['language'], True)
return (None, self.shows[key])[key in self.shows]
return self.shows[key]
key = str(key).lower()
self.config['searchterm'] = key
@ -949,14 +946,10 @@ class Tvdb:
selected_series = [selected_series]
[[self._setShowData(show['id'], k, v) for k, v in show.items()] for show in selected_series]
return selected_series
#test = self._getSeries(key)
#sids = self._nameToSid(key)
#return list(self.shows[sid] for sid in sids)
def __repr__(self):
return str(self.shows)
def main():
"""Simple example of using tvdb_api - it just
grabs an episode name interactively.

View File

@ -11,7 +11,7 @@
__author__ = "dbr/Ben"
__version__ = "1.9"
__all__ = ["tvdb_error", "tvdb_userabort", "tvdb_shownotfound",
__all__ = ["tvdb_error", "tvdb_userabort", "tvdb_shownotfound", "tvdb_showincomplete",
"tvdb_seasonnotfound", "tvdb_episodenotfound", "tvdb_attributenotfound"]
class tvdb_exception(Exception):
@ -35,6 +35,11 @@ class tvdb_shownotfound(tvdb_exception):
"""
pass
class tvdb_showincomplete(tvdb_exception):
"""Show found but incomplete on thetvdb.com (incomplete show)
"""
pass
class tvdb_seasonnotfound(tvdb_exception):
"""Season cannot be found on thetvdb.com
"""

View File

@ -36,7 +36,7 @@ from lib.dateutil.parser import parse
from cachecontrol import CacheControl, caches
from tvrage_ui import BaseUI
from tvrage_exceptions import (tvrage_error, tvrage_userabort, tvrage_shownotfound,
from tvrage_exceptions import (tvrage_error, tvrage_userabort, tvrage_shownotfound, tvrage_showincomplete,
tvrage_seasonnotfound, tvrage_episodenotfound, tvrage_attributenotfound)
@ -465,10 +465,6 @@ class TVRage:
elif key == 'firstaired':
value = parse(value, fuzzy=True).date()
value = value.strftime("%Y-%m-%d")
#if key == 'airs_time':
# value = parse(value).time()
# value = value.strftime("%I:%M %p")
except:
pass
@ -485,10 +481,9 @@ class TVRage:
"""
try:
src = self._loadUrl(url, params).values()[0]
return src
except:
return []
return self._loadUrl(url, params).values()[0]
except Exception, e:
raise tvrage_error(e)
def _setItem(self, sid, seas, ep, attrib, value):
"""Creates a new episode, creating Show(), Season() and
@ -518,8 +513,6 @@ class TVRage:
"""
if sid not in self.shows:
self.shows[sid] = Show()
if not isinstance(key, dict or list) and not isinstance(value, dict or list):
self.shows[sid].data[key] = value
def _cleanData(self, data):
@ -544,11 +537,7 @@ class TVRage:
log().debug("Searching for show %s" % series)
self.config['params_getSeries']['show'] = series
try:
seriesFound = self._getetsrc(self.config['url_getSeries'], self.config['params_getSeries']).values()[0]
return seriesFound
except:
return []
return self._getetsrc(self.config['url_getSeries'], self.config['params_getSeries']).values()[0]
def _getSeries(self, series):
"""This searches tvrage.com for the series name,
@ -557,13 +546,13 @@ class TVRage:
BaseUI is used to select the first result.
"""
allSeries = self.search(series)
if not allSeries:
log().debug('Series result returned zero')
raise tvrage_shownotfound("Show search returned zero results (cannot find show on TVRAGE)")
if not isinstance(allSeries, list):
allSeries = [allSeries]
if len(allSeries) == 0:
log().debug('Series result returned zero')
raise tvrage_shownotfound("Show-name search returned zero results (cannot find show on TVRAGE)")
if self.config['custom_ui'] is not None:
log().debug("Using custom UI %s" % (repr(self.config['custom_ui'])))
CustomUI = self.config['custom_ui']
@ -588,54 +577,55 @@ class TVRage:
self.config['params_seriesInfo']
)
if not seriesInfoEt:
log().debug('Series result returned zero')
raise tvrage_shownotfound("Show search returned zero results (cannot find show on TVRAGE)")
# get series data
try:
for k, v in seriesInfoEt.items():
if v is not None:
v = self._cleanData(v)
self._setShowData(sid, k, v)
except:
return False
# get episode data
if getEpInfo:
# Parse episode data
log().debug('Getting all episodes of %s' % (sid))
self.config['params_epInfo']['sid'] = sid
try:
epsEt = self._getetsrc(self.config['url_epInfo'], self.config['params_epInfo'])
seasons = epsEt['episodelist']['season']
except:
return False
if not epsEt:
log().debug('Series results incomplete')
raise tvrage_showincomplete(
"Show search returned incomplete results (cannot find complete show on TVRAGE)")
seasons = epsEt['episodelist']['season']
if not isinstance(seasons, list):
seasons = [seasons]
for season in seasons:
seas_no = int(season['@no'])
episodes = season['episode']
if not isinstance(episodes, list):
episodes = [episodes]
for episode in episodes:
ep_no = int(episode['episodenumber'])
self._setItem(sid, seas_no, ep_no, 'seasonnumber', seas_no)
for k, v in episode.items():
try:
k = k.lower()
if v is not None:
if k == 'link':
v = v.rsplit('/', 1)[1]
k = 'id'
else:
v = self._cleanData(v)
self._setItem(sid, seas_no, ep_no, k, v)
except:
continue
return True
def _nameToSid(self, name):
@ -663,9 +653,9 @@ class TVRage:
# Item is integer, treat as show id
if key not in self.shows:
self._getShowData(key, True)
return (None, self.shows[key])[key in self.shows]
return self.shows[key]
key = key.lower()
key = str(key).lower()
self.config['searchterm'] = key
selected_series = self._getSeries(key)
if isinstance(selected_series, dict):

View File

@ -10,40 +10,53 @@
__author__ = "echel0n"
__version__ = "1.0"
__all__ = ["tvrage_error", "tvrage_userabort", "tvrage_shownotfound",
__all__ = ["tvrage_error", "tvrage_userabort", "tvrage_shownotfound", "tvrage_showincomplete",
"tvrage_seasonnotfound", "tvrage_episodenotfound", "tvrage_attributenotfound"]
class tvrage_exception(Exception):
"""Any exception generated by tvrage_api
"""
pass
class tvrage_error(tvrage_exception):
"""An error with tvrage.com (Cannot connect, for example)
"""
pass
class tvrage_userabort(tvrage_exception):
"""User aborted the interactive selection (via
the q command, ^c etc)
"""
pass
class tvrage_shownotfound(tvrage_exception):
"""Show cannot be found on tvrage.com (non-existant show)
"""
pass
class tvrage_showincomplete(tvrage_exception):
"""Show found but incomplete on tvrage.com (incomplete show)
"""
pass
class tvrage_seasonnotfound(tvrage_exception):
"""Season cannot be found on tvrage.com
"""
pass
class tvrage_episodenotfound(tvrage_exception):
"""Episode cannot be found on tvrage.com
"""
pass
class tvrage_attributenotfound(tvrage_exception):
"""Raised if an episode does not have the requested
attribute (such as a episode name)

View File

@ -45,8 +45,8 @@ from sickbeard import naming
from sickbeard import dailysearcher
from sickbeard import scene_numbering, scene_exceptions, name_cache
from indexers.indexer_api import indexerApi
from indexers.indexer_exceptions import indexer_shownotfound, indexer_exception, indexer_error, indexer_episodenotfound, \
indexer_attributenotfound, indexer_seasonnotfound, indexer_userabort, indexerExcepts
from indexers.indexer_exceptions import indexer_shownotfound, indexer_showincomplete, indexer_exception, indexer_error, \
indexer_episodenotfound, indexer_attributenotfound, indexer_seasonnotfound, indexer_userabort, indexerExcepts
from sickbeard.common import SD, SKIPPED, NAMING_REPEAT
from sickbeard.databases import mainDB, cache_db, failed_db
@ -466,10 +466,12 @@ TRAKT_API_KEY = 'abd806c54516240c76e4ebc9c5ccf394'
__INITIALIZED__ = False
def get_backlog_cycle_time():
cycletime = DAILYSEARCH_FREQUENCY * 2 + 7
return max([cycletime, 720])
def initialize(consoleLogging=True):
with INIT_LOCK:
@ -548,7 +550,8 @@ def initialize(consoleLogging=True):
# git_remote
GIT_REMOTE = check_setting_str(CFG, 'General', 'git_remote', 'origin')
GIT_REMOTE_URL = check_setting_str(CFG, 'General', 'git_remote_url', 'https://github.com/SiCKRAGETV/SickRage.git')
GIT_REMOTE_URL = check_setting_str(CFG, 'General', 'git_remote_url',
'https://github.com/SiCKRAGETV/SickRage.git')
# current commit hash
CUR_COMMIT_HASH = check_setting_str(CFG, 'General', 'cur_commit_hash', '')
@ -659,7 +662,8 @@ def initialize(consoleLogging=True):
NAMING_ABD_PATTERN = check_setting_str(CFG, 'General', 'naming_abd_pattern', '%SN - %A.D - %EN')
NAMING_CUSTOM_ABD = bool(check_setting_int(CFG, 'General', 'naming_custom_abd', 0))
NAMING_SPORTS_PATTERN = check_setting_str(CFG, 'General', 'naming_sports_pattern', '%SN - %A-D - %EN')
NAMING_ANIME_PATTERN = check_setting_str(CFG, 'General', 'naming_anime_pattern', 'Season %0S/%SN - S%0SE%0E - %EN')
NAMING_ANIME_PATTERN = check_setting_str(CFG, 'General', 'naming_anime_pattern',
'Season %0S/%SN - S%0SE%0E - %EN')
NAMING_ANIME = check_setting_int(CFG, 'General', 'naming_anime', 3)
NAMING_CUSTOM_SPORTS = bool(check_setting_int(CFG, 'General', 'naming_custom_sports', 0))
NAMING_CUSTOM_ANIME = bool(check_setting_int(CFG, 'General', 'naming_custom_anime', 0))

View File

@ -12,19 +12,20 @@ __version__ = "1.0"
from lib.tvrage_api.tvrage_exceptions import \
tvrage_exception, tvrage_attributenotfound, tvrage_episodenotfound, tvrage_error, \
tvrage_seasonnotfound, tvrage_shownotfound, tvrage_userabort
tvrage_seasonnotfound, tvrage_shownotfound, tvrage_showincomplete, tvrage_userabort
from lib.tvdb_api.tvdb_exceptions import \
tvdb_exception, tvdb_attributenotfound, tvdb_episodenotfound, tvdb_error, \
tvdb_seasonnotfound, tvdb_shownotfound, tvdb_userabort
tvdb_seasonnotfound, tvdb_shownotfound, tvdb_showincomplete, tvdb_userabort
indexerExcepts = ["indexer_exception", "indexer_error", "indexer_userabort", "indexer_shownotfound",
"indexer_showincomplete",
"indexer_seasonnotfound", "indexer_episodenotfound", "indexer_attributenotfound"]
tvdbExcepts = ["tvdb_exception", "tvdb_error", "tvdb_userabort", "tvdb_shownotfound",
tvdbExcepts = ["tvdb_exception", "tvdb_error", "tvdb_userabort", "tvdb_shownotfound", "tvdb_showincomplete",
"tvdb_seasonnotfound", "tvdb_episodenotfound", "tvdb_attributenotfound"]
tvrageExcepts = ["tvdb_exception", "tvrage_error", "tvrage_userabort", "tvrage_shownotfound",
tvrageExcepts = ["tvdb_exception", "tvrage_error", "tvrage_userabort", "tvrage_shownotfound", "tvrage_showincomplete",
"tvrage_seasonnotfound", "tvrage_episodenotfound", "tvrage_attributenotfound"]
# link API exceptions to our exception handler
@ -35,3 +36,4 @@ indexer_attributenotfound = tvdb_attributenotfound, tvrage_attributenotfound
indexer_episodenotfound = tvdb_episodenotfound, tvrage_episodenotfound
indexer_seasonnotfound = tvdb_seasonnotfound, tvrage_seasonnotfound
indexer_shownotfound = tvdb_shownotfound, tvrage_shownotfound
indexer_showincomplete = tvdb_showincomplete, tvrage_showincomplete

View File

@ -73,7 +73,6 @@ class Api(webserve.MainHandler):
intent = 4
def index(self, *args, **kwargs):
self.apiKey = sickbeard.API_KEY
access, accessMsg, args, kwargs = self._grand_access(self.apiKey, args, kwargs)
@ -373,7 +372,7 @@ class ApiCall(object):
"""
# auto-select indexer
if key == "indexerid":
if key in indexer_ids:
if "tvdbid" in kwargs:
key = "tvdbid"
elif "tvrageid" in kwargs:
@ -1132,6 +1131,7 @@ class CMD_Exceptions(ApiCall):
# required
# optional
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, False, "int", [])
# super, missing, help
ApiCall.__init__(self, handler, args, kwargs)
@ -1642,7 +1642,6 @@ class CMD_SickBeardSearchIndexers(ApiCall):
self.lang, args = self.check_params(args, kwargs, "lang", "en", False, "string", self.valid_languages.keys())
self.indexerid, args = self.check_params(args, kwargs, "indexerid", None, False, "int", [])
self.indexer, args = self.check_params(args, kwargs, "indexer", self.indexer, False, "int", [])
# super, missing, help
ApiCall.__init__(self, handler, args, kwargs)
@ -1654,42 +1653,45 @@ class CMD_SickBeardSearchIndexers(ApiCall):
lang_id = self.valid_languages[self.lang]
if self.name and not self.indexerid: # only name was given
for self.indexer in sickbeard.indexerApi().indexers if not self.indexer else [int(self.indexer)]:
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
for _indexer in sickbeard.indexerApi().indexers if self.indexer == 0 else [int(self.indexer)]:
lINDEXER_API_PARMS = sickbeard.indexerApi(_indexer).api_params.copy()
if self.lang and not self.lang == 'en':
lINDEXER_API_PARMS['language'] = self.lang
lINDEXER_API_PARMS['actors'] = False
lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
apiData = None
t = sickbeard.indexerApi(_indexer).indexer(**lINDEXER_API_PARMS)
try:
apiData = t[str(self.name).encode()]
except Exception, e:
pass
except (sickbeard.indexer_shownotfound, sickbeard.indexer_showincomplete, sickbeard.indexer_error):
logger.log(u"API :: Unable to find show with id " + str(self.indexerid), logger.WARNING)
return _responds(RESULT_SUCCESS, {"results": [], "langid": lang_id})
for curSeries in apiData:
results.append({indexer_ids[self.indexer]: int(curSeries['id']),
results.append({indexer_ids[_indexer]: int(curSeries['id']),
"name": curSeries['seriesname'],
"first_aired": curSeries['firstaired'],
"indexer": self.indexer})
"indexer": int(_indexer)})
return _responds(RESULT_SUCCESS, {"results": results, "langid": lang_id})
elif self.indexerid:
for self.indexer in sickbeard.indexerApi().indexers if not self.indexer > 0 else [int(self.indexer)]:
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
for _indexer in sickbeard.indexerApi().indexers if self.indexer == 0 else [int(self.indexer)]:
lINDEXER_API_PARMS = sickbeard.indexerApi(_indexer).api_params.copy()
if self.lang and not self.lang == 'en':
lINDEXER_API_PARMS['language'] = self.lang
lINDEXER_API_PARMS['actors'] = False
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
t = sickbeard.indexerApi(_indexer).indexer(**lINDEXER_API_PARMS)
try:
myShow = t[int(self.indexerid)]
except (sickbeard.indexer_shownotfound, sickbeard.indexer_error):
except (sickbeard.indexer_shownotfound, sickbeard.indexer_showincomplete, sickbeard.indexer_error):
logger.log(u"API :: Unable to find show with id " + str(self.indexerid), logger.WARNING)
return _responds(RESULT_SUCCESS, {"results": [], "langid": lang_id})
@ -1699,9 +1701,12 @@ class CMD_SickBeardSearchIndexers(ApiCall):
self.indexerid) + ", however it contained no show name", logger.DEBUG)
return _responds(RESULT_FAILURE, msg="Show contains no name, invalid result")
results = [{indexer_ids[self.indexer]: self.indexerid,
# found show
results = [{indexer_ids[_indexer]: int(myShow.data['id']),
"name": unicode(myShow.data['seriesname']),
"first_aired": myShow.data['firstaired']}]
"first_aired": myShow.data['firstaired'],
"indexer": int(_indexer)}]
break
return _responds(RESULT_SUCCESS, {"results": results, "langid": lang_id})
else:
@ -1711,29 +1716,27 @@ class CMD_SickBeardSearchIndexers(ApiCall):
class CMD_SickBeardSearchTVDB(CMD_SickBeardSearchIndexers):
_help = {"desc": "search for show on theTVDB with a given string and language",
"optionalParameters": {"name": {"desc": "name of the show you want to search for"},
"tvdbid": {
"desc": "thetvdb.com unique id of a show"},
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"lang": {"desc": "the 2 letter abbreviation lang id"}
}
}
def __init__(self, handler, args, kwargs):
self.indexer = 1
self.indexerid, args = self.check_params(args, kwargs, "tvdbid", None, False, "int", [])
CMD_SickBeardSearchIndexers.__init__(self, handler, args, kwargs)
class CMD_SickBeardSearchTVRAGE(CMD_SickBeardSearchIndexers):
_help = {"desc": "search for show on TVRage with a given string and language",
"optionalParameters": {"name": {"desc": "name of the show you want to search for"},
"tvrageid": {
"desc": "tvrage.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"lang": {"desc": "the 2 letter abbreviation lang id"}
}
}
def __init__(self, handler, args, kwargs):
self.indexer = 2
self.indexerid, args = self.check_params(args, kwargs, "tvrageid", None, False, "int", [])
CMD_SickBeardSearchIndexers.__init__(self, handler, args, kwargs)
@ -1835,7 +1838,8 @@ class CMD_Show(ApiCall):
"requiredParameters": {
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
@ -1910,10 +1914,13 @@ class CMD_Show(ApiCall):
class CMD_ShowAddExisting(ApiCall):
_help = {"desc": "add a show in sickrage with an existing folder",
"requiredParameters": {"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com id"},
"requiredParameters": {"indexerid": {"desc": "unique id of a show"},
"location": {"desc": "full path to the existing folder for the show"}
},
"optionalParameters": {"initial": {"desc": "initial quality for the show"},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"initial": {"desc": "initial quality for the show"},
"archive": {"desc": "archive quality for the show"},
"flatten_folders": {"desc": "flatten subfolders for the show"},
"subtitles": {"desc": "allow search episode subtitle"}
@ -1963,6 +1970,9 @@ class CMD_ShowAddExisting(ApiCall):
if not indexerName:
return _responds(RESULT_FAILURE, msg="Unable to retrieve information from indexer")
# set indexer so we can pass it along when adding show to SR
indexer = indexerResult['data']['results'][0]['indexer']
quality_map = {'sdtv': Quality.SDTV,
'sddvd': Quality.SDDVD,
'hdtv': Quality.HDTV,
@ -1989,7 +1999,7 @@ class CMD_ShowAddExisting(ApiCall):
if iqualityID or aqualityID:
newQuality = Quality.combineQualities(iqualityID, aqualityID)
sickbeard.showQueueScheduler.action.addShow(int(self.indexer), int(self.indexerid), self.location, SKIPPED,
sickbeard.showQueueScheduler.action.addShow(int(indexer), int(self.indexerid), self.location, SKIPPED,
newQuality, int(self.flatten_folders))
return _responds(RESULT_SUCCESS, {"name": indexerName}, indexerName + " has been queued to be added")
@ -1997,9 +2007,12 @@ class CMD_ShowAddExisting(ApiCall):
class CMD_ShowAddNew(ApiCall):
_help = {"desc": "add a new show to sickrage",
"requiredParameters": {"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com id"}
"requiredParameters": {"indexerid": {"desc": "unique id of a show"}
},
"optionalParameters": {"initial": {"desc": "initial quality for the show"},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"initial": {"desc": "initial quality for the show"},
"location": {"desc": "base path for where the show folder is to be created"},
"archive": {"desc": "archive quality for the show"},
"flatten_folders": {"desc": "flatten subfolders for the show"},
@ -2123,6 +2136,9 @@ class CMD_ShowAddNew(ApiCall):
if not indexerName:
return _responds(RESULT_FAILURE, msg="Unable to retrieve information from indexer")
# set indexer for found show so we can pass it along
indexer = indexerResult['data']['results'][0]['indexer']
# moved the logic check to the end in an attempt to eliminate empty directory being created from previous errors
showPath = ek.ek(os.path.join, self.location, helpers.sanitizeFileName(indexerName))
@ -2138,7 +2154,7 @@ class CMD_ShowAddNew(ApiCall):
else:
helpers.chmodAsParent(showPath)
sickbeard.showQueueScheduler.action.addShow(int(self.indexer), int(self.indexerid), showPath, newStatus,
sickbeard.showQueueScheduler.action.addShow(int(indexer), int(self.indexerid), showPath, newStatus,
newQuality,
int(self.flatten_folders), self.lang, self.subtitles, self.anime,
self.scene) # @UndefinedVariable
@ -2149,7 +2165,11 @@ class CMD_ShowAddNew(ApiCall):
class CMD_ShowCache(ApiCall):
_help = {"desc": "check sickrage's cache to see if the banner or poster image for a show is valid",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}
"indexerid": {"desc": "unique id of a show"}
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2185,7 +2205,11 @@ class CMD_ShowCache(ApiCall):
class CMD_ShowDelete(ApiCall):
_help = {"desc": "delete a show in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2213,7 +2237,11 @@ class CMD_ShowDelete(ApiCall):
class CMD_ShowGetQuality(ApiCall):
_help = {"desc": "get quality setting for a show in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}
"indexerid": {"desc": "unique id of a show"}
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2238,7 +2266,11 @@ class CMD_ShowGetQuality(ApiCall):
class CMD_ShowGetPoster(ApiCall):
_help = {"desc": "get the poster stored for a show in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}
"indexerid": {"desc": "unique id of a show"}
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2257,7 +2289,11 @@ class CMD_ShowGetPoster(ApiCall):
class CMD_ShowGetBanner(ApiCall):
_help = {"desc": "get the banner stored for a show in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}
"indexerid": {"desc": "unique id of a show"}
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2276,9 +2312,12 @@ class CMD_ShowGetBanner(ApiCall):
class CMD_ShowPause(ApiCall):
_help = {"desc": "set a show's paused state in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {"pause": {"desc": "set the pause state of the show"}
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"pause": {"desc": "set the pause state of the show"}
}
}
@ -2309,7 +2348,11 @@ class CMD_ShowPause(ApiCall):
class CMD_ShowRefresh(ApiCall):
_help = {"desc": "refresh a show in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2337,9 +2380,12 @@ class CMD_ShowRefresh(ApiCall):
class CMD_ShowSeasonList(ApiCall):
_help = {"desc": "display the season list for a given show",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {"sort": {"desc": "change the sort order from descending to ascending"}
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"sort": {"desc": "change the sort order from descending to ascending"}
}
}
@ -2376,9 +2422,12 @@ class CMD_ShowSeasonList(ApiCall):
class CMD_ShowSeasons(ApiCall):
_help = {"desc": "display a listing of episodes for all or a given season",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {"season": {"desc": "the season number"},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"season": {"desc": "the season number"},
}
}
@ -2445,9 +2494,12 @@ class CMD_ShowSetQuality(ApiCall):
_help = {
"desc": "set desired quality of a show in sickrage. if neither initial or archive are provided then the config default quality will be used",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"}
"indexerid": {"desc": "unique id of a show"}
},
"optionalParameters": {"initial": {"desc": "initial quality for the show"},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
"initial": {"desc": "initial quality for the show"},
"archive": {"desc": "archive quality for the show"}
}
}
@ -2510,7 +2562,11 @@ class CMD_ShowSetQuality(ApiCall):
class CMD_ShowStats(ApiCall):
_help = {"desc": "display episode statistics for a given show",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}
@ -2615,7 +2671,11 @@ class CMD_ShowStats(ApiCall):
class CMD_ShowUpdate(ApiCall):
_help = {"desc": "update a show in sickrage",
"requiredParameters": {
"indexerid or tvdbid or tvrageid": {"desc": "thetvdb.com or tvrage.com unique id of a show"},
"indexerid": {"desc": "unique id of a show"},
},
"optionalParameters": {
"tvdbid": {"desc": "thetvdb.com unique id of a show"},
"tvrageid": {"desc": "tvrage.com unique id of a show"},
}
}