本文整理汇总了Python中sickrage.show.Show.Show.find方法的典型用法代码示例。如果您正苦于以下问题:Python Show.find方法的具体用法?Python Show.find怎么用?Python Show.find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sickrage.show.Show.Show
的用法示例。
在下文中一共展示了Show.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_scene_absolute_numbering
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, fallback_to_xem=True):
"""
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
returns the TVDB numbering.
(so the return values will always be set)
:param indexer_id: int
;param absolute_number: int
: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)
"""
if indexer_id is None or absolute_number is None:
return absolute_number
indexer_id = int(indexer_id)
indexer = int(indexer)
showObj = Show.find(sickbeard.showList, indexer_id)
if showObj and not showObj.is_scene:
return absolute_number
result = find_scene_absolute_numbering(indexer_id, indexer, absolute_number)
if result:
return result
else:
if fallback_to_xem:
xem_result = find_xem_absolute_numbering(indexer_id, indexer, absolute_number)
if xem_result:
return xem_result
return absolute_number
示例2: getEpisode
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def getEpisode(show, season=None, episode=None, absolute=None):
""" Get a specific episode object based on show, season and episode number
:param show: Season number
:param season: Season number
:param season: Season number
:param absolute: Optional if the episode number is a scene absolute number
:return: episode object
"""
if show is None:
return "Invalid show parameters"
show_obj = Show.find(sickbeard.showList, int(show))
if show_obj is None:
return "Invalid show paramaters"
if absolute:
ep_obj = show_obj.get_episode(absolute_number=absolute)
elif season and episode:
ep_obj = show_obj.get_episode(season, episode)
else:
return "Invalid paramaters"
if ep_obj is None:
return "Episode couldn't be retrieved"
return ep_obj
示例3: getEpisodes
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def getEpisodes(search_thread, searchstatus):
""" Get all episodes located in a search thread with a specific status """
results = []
# NOTE!: Show.find called with just indexerid!
show_obj = Show.find(sickbeard.showList, int(search_thread.show.indexerid))
if not show_obj:
if not search_thread.show.is_recently_deleted:
logger.log(u'No Show Object found for show with indexerID: {0}'.
format(search_thread.show.indexerid), logger.ERROR)
return results
if not isinstance(search_thread.segment, list):
search_thread.segment = [search_thread.segment]
for ep_obj in search_thread.segment:
ep = show_obj.get_episode(ep_obj.season, ep_obj.episode)
results.append({
'show': show_obj.indexerid,
'episode': ep.episode,
'episodeindexid': ep.indexerid,
'season': ep.season,
'searchstatus': searchstatus,
'status': statusStrings[ep.status],
'quality': getQualityClass(ep),
'overview': Overview.overviewStrings[show_obj.get_overview(ep.status)],
})
return results
示例4: addDefaultShow
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def addDefaultShow(indexer, indexer_id, name, status):
"""
Adds a new show with the default settings
"""
if not Show.find(sickbeard.showList, int(indexer_id)):
logger.log(u"Adding show " + str(indexer_id))
root_dirs = sickbeard.ROOT_DIRS.split('|')
try:
location = root_dirs[int(root_dirs[0]) + 1]
except Exception:
location = None
if location:
showPath = ek(os.path.join, location, sanitize_filename(name))
dir_exists = helpers.makeDir(showPath)
if not dir_exists:
logger.log(u"Unable to create the folder %s , can't add the show" % showPath, logger.WARNING)
return
else:
helpers.chmodAsParent(showPath)
sickbeard.showQueueScheduler.action.addShow(int(indexer), int(indexer_id), showPath,
default_status=status,
quality=int(sickbeard.QUALITY_DEFAULT),
flatten_folders=int(sickbeard.FLATTEN_FOLDERS_DEFAULT),
paused=sickbeard.TRAKT_START_PAUSED,
default_status_after=status)
else:
logger.log(u"There was an error creating the show, no root directory setting found", logger.WARNING)
return
示例5: find_propers
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def find_propers(self, search_date=None):
results = []
db = DBConnection()
placeholder = ','.join([str(x) for x in Quality.DOWNLOADED + Quality.SNATCHED + Quality.SNATCHED_BEST])
sql_results = db.select(
'SELECT s.show_name, e.showid, e.season, e.episode, e.status, e.airdate'
' FROM tv_episodes AS e'
' INNER JOIN tv_shows AS s ON (e.showid = s.indexer_id)'
' WHERE e.airdate >= ' + str(search_date.toordinal()) +
' AND e.status IN (' + placeholder + ')'
)
for result in sql_results or []:
show = Show.find(sickbeard.showList, int(result['showid']))
if show:
episode = show.getEpisode(result['season'], result['episode'])
for term in self.proper_strings:
search_strings = self._get_episode_search_strings(episode, add_string=term)
for item in self.search(search_strings[0]):
title, url = self._get_title_and_url(item)
results.append(Proper(title, url, datetime.today(), show))
return results
示例6: backlogShow
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def backlogShow(self, indexer_id):
show_obj = Show.find(sickbeard.showList, int(indexer_id))
if show_obj:
sickbeard.backlogSearchScheduler.action.searchBacklog([show_obj])
return self.redirect('/manage/backlogOverview/')
示例7: add_show
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def add_show(indexer, indexer_id, show_name, status):
"""
Adds a new show with the default settings
"""
if not Show.find(sickbeard.showList, int(indexer_id)):
root_dirs = sickbeard.ROOT_DIRS.split('|')
location = root_dirs[int(root_dirs[0]) + 1] if root_dirs else None
if location:
show_path = ek(os.path.join, location, show_name)
logger.log(u"Adding show '{}' with ID: '{}' in location: '{}'".format(show_name, indexer_id, show_path))
dir_exists = helpers.makeDir(show_path)
if not dir_exists:
logger.log(u"Unable to create the folder {}. Unable to add the show {}".format(show_path, show_name), logger.WARNING)
return
else:
logger.log(u"Creating the folder '{}'".format(show_path), logger.DEBUG)
helpers.chmodAsParent(show_path)
sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_path,
default_status=status,
quality=int(sickbeard.QUALITY_DEFAULT),
flatten_folders=int(sickbeard.FLATTEN_FOLDERS_DEFAULT),
paused=sickbeard.TRAKT_START_PAUSED,
default_status_after=status)
else:
logger.log(u"There was an error creating the show, no root directory setting found", logger.WARNING)
return
示例8: fetch_trakt_shows
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def fetch_trakt_shows(self):
if not self.show_watchlist:
logger.log(u"No shows found in your watchlist, aborting watchlist update", logger.DEBUG)
else:
indexer = int(sickbeard.TRAKT_DEFAULT_INDEXER)
trakt_id = sickbeard.indexerApi(indexer).config['trakt_id']
for watchlisted_show in self.show_watchlist[trakt_id]:
indexer_id = int(watchlisted_show)
show_obj = self.show_watchlist[trakt_id][watchlisted_show]
if show_obj['year'] and show_obj['slug'].endswith(str(show_obj['year'])):
show_name = '{} ({})'.format(show_obj['title'], show_obj['year'])
else:
show_name = show_obj['title']
if int(sickbeard.TRAKT_METHOD_ADD) != 2:
self.add_show(indexer, indexer_id, show_name, SKIPPED)
else:
self.add_show(indexer, indexer_id, show_name, WANTED)
if int(sickbeard.TRAKT_METHOD_ADD) == 1:
new_show = Show.find(sickbeard.showList, indexer_id)
if new_show:
setEpisodeToWanted(new_show, 1, 1)
else:
self.todoWanted.append(indexer_id, 1, 1)
示例9: find_propers
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def find_propers(self, proper_candidates):
results = []
for proper_candidate in proper_candidates:
show_obj = Show.find(sickbeard.showList, int(proper_candidate[b'showid'])) if proper_candidate[b'showid'] else None
if show_obj:
episode_obj = show_obj.get_episode(proper_candidate[b'season'], proper_candidate[b'episode'])
for term in self.proper_strings:
search_strings = self._get_episode_search_strings(episode_obj, add_string=term)
for item in self.search(search_strings[0], ep_obj=episode_obj):
title, url = self._get_title_and_url(item)
seeders, leechers = self._get_result_info(item)
size = self._get_size(item)
pubdate = self._get_pubdate(item)
torrent_hash = self._get_hash(item)
# This will be retrived from parser
proper_tags = None
results.append(Proper(title, url, datetime.today(), show_obj, seeders, leechers, size, pubdate, torrent_hash, proper_tags))
return results
示例10: set_scene_numbering
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def set_scene_numbering(indexer_id, indexer, season=None, episode=None, # pylint:disable=too-many-arguments
absolute_number=None, sceneSeason=None,
sceneEpisode=None, sceneAbsolute=None):
"""
Set scene numbering for a season/episode.
To clear the scene numbering, leave both sceneSeason and sceneEpisode as None.
"""
if indexer_id is None:
return
indexer_id = int(indexer_id)
indexer = int(indexer)
main_db_con = db.DBConnection()
if season and episode:
main_db_con.action(
"INSERT OR IGNORE INTO scene_numbering (indexer, indexer_id, season, episode) VALUES (?,?,?,?)",
[indexer, indexer_id, season, episode])
main_db_con.action(
"UPDATE scene_numbering SET scene_season = ?, scene_episode = ? WHERE indexer = ? and indexer_id = ? and season = ? and episode = ?",
[sceneSeason, sceneEpisode, indexer, indexer_id, season, episode])
elif absolute_number:
main_db_con.action(
"INSERT OR IGNORE INTO scene_numbering (indexer, indexer_id, absolute_number) VALUES (?,?,?)",
[indexer, indexer_id, absolute_number])
main_db_con.action(
"UPDATE scene_numbering SET scene_absolute_number = ? WHERE indexer = ? and indexer_id = ? and absolute_number = ?",
[sceneAbsolute, indexer, indexer_id, absolute_number])
# Reload data from DB so that cache and db are in sync
show = Show.find(sickbeard.showList, indexer_id)
show.flushEpisodes()
示例11: find_propers
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def find_propers(self, search_date=datetime.datetime.today()):
"""
Searches providers for PROPER or REPACK releases
Returns a list of objects of type classes.Proper
"""
results = []
myDB = db.DBConnection()
sqlResults = myDB.select(
'SELECT s.show_name, e.showid, e.season, e.episode, e.status, e.airdate FROM tv_episodes AS e' +
' INNER JOIN tv_shows AS s ON (e.showid = s.indexer_id)' +
' WHERE e.airdate >= ' + str(search_date.toordinal()) +
' AND (e.status IN (' + ','.join([str(x) for x in Quality.DOWNLOADED]) + ')' +
' OR (e.status IN (' + ','.join([str(x) for x in Quality.SNATCHED]) + ')))'
)
if not sqlResults:
return results
for sqlshow in sqlResults:
self.show = Show.find(sickbeard.showList, int(sqlshow["showid"]))
if self.show:
curEp = self.show.getEpisode(sqlshow["season"], sqlshow["episode"])
searchStrings = self._get_episode_search_strings(curEp, add_string='PROPER|REPACK')
for searchString in searchStrings:
for item in self.search(searchString):
title, url = self._get_title_and_url(item)
if re.match(r'.*(REPACK|PROPER).*', title, re.I):
results.append(classes.Proper(title, url, datetime.datetime.today(), self.show))
return results
示例12: updateShows
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def updateShows(self):
logger.log(u"SHOW_WATCHLIST::CHECK::START - Trakt Show Watchlist", logger.DEBUG)
if not len(self.ShowWatchlist):
logger.log(u"No shows found in your watchlist, aborting watchlist update", logger.DEBUG)
return
indexer = int(sickbeard.TRAKT_DEFAULT_INDEXER)
trakt_id = sickbeard.indexerApi(indexer).config['trakt_id']
for show_el in self.ShowWatchlist[trakt_id]:
indexer_id = int(str(show_el))
show = self.ShowWatchlist[trakt_id][show_el]
# logger.log(u"Checking Show: %s %s %s" % (trakt_id, indexer_id, show['title']),logger.DEBUG)
if int(sickbeard.TRAKT_METHOD_ADD) != 2:
self.addDefaultShow(indexer, indexer_id, show['title'], SKIPPED)
else:
self.addDefaultShow(indexer, indexer_id, show['title'], WANTED)
if int(sickbeard.TRAKT_METHOD_ADD) == 1:
newShow = Show.find(sickbeard.showList, indexer_id)
if newShow is not None:
setEpisodeToWanted(newShow, 1, 1)
else:
self.todoWanted.append((indexer_id, 1, 1))
logger.log(u"SHOW_WATCHLIST::CHECK::FINISH - Trakt Show Watchlist", logger.DEBUG)
示例13: test_find
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def test_find(self):
"""
Test find
"""
sickbeard.QUALITY_DEFAULT = Quality.FULLHDTV
sickbeard.showList = []
show123 = TestTVShow(0, 123)
show456 = TestTVShow(0, 456)
show789 = TestTVShow(0, 789)
shows = [show123, show456, show789]
shows_duplicate = shows + shows
test_cases = {
(False, None): None,
(False, ''): None,
(False, '123'): None,
(False, 123): None,
(False, 12.3): None,
(True, None): None,
(True, ''): None,
(True, '123'): None,
(True, 123): show123,
(True, 12.3): None,
(True, 456): show456,
(True, 789): show789,
}
unicode_test_cases = {
(False, ''): None,
(False, '123'): None,
(True, ''): None,
(True, '123'): None,
}
for tests in test_cases, unicode_test_cases:
for ((use_shows, indexer_id), result) in six.iteritems(tests):
if use_shows:
self.assertEqual(Show.find(shows, indexer_id), result)
else:
self.assertEqual(Show.find(None, indexer_id), result)
with self.assertRaises(MultipleShowObjectsException):
Show.find(shows_duplicate, 456)
示例14: get_show
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def get_show(self):
"""
:return: The show object associated with ``self.indexer_id`` or ``None``
"""
try:
return Show.find(sickbeard.showList, self.indexer_id)
except MultipleShowObjectsException:
return None
示例15: updateWatchedData
# 需要导入模块: from sickrage.show.Show import Show [as 别名]
# 或者: from sickrage.show.Show.Show import find [as 别名]
def updateWatchedData(self):
try:
response = self.trakt_api.traktRequest("users/me/history/episodes")
changes = dict()
myDB = db.DBConnection()
for data in response:
show_id = None
if not data['show']['ids']["tvdb"] is None:
show_id = data['show']['ids']["tvdb"]
elif not data['show']['ids']["tvrage"] is None:
show_id = data['show']['ids']["tvrage"]
else:
logger.log(u"Could not retrieve show_id from trakt history", logger.WARNING)
continue
show_name = data["show"]["title"]
season = data["episode"]["season"]
episode = data["episode"]["number"]
watched = time.mktime(parser.parse(data["watched_at"]).timetuple())
cursor = myDB.action("UPDATE tv_episodes SET last_watched=? WHERE showid=? AND season=? AND episode=? AND (last_watched IS NULL OR last_watched < ?)", [watched, show_id, season, episode, watched])
if cursor.rowcount > 0:
changes[show_name] = changes.get(show_name, 0) + 1
logger.log("Updated " + show_name + ", episode " + str(season) + "x" + str(episode) + ": Episode was watched at " + str(watched))
show = Show.find(sickbeard.showList, int(show_id))
show.last_seen = max(show.last_seen, watched)
message = "Watched episodes synchronization complete: ";
if (len(changes) == 0):
message += "No changes detected."
else:
message += "Marked as watched "
first = True;
for show_name in changes:
if (not first):
message += ", "
message += str(changes[show_name]) + " episodes of " + show_name
first = False;
logger.log(message)
self._updateAllShowsNextEpisodeData()
except traktException as e:
logger.log(u"Could not connect to trakt service, cannot synch Watched Data: %s" % ex(e), logger.ERROR)