本文整理汇总了Python中sickbeard.notifiers.notify_snatch函数的典型用法代码示例。如果您正苦于以下问题:Python notify_snatch函数的具体用法?Python notify_snatch怎么用?Python notify_snatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了notify_snatch函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
elif result.resultType == "torrent":
dlResult = _downloadResult(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if dlResult == False:
return False
history.logSnatch(result)
# don't notify when we re-download an episode
for curEpObj in result.episodes:
with curEpObj.lock:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.saveToDB()
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj.prettyName(True))
return True
开发者ID:Hydrokugal,项目名称:Sick-Beard,代码行数:31,代码来源:search.py
示例2: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
dlResult = nzbget.sendNZB(result)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# TORRENTs can be sent to clients or saved to disk
elif result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
result.content = result.provider.getURL(result.url) if not result.url.startswith('magnet') else None
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
dlResult = client.sendTORRENT(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if dlResult is False:
return False
history.logSnatch(result)
# don't notify when we re-download an episode
for curEpObj in result.episodes:
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj.prettyName())
with curEpObj.lock:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.saveToDB()
return True
开发者ID:fldc,项目名称:Sick-Beard,代码行数:58,代码来源:search.py
示例3: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
# NZBs can be sent straight to SAB or saved to disk
if hasattr(result, "resultType"):
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
dlResult = nzbget.sendNZB(result)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# TORRENTs can be sent to clients or saved to disk
elif result.resultType in ("torrent", "torrentdata"):
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
if hasattr(result, "extraInfo") and result.resultType == "torrentdata":
result.content = result.extraInfo[0]
dlResult = client.sendTORRENT(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if dlResult == False:
return False
history.logSnatch(result)
# don't notify when we re-download an episode
for curEpObj in result.episodes:
with curEpObj.lock:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.audio_langs = result.audio_lang
curEpObj.saveToDB()
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj.prettyName())
return True
else:
return False
开发者ID:stven,项目名称:Sick-Beard,代码行数:56,代码来源:search.py
示例4: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
dlResult = nzbget.sendNZB(result)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# torrents are always saved to disk
elif result.resultType == "torrent":
dlResult = _downloadResult(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if dlResult == False:
return False
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
failed_history.logSnatch(result)
# don't notify when we re-download an episode
for curEpObj in result.episodes:
with curEpObj.lock:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.saveToDB()
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj.prettyName())
return True
开发者ID:jetskijoe,项目名称:Sick-Beard,代码行数:48,代码来源:search.py
示例5: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
if result is None:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
if re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', result.name, re.I) != None:
endStatus = SNATCHED_PROPER
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
is_proper = True if endStatus == SNATCHED_PROPER else False
dlResult = nzbget.sendNZB(result, is_proper)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# TORRENTs can be sent to clients or saved to disk
elif result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
if result.content or result.url.startswith('magnet'):
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
dlResult = client.sendTORRENT(result)
else:
logger.log(u"Torrent file content is empty", logger.ERROR)
dlResult = False
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
sql_l = []
trakt_data = []
for curEpObj in result.episodes:
with curEpObj.lock:
if isFirstBestMatch(result):
curEpObj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.audio_langs = result.audio_lang
sql_l.append(curEpObj.get_sql())
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN') + " from " + result.provider.name)
trakt_data.append((curEpObj.season, curEpObj.episode))
data = notifiers.trakt_notifier.trakt_episode_data_generate(trakt_data)
if sickbeard.USE_TRAKT and sickbeard.TRAKT_SYNC_WATCHLIST:
logger.log(u"Add episodes, showid: indexerid " + str(result.show.indexerid) + ", Title " + str(result.show.name) + " to Traktv Watchlist", logger.DEBUG)
if data:
notifiers.trakt_notifier.update_watchlist(result.show, data_episode=data, update="add")
if len(sql_l) > 0:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
if sickbeard.UPDATE_SHOWS_ON_SNATCH and not sickbeard.showQueueScheduler.action.isBeingUpdated(result.show) and result.show.status == "Continuing":
try:
sickbeard.showQueueScheduler.action.updateShow(result.show, True)
except exceptions.CantUpdateException as e:
logger.log("Unable to update show: {0}".format(str(e)),logger.DEBUG)
return True
开发者ID:WuzUrDaddy,项目名称:SickRageVF,代码行数:98,代码来源:search.py
示例6: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED): # pylint: disable=too-many-branches, too-many-statements
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
:param result: SearchResult instance to be snatched.
:param endStatus: the episode status that should be used for the episode object once it's snatched.
:return: boolean, True on success
"""
if result is None:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
endStatus = SNATCHED_PROPER if re.search(r'\b(proper|repack|real)\b', result.name, re.I) else endStatus
if result.url.startswith('magnet') or result.url.endswith('torrent'):
result.resultType = 'torrent'
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
is_proper = True if endStatus == SNATCHED_PROPER else False
dlResult = nzbget.sendNZB(result, is_proper)
elif sickbeard.NZB_METHOD == "download_station":
client = clients.getClientInstance(sickbeard.NZB_METHOD)(
sickbeard.SYNOLOGY_DSM_HOST, sickbeard.SYNOLOGY_DSM_USERNAME, sickbeard.SYNOLOGY_DSM_PASSWORD)
dlResult = client.sendNZB(result)
else:
logger.log("Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# Torrents can be sent to clients or saved to disk
elif result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
if not result.content and not result.url.startswith('magnet'):
if result.provider.login():
result.content = result.provider.get_url(result.url, returns='content')
if result.content or result.url.startswith('magnet'):
client = clients.getClientInstance(sickbeard.TORRENT_METHOD)()
dlResult = client.sendTORRENT(result)
else:
logger.log("Torrent file content is empty", logger.WARNING)
dlResult = False
else:
logger.log("Unknown result type, unable to download it ({0!r})".format(result.resultType), logger.ERROR)
dlResult = False
if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
sql_l = []
trakt_data = []
for curEpObj in result.episodes:
with curEpObj.lock:
if isFirstBestMatch(result):
curEpObj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
sql_l.append(curEpObj.get_sql())
if curEpObj.status not in Quality.DOWNLOADED:
try:
notifiers.notify_snatch("{0} from {1}".format(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN'), result.provider.name)) # pylint: disable=protected-access
except Exception:
# Without this, when notification fail, it crashes the snatch thread and SR will
# keep snatching until notification is sent
logger.log("Failed to send snatch notification", logger.DEBUG)
trakt_data.append((curEpObj.season, curEpObj.episode))
data = notifiers.trakt_notifier.trakt_episode_data_generate(trakt_data)
if sickbeard.USE_TRAKT and sickbeard.TRAKT_SYNC_WATCHLIST:
logger.log("Add episodes, showid: indexerid " + str(result.show.indexerid) + ", Title " + str(result.show.name) + " to Traktv Watchlist", logger.DEBUG)
if data:
notifiers.trakt_notifier.update_watchlist(result.show, data_episode=data, update="add")
#.........这里部分代码省略.........
开发者ID:Zelgadis87,项目名称:SickRage,代码行数:101,代码来源:search.py
示例7: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
if result is None: return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
if re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', result.name, re.I) != None:
endStatus = SNATCHED_PROPER
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
is_proper = True if endStatus == SNATCHED_PROPER else False
dlResult = nzbget.sendNZB(result, is_proper)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# TORRENTs can be sent to clients or saved to disk
elif result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
result.content = result.provider.getURL(result.url) if not result.url.startswith('magnet') else None
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
dlResult = client.sendTORRENT(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
else:
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
for curEpObj in result.episodes:
with curEpObj.lock:
if isFirstBestMatch(result):
curEpObj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.saveToDB()
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
return True
开发者ID:Weiry,项目名称:SickRage,代码行数:71,代码来源:search.py
示例8: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
if result is None: return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
if re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', result.name, re.I) != None:
endStatus = SNATCHED_PROPER
if result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
# Sets per provider seed ratio
result.ratio = result.provider.seedRatio()
result.content = result.provider.getURL(result.url) if not result.url.startswith('magnet') else None
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
dlResult = client.sendTORRENT(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
sql_l = []
for curEpObj in result.episodes:
with curEpObj.lock:
if isFirstBestMatch(result):
curEpObj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
sql_l.append(curEpObj.get_sql())
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
if sql_l:
myDB = db.DBConnection()
myDB.mass_action(sql_l)
return True
开发者ID:BeegorMif,项目名称:HTPC-Manager,代码行数:66,代码来源:search.py
示例9: str
running_torrent_ptr["status"] = str(s.state)
running_torrent_ptr["name"] = name
running_torrent_ptr["total_size"] = i.total_size()
running_torrent_ptr["paused"] = s.paused
running_torrent_ptr["error"] = s.error
if s.state in [
lt.torrent_status.seeding,
lt.torrent_status.downloading,
lt.torrent_status.finished,
lt.torrent_status.downloading_metadata,
]:
logger.log(
u'Torrent "%s" has state "%s" (%s), interpreting as snatched' % (name, s.state, repr(s.state)),
logger.MESSAGE,
)
notifiers.notify_snatch(u"Torrent " + name + u" interpreted as snatched")
return True
elif s.state is lt.torrent_status.downloading_metadata and torrent.startswith("magnet:"):
# if it's a magnet, 'downloading_metadata' is considered a success
logger.log(u"Torrent has state downloading_metadata, interpreting as snatched", logger.MESSAGE)
notifiers.notify_snatch(u"Torrent " + name + u" interpreted as snatched")
return True
else:
# no metadata and not a magnet? Definitely not started yet then!
pass
# check for timeout
if time.time() - start_time > TORRENT_START_WAIT_TIMEOUT_SECS:
logger.log(
u"Torrent has failed to start within timeout %d secs. Removing"
% (TORRENT_START_WAIT_TIMEOUT_SECS),
开发者ID:phlunk3,项目名称:Sick-Beard,代码行数:31,代码来源:downloader.py
示例10: snatchEpisode
def snatchEpisode(result): # pylint: disable=too-many-branches, too-many-statements
"""
Internal logic necessary to actually "snatch" a result that has been found.
:param result: SearchResult instance to be snatched.
:return: boolean, True on success
"""
if result is None:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
is_proper = False
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
if result.proper_tags:
logger.log(u'Found proper tags for {0}. Snatching as PROPER'.format(result.name), logger.DEBUG)
is_proper = True
endStatus = SNATCHED_PROPER
else:
endStatus = SNATCHED
if result.url.startswith('magnet') or result.url.endswith('torrent'):
result.resultType = 'torrent'
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
dlResult = nzbget.sendNZB(result, is_proper)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
# Torrents can be sent to clients or saved to disk
elif result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
if not result.content and not result.url.startswith('magnet'):
if result.provider.login():
result.content = result.provider.get_url(result.url, returns='content')
if result.content or result.url.startswith('magnet'):
client = clients.get_client_instance(sickbeard.TORRENT_METHOD)()
dlResult = client.send_torrent(result)
else:
logger.log(u"Torrent file content is empty", logger.WARNING)
dlResult = False
else:
logger.log(u"Unknown result type, unable to download it (%r)" % result.resultType, logger.ERROR)
dlResult = False
if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
sql_l = []
trakt_data = []
for curEpObj in result.episodes:
with curEpObj.lock:
if isFirstBestMatch(result):
curEpObj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
sql_l.append(curEpObj.get_sql())
if curEpObj.status not in Quality.DOWNLOADED:
try:
notify_message = curEpObj.formatted_filename('%SN - %Sx%0E - %EN - %QN')
if all([sickbeard.SEEDERS_LEECHERS_IN_NOTIFY, result.seeders not in (-1, None),
result.leechers not in (-1, None)]):
notifiers.notify_snatch("{0} with {1} seeders and {2} leechers from {3}".format
(notify_message, result.seeders, result.leechers, result.provider.name), is_proper)
else:
notifiers.notify_snatch("{0} from {1}".format(notify_message, result.provider.name), is_proper)
except Exception:
# Without this, when notification fail, it crashes the snatch thread and Medusa will
# keep snatching until notification is sent
logger.log(u"Failed to send snatch notification. Error: {0}".format(e), logger.DEBUG)
trakt_data.append((curEpObj.season, curEpObj.episode))
data = notifiers.trakt_notifier.trakt_episode_data_generate(trakt_data)
if sickbeard.USE_TRAKT and sickbeard.TRAKT_SYNC_WATCHLIST:
#.........这里部分代码省略.........
开发者ID:Thraxis,项目名称:pymedusa,代码行数:101,代码来源:search.py
示例11: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
dlResult = nzbget.sendNZB(result)
else:
logger.log(u"Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR)
dlResult = False
elif result.resultType == "torrent":
#this is required for providers that use torrent cache (more than one possibility)
#like Torrentz. Maybe convert result.url to an array in the future.
if result.url.count(";") > 0:
allUrls = result.url.split(";", 3)
for url in allUrls:
try:
urllib2.urlopen(url)
result.url = url
break
except Exception:
continue
# torrents are always saved to disk
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
# torrents are sending to torrent client
elif sickbeard.TORRENT_METHOD == "utorrent":
dlResult = utorrent.sendTORRENT(result)
elif sickbeard.TORRENT_METHOD == "transmission":
dlResult = transmission.sendTORRENT(result)
elif sickbeard.TORRENT_METHOD == "downloadstation":
dlResult = downloadstation.sendDownload(result)
elif sickbeard.TORRENT_METHOD == "deluge":
dlResult = deluge.sendTORRENT(result)
else:
logger.log(u"Unknown result type, unable to download it", logger.ERROR)
dlResult = False
if dlResult == False:
return False
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
for curEpObj in result.episodes:
with curEpObj.lock:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
curEpObj.saveToDB()
if curEpObj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(curEpObj.prettyName())
return True
开发者ID:mptrs,项目名称:Sick-Beard,代码行数:70,代码来源:search.py
示例12: snatch_episode
#.........这里部分代码省略.........
if None is result:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for cur_ep in result.episodes:
if datetime.date.today() - cur_ep.airdate <= datetime.timedelta(days=7):
result.priority = 1
if 0 < result.properlevel:
end_status = SNATCHED_PROPER
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ('nzb', 'nzbdata'):
if 'blackhole' == sickbeard.NZB_METHOD:
dl_result = _download_result(result)
elif 'sabnzbd' == sickbeard.NZB_METHOD:
dl_result = sab.send_nzb(result)
elif 'nzbget' == sickbeard.NZB_METHOD:
dl_result = nzbget.send_nzb(result)
else:
logger.log(u'Unknown NZB action specified in config: %s' % sickbeard.NZB_METHOD, logger.ERROR)
dl_result = False
# TORRENTs can be sent to clients or saved to disk
elif 'torrent' == result.resultType:
if not result.url.startswith('magnet') and None is not result.get_data_func:
result.url = result.get_data_func(result.url)
result.get_data_func = None # consume only once
if not result.url:
return False
if not result.content and result.url.startswith('magnet-'):
if sickbeard.TORRENT_DIR:
filepath = ek.ek(os.path.join, sickbeard.TORRENT_DIR, 'files.txt')
try:
with open(filepath, 'a') as fh:
result.url = result.url[7:]
fh.write('"%s"\t"%s"\n' % (result.url, sickbeard.TV_DOWNLOAD_DIR))
dl_result = True
except IOError:
logger.log(u'Failed to write to %s' % filepath, logger.ERROR)
return False
else:
logger.log(u'Need to set a torrent blackhole folder', logger.ERROR)
return False
# torrents are saved to disk when blackhole mode
elif 'blackhole' == sickbeard.TORRENT_METHOD:
dl_result = _download_result(result)
else:
# make sure we have the torrent file content
if not result.content and not result.url.startswith('magnet'):
result.content = result.provider.get_url(result.url)
if result.provider.should_skip() or not result.content:
logger.log(u'Torrent content failed to download from %s' % result.url, logger.ERROR)
return False
# Snatches torrent with client
client = clients.get_client_instance(sickbeard.TORRENT_METHOD)()
dl_result = client.send_torrent(result)
if getattr(result, 'cache_file', None):
helpers.remove_file_failed(result.cache_file)
else:
logger.log(u'Unknown result type, unable to download it', logger.ERROR)
dl_result = False
if not dl_result:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.add_snatched(result)
ui.notifications.message(u'Episode snatched', result.name)
history.log_snatch(result)
# don't notify when we re-download an episode
sql_l = []
update_imdb_data = True
for cur_ep_obj in result.episodes:
with cur_ep_obj.lock:
if is_first_best_match(cur_ep_obj.status, result):
cur_ep_obj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
cur_ep_obj.status = Quality.compositeStatus(end_status, result.quality)
item = cur_ep_obj.get_sql()
if None is not item:
sql_l.append(item)
if cur_ep_obj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(cur_ep_obj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
update_imdb_data = update_imdb_data and cur_ep_obj.show.load_imdb_info()
if 0 < len(sql_l):
my_db = db.DBConnection()
my_db.mass_action(sql_l)
return True
开发者ID:JackDandy,项目名称:SickGear,代码行数:101,代码来源:search.py
示例13: snatchEpisode
def snatchEpisode(result, endStatus=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
:param result: SearchResult instance to be snatched.
:param endStatus: the episode status that should be used for the episode object once it's snatched.
:return: boolean, True on success
"""
if result is None:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for curEp in result.episodes:
if datetime.date.today() - curEp.airdate <= datetime.timedelta(days=7):
result.priority = 1
if re.search(r'(^|[\. _-])(proper|repack)([\. _-]|$)', result.name, re.I) != None:
endStatus = SNATCHED_PROPER
if result.url.startswith('magnet') or result.url.endswith('torrent'):
result.resultType = 'torrent'
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ("nzb", "nzbdata"):
if sickbeard.NZB_METHOD == "blackhole":
dlResult = _downloadResult(result)
elif sickbeard.NZB_METHOD == "sabnzbd":
dlResult = sab.sendNZB(result)
elif sickbeard.NZB_METHOD == "nzbget":
is_proper = True if endStatus == SNATCHED_PROPER else False
dlResult = nzbget.sendNZB(result, is_proper)
else:
logging.error("Unknown NZB action specified in config: " + sickbeard.NZB_METHOD)
dlResult = False
# TORRENTs can be sent to clients or saved to disk
elif result.resultType == "torrent":
# torrents are saved to disk when blackhole mode
if sickbeard.TORRENT_METHOD == "blackhole":
dlResult = _downloadResult(result)
else:
if not result.content and not result.url.startswith('magnet'):
result.content = result.provider.getURL(result.url, needBytes=True)
if result.content or result.url.startswith('magnet'):
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
dlResult = client.sendTORRENT(result)
else:
logging.warning("Torrent file content is empty")
dlResult = False
else:
logging.error("Unknown result type, unable to download it (%r)" % result.resultType)
dlResult = False
if not dlResult:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
ui.notifications.message('Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
sql_l = []
trakt_data = []
for curEpObj in result.episodes:
with curEpObj.lock:
if isFirstBestMatch(result):
curEpObj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
curEpObj.status = Quality.compositeStatus(endStatus, result.quality)
sql_l.append(curEpObj.get_sql())
if curEpObj.status not in Quality.DOWNLOADED:
try:
notifiers.notify_snatch(
curEpObj._format_pattern('%SN - %Sx%0E - %EN - %QN') + " from " + result.provider.name)
except:
# Without this, when notification fail, it crashes the snatch thread and SR will
# keep snatching until notification is sent
logging.debug("Failed to send snatch notification")
trakt_data.append((curEpObj.season, curEpObj.episode))
data = notifiers.trakt_notifier.trakt_episode_data_generate(trakt_data)
if sickbeard.USE_TRAKT and sickbeard.TRAKT_SYNC_WATCHLIST:
logging.debug("Add episodes, showid: indexerid " + str(result.show.indexerid) + ", Title " + str(
result.show.name) + " to Traktv Watchlist")
if data:
notifiers.trakt_notifier.update_watchlist(result.show, data_episode=data, update="add")
if len(sql_l) > 0:
myDB = db.DBConnection()
#.........这里部分代码省略.........
开发者ID:coderbone,项目名称:SickRage,代码行数:101,代码来源:search.py
示例14: snatch_episode
def snatch_episode(result, end_status=SNATCHED):
"""
Contains the internal logic necessary to actually "snatch" a result that
has been found.
Returns a bool representing success.
result: SearchResult instance to be snatched.
endStatus: the episode status that should be used for the episode object once it's snatched.
"""
if None is result:
return False
result.priority = 0 # -1 = low, 0 = normal, 1 = high
if sickbeard.ALLOW_HIGH_PRIORITY:
# if it aired recently make it high priority
for cur_ep in result.episodes:
if datetime.date.today() - cur_ep.airdate <= datetime.timedelta(days=7):
result.priority = 1
if None is not re.search('(^|[\. _-])(proper|repack)([\. _-]|$)', result.name, re.I):
end_status = SNATCHED_PROPER
# NZBs can be sent straight to SAB or saved to disk
if result.resultType in ('nzb', 'nzbdata'):
if 'blackhole' == sickbeard.NZB_METHOD:
dl_result = _download_result(result)
elif 'sabnzbd' == sickbeard.NZB_METHOD:
dl_result = sab.send_nzb(result)
elif 'nzbget' == sickbeard.NZB_METHOD:
is_proper = True if SNATCHED_PROPER == end_status else False
dl_result = nzbget.sendNZB(result, is_proper)
else:
logger.log(u'Unknown NZB action specified in config: %s' % sickbeard.NZB_METHOD, logger.ERROR)
dl_result = False
# TORRENTs can be sent to clients or saved to disk
elif 'torrent' == result.resultType:
# torrents are saved to disk when blackhole mode
if 'blackhole' == sickbeard.TORRENT_METHOD:
dl_result = _download_result(result)
else:
# make sure we have the torrent file content
if not result.content and not result.url.startswith('magnet'):
result.content = result.provider.get_url(result.url)
if not result.content:
logger.log(u'Torrent content failed to download from %s' % result.url, logger.ERROR)
return False
# Snatches torrent with client
client = clients.getClientIstance(sickbeard.TORRENT_METHOD)()
dl_result = client.sendTORRENT(result)
else:
logger.log(u'Unknown result type, unable to download it', logger.ERROR)
dl_result = False
if not dl_result:
return False
if sickbeard.USE_FAILED_DOWNLOADS:
failed_history.logSnatch(result)
ui.notifications.message(u'Episode snatched', result.name)
history.logSnatch(result)
# don't notify when we re-download an episode
sql_l = []
update_imdb_data = True
for cur_ep_obj in result.episodes:
with cur_ep_obj.lock:
if is_first_best_match(result):
cur_ep_obj.status = Quality.compositeStatus(SNATCHED_BEST, result.quality)
else:
cur_ep_obj.status = Quality.compositeStatus(end_status, result.quality)
item = cur_ep_obj.get_sql()
if None is not item:
sql_l.append(item)
if cur_ep_obj.status not in Quality.DOWNLOADED:
notifiers.notify_snatch(cur_ep_obj._format_pattern('%SN - %Sx%0E - %EN - %QN'))
update_imdb_data = update_imdb_data and cur_ep_obj.show.load_imdb_info()
if 0 < len(sql_l):
my_db = db.DBConnection()
my_db.mass_action(sql_l)
return True
开发者ID:Apocrathia,项目名称:SickGear,代码行数:89,代码来源:search.py
注:本文中的sickbeard.notifiers.notify_snatch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论