Commit 34aa88cd authored by echel0n's avatar echel0n

Refactored show object class, cleaned up naming conventions for functions.

parent 753625db
# Changelog # Changelog
- * e191b1e - 2018-11-12: Refactored queue current item property to always represent current running task. - * 3176978 - 2018-11-12: Refactored show object class, cleaned up naming conventions for functions.
- * 753625d - 2018-11-12: Refactored queue current item property to always represent current running task.
- * 8bd128e - 2018-11-11: Release v9.4.30 - * 8bd128e - 2018-11-11: Release v9.4.30
- * 90fdbb1 - 2018-11-11: Pre-Release v9.4.30.dev1 - * 90fdbb1 - 2018-11-11: Pre-Release v9.4.30.dev1
- * 007df0a - 2018-11-11: Refactored get, all, and get_many database functions. - * 007df0a - 2018-11-11: Refactored get, all, and get_many database functions.
......
...@@ -544,7 +544,7 @@ class Core(object): ...@@ -544,7 +544,7 @@ class Core(object):
self.log.info("Saving all shows to the database") self.log.info("Saving all shows to the database")
for show in self.showlist: for show in self.showlist:
try: try:
show.saveToDB() show.save_to_db()
except Exception: except Exception:
continue continue
......
...@@ -288,7 +288,7 @@ class TVCache(object): ...@@ -288,7 +288,7 @@ class TVCache(object):
continue continue
try: try:
result.episodes = [result.show.getEpisode(curSeason, int(curEp)) for curEp in result.episodes = [result.show.get_episode(curSeason, int(curEp)) for curEp in
filter(None, curResult["episodes"].split("|"))] filter(None, curResult["episodes"].split("|"))]
except EpisodeNotFoundException: except EpisodeNotFoundException:
continue continue
...@@ -300,7 +300,7 @@ class TVCache(object): ...@@ -300,7 +300,7 @@ class TVCache(object):
# make sure we want the episode # make sure we want the episode
wantEp = False wantEp = False
for curEp in result.episodes: for curEp in result.episodes:
if result.show.wantEpisode(curEp.season, curEp.episode, result.quality, manualSearch, downCurQuality): if result.show.want_episode(curEp.season, curEp.episode, result.quality, manualSearch, downCurQuality):
wantEp = True wantEp = True
if not wantEp: if not wantEp:
......
...@@ -170,7 +170,7 @@ def makeSceneSeasonSearchString(show, ep_obj, extraSearchType=None): ...@@ -170,7 +170,7 @@ def makeSceneSeasonSearchString(show, ep_obj, extraSearchType=None):
# the search string for air by date shows is just # the search string for air by date shows is just
seasonStrings = [str(ep_obj.airdate).split('-')[0]] seasonStrings = [str(ep_obj.airdate).split('-')[0]]
elif show.is_anime: elif show.is_anime:
seasonEps = show.getAllEpisodes(ep_obj.season) seasonEps = show.get_all_episodes(ep_obj.season)
# get show qualities # get show qualities
anyQualities, bestQualities = Quality.splitQuality(show.quality) anyQualities, bestQualities = Quality.splitQuality(show.quality)
......
...@@ -176,7 +176,7 @@ def splitNZBResult(result): ...@@ -176,7 +176,7 @@ def splitNZBResult(result):
wantEp = True wantEp = True
for epNo in parse_result.episode_numbers: for epNo in parse_result.episode_numbers:
if not result.extraInfo[0].wantEpisode(season, epNo, result.quality): if not result.extraInfo[0].want_episode(season, epNo, result.quality):
sickrage.app.log.info( sickrage.app.log.info(
"Ignoring result " + newNZB + " because we don't want an episode that is " + "Ignoring result " + newNZB + " because we don't want an episode that is " +
Quality.qualityStrings[result.quality]) Quality.qualityStrings[result.quality])
...@@ -188,7 +188,7 @@ def splitNZBResult(result): ...@@ -188,7 +188,7 @@ def splitNZBResult(result):
# get all the associated episode objects # get all the associated episode objects
epObjList = [] epObjList = []
for curEp in parse_result.episode_numbers: for curEp in parse_result.episode_numbers:
epObjList.append(result.extraInfo[0].getEpisode(season, curEp)) epObjList.append(result.extraInfo[0].get_episode(season, curEp))
# make a result # make a result
curResult = classes.NZBDataSearchResult(epObjList) curResult = classes.NZBDataSearchResult(epObjList)
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
from __future__ import print_function, unicode_literals from __future__ import print_function, unicode_literals
import sickrage import sickrage
from sickrage.core.common import Quality, WANTED, DOWNLOADED, SNATCHED, SNATCHED_PROPER, SNATCHED_BEST from sickrage.core.common import Quality, SNATCHED, SNATCHED_PROPER, SNATCHED_BEST
from sickrage.core.exceptions import FailedPostProcessingFailedException from sickrage.core.exceptions import FailedPostProcessingFailedException
from sickrage.core.helpers import show_names from sickrage.core.helpers import show_names
from sickrage.core.nameparser import InvalidNameException, InvalidShowException, \ from sickrage.core.nameparser import InvalidNameException, InvalidShowException, \
...@@ -77,7 +77,7 @@ class FailedProcessor(object): ...@@ -77,7 +77,7 @@ class FailedProcessor(object):
sickrage.app.log.debug(" - " + str(parsed.air_date)) sickrage.app.log.debug(" - " + str(parsed.air_date))
for episode in parsed.episode_numbers: for episode in parsed.episode_numbers:
segment = parsed.show.getEpisode(parsed.season_number, episode) segment = parsed.show.get_episode(parsed.season_number, episode)
curStatus, curQuality = Quality.splitCompositeStatus(segment.status) curStatus, curQuality = Quality.splitCompositeStatus(segment.status)
if curStatus not in {SNATCHED, SNATCHED_BEST, SNATCHED_PROPER}: if curStatus not in {SNATCHED, SNATCHED_BEST, SNATCHED_PROPER}:
......
...@@ -775,7 +775,7 @@ class PostProcessor(object): ...@@ -775,7 +775,7 @@ class PostProcessor(object):
# now that we've figured out which episode this file is just load it manually # now that we've figured out which episode this file is just load it manually
try: try:
curEp = show.getEpisode(season, cur_episode) curEp = show.get_episode(season, cur_episode)
except EpisodeNotFoundException as e: except EpisodeNotFoundException as e:
self._log("Unable to create episode: {}".format(e)), sickrage.app.log.DEBUG self._log("Unable to create episode: {}".format(e)), sickrage.app.log.DEBUG
raise EpisodePostProcessingFailedException() raise EpisodePostProcessingFailedException()
...@@ -1060,7 +1060,7 @@ class PostProcessor(object): ...@@ -1060,7 +1060,7 @@ class PostProcessor(object):
"Unable to create the show directory: " + ep_obj.show.location) "Unable to create the show directory: " + ep_obj.show.location)
# write metadata for the show (but not episode because it hasn't been fully processed) # write metadata for the show (but not episode because it hasn't been fully processed)
ep_obj.show.writeMetadata(True) ep_obj.show.write_metadata(True)
# update the ep info before we rename so the quality & release name go into the name properly # update the ep info before we rename so the quality & release name go into the name properly
for cur_ep in [ep_obj] + ep_obj.relatedEps: for cur_ep in [ep_obj] + ep_obj.relatedEps:
...@@ -1091,7 +1091,7 @@ class PostProcessor(object): ...@@ -1091,7 +1091,7 @@ class PostProcessor(object):
else: else:
cur_ep.release_group = "" cur_ep.release_group = ""
cur_ep.saveToDB() cur_ep.save_to_db()
# Just want to keep this consistent for failed handling right now # Just want to keep this consistent for failed handling right now
releaseName = show_names.determineReleaseName(self.folder_path, self.nzb_name) releaseName = show_names.determineReleaseName(self.folder_path, self.nzb_name)
...@@ -1164,13 +1164,13 @@ class PostProcessor(object): ...@@ -1164,13 +1164,13 @@ class PostProcessor(object):
with cur_ep.lock: with cur_ep.lock:
cur_ep.location = os.path.join(dest_path, new_file_name) cur_ep.location = os.path.join(dest_path, new_file_name)
cur_ep.refreshSubtitles() cur_ep.refreshSubtitles()
cur_ep.downloadSubtitles() cur_ep.download_subtitles()
# put the new location in the database # put the new location in the database
for cur_ep in [ep_obj] + ep_obj.relatedEps: for cur_ep in [ep_obj] + ep_obj.relatedEps:
with cur_ep.lock: with cur_ep.lock:
cur_ep.location = os.path.join(dest_path, new_file_name) cur_ep.location = os.path.join(dest_path, new_file_name)
cur_ep.saveToDB() cur_ep.save_to_db()
# set file modify stamp to show airdate # set file modify stamp to show airdate
if sickrage.app.config.airdate_episodes: if sickrage.app.config.airdate_episodes:
......
...@@ -125,7 +125,7 @@ class ShowQueue(srQueue): ...@@ -125,7 +125,7 @@ class ShowQueue(srQueue):
def renameShowEpisodes(self, show): def renameShowEpisodes(self, show):
return self.put(QueueItemRename(show)) return self.put(QueueItemRename(show))
def downloadSubtitles(self, show): def download_subtitles(self, show):
return self.put(QueueItemSubtitle(show)) return self.put(QueueItemSubtitle(show))
def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None, def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None,
...@@ -208,7 +208,7 @@ class ShowQueueItem(srQueueItem): ...@@ -208,7 +208,7 @@ class ShowQueueItem(srQueueItem):
self.show = show self.show = show
def finish(self): def finish(self):
self.show.flushEpisodes() self.show.flush_episodes()
def is_in_queue(self): def is_in_queue(self):
return self in sickrage.app.show_queue.queue + [sickrage.app.show_queue.current_item] return self in sickrage.app.show_queue.queue + [sickrage.app.show_queue.current_item]
...@@ -339,7 +339,7 @@ class QueueItemAdd(ShowQueueItem): ...@@ -339,7 +339,7 @@ class QueueItemAdd(ShowQueueItem):
try: try:
self.show = TVShow(self.indexer, self.indexer_id, self.lang) self.show = TVShow(self.indexer, self.indexer_id, self.lang)
self.show.loadFromIndexer() self.show.load_from_indexer()
# set up initial values # set up initial values
self.show.location = self.showDir self.show.location = self.showDir
...@@ -404,7 +404,7 @@ class QueueItemAdd(ShowQueueItem): ...@@ -404,7 +404,7 @@ class QueueItemAdd(ShowQueueItem):
sickrage.app.log.error("Error loading IMDb info: {}".format(e)) sickrage.app.log.error("Error loading IMDb info: {}".format(e))
try: try:
self.show.saveToDB() self.show.save_to_db()
except Exception as e: except Exception as e:
sickrage.app.log.error("Error saving the show to the database: {}".format(e)) sickrage.app.log.error("Error saving the show to the database: {}".format(e))
sickrage.app.log.debug(traceback.format_exc()) sickrage.app.log.debug(traceback.format_exc())
...@@ -415,7 +415,7 @@ class QueueItemAdd(ShowQueueItem): ...@@ -415,7 +415,7 @@ class QueueItemAdd(ShowQueueItem):
sickrage.app.showlist.append(self.show) sickrage.app.showlist.append(self.show)
try: try:
self.show.loadEpisodesFromIndexer() self.show.load_episodes_from_indexer()
except Exception as e: except Exception as e:
sickrage.app.log.error( sickrage.app.log.error(
"Error with " + IndexerApi( "Error with " + IndexerApi(
...@@ -423,7 +423,7 @@ class QueueItemAdd(ShowQueueItem): ...@@ -423,7 +423,7 @@ class QueueItemAdd(ShowQueueItem):
sickrage.app.log.debug(traceback.format_exc()) sickrage.app.log.debug(traceback.format_exc())
try: try:
self.show.loadEpisodesFromDir() self.show.load_episodes_from_dir()
except Exception as e: except Exception as e:
sickrage.app.log.debug("Error searching dir for episodes: {}".format(e)) sickrage.app.log.debug("Error searching dir for episodes: {}".format(e))
sickrage.app.log.debug(traceback.format_exc()) sickrage.app.log.debug(traceback.format_exc())
...@@ -433,8 +433,8 @@ class QueueItemAdd(ShowQueueItem): ...@@ -433,8 +433,8 @@ class QueueItemAdd(ShowQueueItem):
sickrage.app.log.info("Launching backlog for this show since its episodes are WANTED") sickrage.app.log.info("Launching backlog for this show since its episodes are WANTED")
sickrage.app.backlog_searcher.search_backlog([self.show]) sickrage.app.backlog_searcher.search_backlog([self.show])
self.show.writeMetadata(force=True) self.show.write_metadata(force=True)
self.show.populateCache() self.show.populate_cache()
if sickrage.app.config.use_trakt: if sickrage.app.config.use_trakt:
# if there are specific episodes that need to be added by trakt # if there are specific episodes that need to be added by trakt
...@@ -457,7 +457,7 @@ class QueueItemAdd(ShowQueueItem): ...@@ -457,7 +457,7 @@ class QueueItemAdd(ShowQueueItem):
self.show.default_ep_status = self.default_status_after self.show.default_ep_status = self.default_status_after
self.show.saveToDB() self.show.save_to_db()
sickrage.app.name_cache.build(self.show) sickrage.app.name_cache.build(self.show)
...@@ -486,10 +486,10 @@ class QueueItemRefresh(ShowQueueItem): ...@@ -486,10 +486,10 @@ class QueueItemRefresh(ShowQueueItem):
sickrage.app.log.info("Performing refresh for show: {}".format(self.show.name)) sickrage.app.log.info("Performing refresh for show: {}".format(self.show.name))
self.show.refreshDir() self.show.refresh_dir()
self.show.writeMetadata(force=self.force) self.show.write_metadata(force=self.force)
self.show.populateCache(force=self.force) self.show.populate_cache(force=self.force)
# Load XEM data to DB for show # Load XEM data to DB for show
# xem_refresh(self.show.indexerid, self.show.indexer) # xem_refresh(self.show.indexerid, self.show.indexer)
...@@ -516,7 +516,7 @@ class QueueItemRename(ShowQueueItem): ...@@ -516,7 +516,7 @@ class QueueItemRename(ShowQueueItem):
ep_obj_rename_list = [] ep_obj_rename_list = []
ep_obj_list = self.show.getAllEpisodes(has_location=True) ep_obj_list = self.show.get_all_episodes(has_location=True)
for cur_ep_obj in ep_obj_list: for cur_ep_obj in ep_obj_list:
# Only want to rename if we have a location # Only want to rename if we have a location
if cur_ep_obj.location: if cur_ep_obj.location:
...@@ -548,7 +548,7 @@ class QueueItemSubtitle(ShowQueueItem): ...@@ -548,7 +548,7 @@ class QueueItemSubtitle(ShowQueueItem):
def run(self): def run(self):
sickrage.app.log.info("Started downloading subtitles for show: {}".format(self.show.name)) sickrage.app.log.info("Started downloading subtitles for show: {}".format(self.show.name))
self.show.downloadSubtitles() self.show.download_subtitles()
self.finish() self.finish()
...@@ -567,7 +567,7 @@ class QueueItemUpdate(ShowQueueItem): ...@@ -567,7 +567,7 @@ class QueueItemUpdate(ShowQueueItem):
try: try:
sickrage.app.log.debug("Retrieving show info from " + IndexerApi(self.show.indexer).name + "") sickrage.app.log.debug("Retrieving show info from " + IndexerApi(self.show.indexer).name + "")
self.show.loadFromIndexer(cache=False) self.show.load_from_indexer(cache=False)
except indexer_error as e: except indexer_error as e:
sickrage.app.log.warning( sickrage.app.log.warning(
"Unable to contact " + IndexerApi(self.show.indexer).name + ", aborting: {}".format(e)) "Unable to contact " + IndexerApi(self.show.indexer).name + ", aborting: {}".format(e))
...@@ -584,12 +584,12 @@ class QueueItemUpdate(ShowQueueItem): ...@@ -584,12 +584,12 @@ class QueueItemUpdate(ShowQueueItem):
sickrage.app.log.warning("Error loading IMDb info for {}: {}".format(IndexerApi(self.show.indexer).name, e)) sickrage.app.log.warning("Error loading IMDb info for {}: {}".format(IndexerApi(self.show.indexer).name, e))
# get episode list from DB # get episode list from DB
DBEpList = self.show.loadEpisodesFromDB() DBEpList = self.show.load_episodes_from_db()
IndexerEpList = None IndexerEpList = None
# get episode list from TVDB # get episode list from TVDB
try: try:
IndexerEpList = self.show.loadEpisodesFromIndexer() IndexerEpList = self.show.load_episodes_from_indexer()
except indexer_exception as e: except indexer_exception as e:
sickrage.app.log.error("Unable to get info from " + IndexerApi( sickrage.app.log.error("Unable to get info from " + IndexerApi(
self.show.indexer).name + ", the show info will not be refreshed: {}".format(e)) self.show.indexer).name + ", the show info will not be refreshed: {}".format(e))
...@@ -610,7 +610,7 @@ class QueueItemUpdate(ShowQueueItem): ...@@ -610,7 +610,7 @@ class QueueItemUpdate(ShowQueueItem):
sickrage.app.log.info( sickrage.app.log.info(
"Permanently deleting episode " + str(curSeason) + "x" + str(curEpisode) + " from the database") "Permanently deleting episode " + str(curSeason) + "x" + str(curEpisode) + " from the database")
try: try:
self.show.getEpisode(curSeason, curEpisode).deleteEpisode() self.show.get_episode(curSeason, curEpisode).deleteEpisode()
except EpisodeDeletedException: except EpisodeDeletedException:
pass pass
...@@ -653,7 +653,7 @@ class QueueItemRemove(ShowQueueItem): ...@@ -653,7 +653,7 @@ class QueueItemRemove(ShowQueueItem):
sickrage.app.quicksearch_cache.del_show(self.show.indexerid) sickrage.app.quicksearch_cache.del_show(self.show.indexerid)
self.show.deleteShow(full=self.full) self.show.delete_show(full=self.full)
if sickrage.app.config.use_trakt: if sickrage.app.config.use_trakt:
try: try:
......
...@@ -244,7 +244,7 @@ def set_scene_numbering(indexer_id, indexer, season=0, episode=0, absolute_numbe ...@@ -244,7 +244,7 @@ def set_scene_numbering(indexer_id, indexer, season=0, episode=0, absolute_numbe
# Reload data from DB so that cache and db are in sync # Reload data from DB so that cache and db are in sync
show = findCertainShow(indexer_id) show = findCertainShow(indexer_id)
show.flushEpisodes() show.flush_episodes()
def find_xem_numbering(indexer_id, indexer, season, episode): def find_xem_numbering(indexer_id, indexer, season, episode):
......
...@@ -110,7 +110,7 @@ def snatchEpisode(result, endStatus=SNATCHED): ...@@ -110,7 +110,7 @@ def snatchEpisode(result, endStatus=SNATCHED):
curEpObj.status = Quality.compositeStatus(endStatus, result.quality) curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
# save episode to DB # save episode to DB
curEpObj.saveToDB() curEpObj.save_to_db()
if curEpObj.status not in Quality.DOWNLOADED: if curEpObj.status not in Quality.DOWNLOADED:
try: try:
...@@ -446,7 +446,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up ...@@ -446,7 +446,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up
anyWanted = False anyWanted = False
for curEpNum in allEps: for curEpNum in allEps:
for season in set([x.season for x in episodes]): for season in set([x.season for x in episodes]):
if not show.wantEpisode(season, curEpNum, seasonQual, downCurQuality): if not show.want_episode(season, curEpNum, seasonQual, downCurQuality):
allWanted = False allWanted = False
else: else:
anyWanted = True anyWanted = True
...@@ -460,7 +460,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up ...@@ -460,7 +460,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up
epObjs = [] epObjs = []
for curEpNum in allEps: for curEpNum in allEps:
for season in set([x.season for x in episodes]): for season in set([x.season for x in episodes]):
epObjs.append(show.getEpisode(season, curEpNum)) epObjs.append(show.get_episode(season, curEpNum))
bestSeasonResult.episodes = epObjs bestSeasonResult.episodes = epObjs
...@@ -497,7 +497,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up ...@@ -497,7 +497,7 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False, up
epObjs = [] epObjs = []
for curEpNum in allEps: for curEpNum in allEps:
for season in set([x.season for x in episodes]): for season in set([x.season for x in episodes]):
epObjs.append(show.getEpisode(season, curEpNum)) epObjs.append(show.get_episode(season, curEpNum))
bestSeasonResult.episodes = epObjs bestSeasonResult.episodes = epObjs
if MULTI_EP_RESULT in found_results[providerObj.name]: if MULTI_EP_RESULT in found_results[providerObj.name]:
......
...@@ -63,7 +63,7 @@ def new_episode_finder(): ...@@ -63,7 +63,7 @@ def new_episode_finder():
if air_time > curTime: if air_time > curTime:
continue continue
ep_obj = show.getEpisode(int(episode['season']), int(episode['episode'])) ep_obj = show.get_episode(int(episode['season']), int(episode['episode']))
with ep_obj.lock: with ep_obj.lock:
ep_obj.status = show.default_ep_status if ep_obj.season else SKIPPED ep_obj.status = show.default_ep_status if ep_obj.season else SKIPPED
sickrage.app.log.info('Setting status ({status}) for show airing today: {name} {special}'.format( sickrage.app.log.info('Setting status ({status}) for show airing today: {name} {special}'.format(
...@@ -72,4 +72,4 @@ def new_episode_finder(): ...@@ -72,4 +72,4 @@ def new_episode_finder():
special='(specials are not supported)' if not ep_obj.season else '', special='(specials are not supported)' if not ep_obj.season else '',
)) ))
ep_obj.saveToDB() ep_obj.save_to_db()
\ No newline at end of file \ No newline at end of file
...@@ -143,7 +143,7 @@ class BacklogSearcher(object): ...@@ -143,7 +143,7 @@ class BacklogSearcher(object):
if curStatus == DOWNLOADED and show.skip_downloaded: if curStatus == DOWNLOADED and show.skip_downloaded:
continue continue
epObj = show.getEpisode(int(result["season"]), int(result["episode"])) epObj = show.get_episode(int(result["season"]), int(result["episode"]))
wanted.append(epObj) wanted.append(epObj)
return wanted return wanted
......
...@@ -104,7 +104,7 @@ class DailySearcher(object): ...@@ -104,7 +104,7 @@ class DailySearcher(object):
if curStatus == DOWNLOADED and show.skip_downloaded: if curStatus == DOWNLOADED and show.skip_downloaded:
continue continue
epObj = show.getEpisode(int(dbData["season"]), int(dbData["episode"])) epObj = show.get_episode(int(dbData["season"]), int(dbData["episode"]))
epObj.wantedQuality = [i for i in allQualities if (i > curQuality and i != Quality.UNKNOWN)] epObj.wantedQuality = [i for i in allQualities if (i > curQuality and i != Quality.UNKNOWN)]
wanted.append(epObj) wanted.append(epObj)
......
...@@ -77,7 +77,7 @@ class FailedSnatchSearcher(object): ...@@ -77,7 +77,7 @@ class FailedSnatchSearcher(object):
if not show or show.paused: if not show or show.paused:
continue continue
ep_obj = show.getEpisode(int(episode['season']), int(episode['episode'])) ep_obj = show.get_episode(int(episode['season']), int(episode['episode']))
if isinstance(ep_obj, TVEpisode): if isinstance(ep_obj, TVEpisode):
curStatus, curQuality = Quality.splitCompositeStatus(ep_obj.status) curStatus, curQuality = Quality.splitCompositeStatus(ep_obj.status)
if curStatus not in {SNATCHED, SNATCHED_BEST, SNATCHED_PROPER}: if curStatus not in {SNATCHED, SNATCHED_BEST, SNATCHED_PROPER}:
......
...@@ -265,7 +265,7 @@ class ProperSearcher(object): ...@@ -265,7 +265,7 @@ class ProperSearcher(object):
continue continue
# make the result object # make the result object
result = curProper.provider.getResult([curProper.show.getEpisode(curProper.season, curProper.episode)]) result = curProper.provider.getResult([curProper.show.get_episode(curProper.season, curProper.episode)])
result.show = curProper.show result.show = curProper.show
result.url = curProper.url result.url = curProper.url
result.name = curProper.name result.name = curProper.name
......
...@@ -125,7 +125,7 @@ class SubtitleSearcher(object): ...@@ -125,7 +125,7 @@ class SubtitleSearcher(object):
sickrage.app.log.debug('Show not found') sickrage.app.log.debug('Show not found')
return return
epObj = showObj.getEpisode(int(epToSub["season"]), int(epToSub["episode"])) epObj = showObj.get_episode(int(epToSub["season"]), int(epToSub["episode"]))
if isinstance(epObj, str): if isinstance(epObj, str):
sickrage.app.log.debug('Episode not found') sickrage.app.log.debug('Episode not found')
return return
...@@ -133,7 +133,7 @@ class SubtitleSearcher(object): ...@@ -133,7 +133,7 @@ class SubtitleSearcher(object):
existing_subtitles = epObj.subtitles existing_subtitles = epObj.subtitles
try: try:
epObj.downloadSubtitles() epObj.download_subtitles()
except Exception as e: except Exception as e:
sickrage.app.log.debug('Unable to find subtitles') sickrage.app.log.debug('Unable to find subtitles')
sickrage.app.log.debug(str(e)) sickrage.app.log.debug(str(e))
......
...@@ -36,7 +36,7 @@ def setEpisodeToWanted(show, s, e): ...@@ -36,7 +36,7 @@ def setEpisodeToWanted(show, s, e):
""" """
Sets an episode to wanted, only if it is currently skipped Sets an episode to wanted, only if it is currently skipped
""" """
epObj = show.getEpisode(int(s), int(e)) epObj = show.get_episode(int(s), int(e))
if epObj: if epObj:
with epObj.lock: with epObj.lock:
if epObj.status != SKIPPED or epObj.airdate == date.fromordinal(1): if epObj.status != SKIPPED or epObj.airdate == date.fromordinal(1):
...@@ -46,7 +46,7 @@ def setEpisodeToWanted(show, s, e): ...@@ -46,7 +46,7 @@ def setEpisodeToWanted(show, s, e):
# figure out what segment the episode is in and remember it so we can backlog it # figure out what segment the episode is in and remember it so we can backlog it
epObj.status = WANTED epObj.status = WANTED
epObj.saveToDB() epObj.save_to_db()
sickrage.app.search_queue.put(BacklogQueueItem(show, [epObj])) sickrage.app.search_queue.put(BacklogQueueItem(show, [epObj]))
......
...@@ -286,9 +286,9 @@ class TVEpisode(object): ...@@ -286,9 +286,9 @@ class TVEpisode(object):
"""Look for subtitles files and refresh the subtitles property""" """Look for subtitles files and refresh the subtitles property"""
self.subtitles, save_subtitles = refresh_subtitles(self) self.subtitles, save_subtitles = refresh_subtitles(self)
if save_subtitles: if save_subtitles:
self.saveToDB() self.save_to_db()
def downloadSubtitles(self): def download_subtitles(self):
if not os.path.isfile(self.location): if not os.path.isfile(self.location):
sickrage.app.log.debug("%s: Episode file doesn't exist, can't download subtitles for S%02dE%02d" % sickrage.app.log.debug("%s: Episode file doesn't exist, can't download subtitles for S%02dE%02d" %
(self.show.indexerid, self.season or 0, self.episode or 0)) (self.show.indexerid, self.season or 0, self.episode or 0))
...@@ -302,7 +302,7 @@ class TVEpisode(object): ...@@ -302,7 +302,7 @@ class TVEpisode(object):
self.subtitles_searchcount += 1 if self.subtitles_searchcount else 1 self.subtitles_searchcount += 1 if self.subtitles_searchcount else 1
self.subtitles_lastsearch = datetime.datetime.now().strftime(dateTimeFormat) self.subtitles_lastsearch = datetime.datetime.now().strftime(dateTimeFormat)
self.saveToDB() self.save_to_db()
if newSubtitles: if newSubtitles:
subtitleList = ", ".join([name_from_code(newSub) for newSub in newSubtitles]) subtitleList = ", ".join([name_from_code(newSub) for newSub in newSubtitles])
...@@ -352,9 +352,9 @@ class TVEpisode(object): ...@@ -352,9 +352,9 @@ class TVEpisode(object):
'db': False} 'db': False}
for method, func in OrderedDict([ for method, func in OrderedDict([
('db', lambda: self.loadFromDB(season, episode)), ('db', lambda: self.load_from_db(season, episode)),
('nfo', lambda: self.loadFromNFO(self.location)), ('nfo', lambda: self.loadFromNFO(self.location)),
('indexer', lambda: self.loadFromIndexer(season, episode)), ('indexer', lambda: self.load_from_indexer(season, episode)),
]).items(): ]).items():
try: try:
...@@ -372,7 +372,7 @@ class TVEpisode(object): ...@@ -372,7 +372,7 @@ class TVEpisode(object):
# we failed to populate the episode # we failed to populate the episode
raise EpisodeNotFoundException("Couldn't find episode S%02dE%02d" % (season or 0, episode or 0)) raise EpisodeNotFoundException("Couldn't find episode S%02dE%02d" % (season or 0, episode or 0))
def loadFromDB(self, season, episode): def load_from_db(self, season, episode):
sickrage.app.log.debug("%s: Loading episode details from DB for episode %s S%02dE%02d" % ( sickrage.app.log.debug("%s: Loading episode details from DB for episode %s S%02dE%02d" % (
self.show.indexerid, self.show.name, season or 0, episode or 0)) self.show.indexerid, self.show.name, season or 0, episode or 0))
...@@ -427,7 +427,7 @@ class TVEpisode(object): ...@@ -427,7 +427,7 @@ class TVEpisode(object):
return True return True
def loadFromIndexer(self, season=None, episode=None, cache=True, tvapi=None, cachedSeason=None): def load_from_indexer(self, season=None, episode=None, cache=True, tvapi=None, cachedSeason=None):
indexer_name = IndexerApi(self.indexer).name indexer_name = IndexerApi(self.indexer).name
season = (self.season, season)[season is not None] season = (self.season, season)[season is not None]
...@@ -679,7 +679,7 @@ class TVEpisode(object): ...@@ -679,7 +679,7 @@ class TVEpisode(object):
self.createThumbnail(force) self.createThumbnail(force)
if self.checkForMetaFiles(): if self.checkForMetaFiles():
self.saveToDB() self.save_to_db()
def createNFO(self, force=False): def createNFO(self, force=False):
...@@ -705,7 +705,7 @@ class TVEpisode(object): ...@@ -705,7 +705,7 @@ class TVEpisode(object):
"Deleting %s S%02dE%02d from the DB" % (self.show.name, self.season or 0, self.episode or 0)) "Deleting %s S%02dE%02d from the DB" % (self.show.name, self.season or 0, self.episode or 0))
# remove myself from the show dictionary