def snatchEpisode(result, endStatus=SNATCHED): if result.resultType == "nzb": if sickbeard.NZB_METHOD == "blackhole": dlResult = _downloadResult(result) elif sickbeard.NZB_METHOD == "sabnzbd": dlResult = sab.sendNZB(result) else: logger.log("Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR) dlResult = False elif result.resultType == "torrent": dlResult = _downloadResult(result) else: logger.log("Unknown result type, unable to download it", logger.ERROR) dlResult = False if dlResult == False: return history.logSnatch(result) # don't notify when we re-download an episode if result.episode.status in Quality.DOWNLOADED: notifiers.notify(NOTIFY_SNATCH, result.episode.prettyName(True)) with result.episode.lock: result.episode.status = Quality.compositeStatus(endStatus, result.quality) result.episode.saveToDB() sickbeard.updateAiringList() sickbeard.updateComingList()
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(NOTIFY_SNATCH, curEpObj.prettyName(True)) return True
def snatchEpisode(result, endStatus=SNATCHED): if result.resultType == "nzb": if sickbeard.NZB_METHOD == "blackhole": dlResult = _downloadResult(result) elif sickbeard.NZB_METHOD == "sabnzbd": dlResult = sab.sendNZB(result) else: logger.log("Unknown NZB action specified in config: " + sickbeard.NZB_METHOD, logger.ERROR) dlResult = False elif result.resultType == "torrent": dlResult = _downloadResult(result) else: logger.log("Unknown result type, unable to download it", logger.ERROR) dlResult = False if dlResult == False: return history.logSnatch(result) # don't notify when we snatch a backlog episode, that's just annoying if endStatus != SNATCHED_BACKLOG: notifiers.notify(NOTIFY_SNATCH, result.episode.prettyName(True)) with result.episode.lock: if result.predownloaded == True: logger.log("changing status from " + str(result.episode.status) + " to " + str(PREDOWNLOADED), logger.DEBUG) result.episode.status = PREDOWNLOADED else: logger.log("changing status from " + str(result.episode.status) + " to " + str(endStatus), logger.DEBUG) result.episode.status = endStatus result.episode.saveToDB() sickbeard.updateMissingList() sickbeard.updateAiringList() sickbeard.updateComingList()
if ek.ek(os.path.normpath, movedFilePath) != ek.ek(os.path.normpath, renamedFilePath): try: ek.ek(os.rename, movedFilePath, renamedFilePath) returnStr += logHelper(u"Renaming the file " + movedFilePath + " to " + renamedFilePath, logger.DEBUG) except (OSError, IOError), e: returnStr += logHelper(u"Failed renaming " + movedFilePath + " to " + renamedFilePath + ": " + str(e), logger.ERROR) return returnStr else: returnStr += logHelper(u"Renaming is disabled, leaving file as "+movedFilePath, logger.DEBUG) # log it to history history.logDownload(rootEp, fileName) notifiers.notify(NOTIFY_DOWNLOAD, rootEp.prettyName(True)) # generate nfo/tbn rootEp.createMetaFiles() rootEp.saveToDB() # try updating just show path first if sickbeard.XBMC_UPDATE_LIBRARY: for curHost in [x.strip() for x in sickbeard.XBMC_HOST.split(",")]: if not notifiers.xbmc.updateLibrary(curHost, showName=rootEp.show.name) and sickbeard.XBMC_UPDATE_FULL: # do a full update if requested returnStr += logHelper(u"Update of show directory failed on " + curHost + ", trying full update as requested") notifiers.xbmc.updateLibrary(curHost) for curScriptName in sickbeard.EXTRA_SCRIPTS: script_cmd = shlex.split(curScriptName) + [rootEp.location, biggestFileName, str(tvdb_id), str(season), str(episode), str(rootEp.airdate)]
self._move(new_file_path, dest_path, sickbeard.MOVE_ASSOCIATED_FILES) except OSError, IOError: raise exceptions.PostProcessingFailed("Unable to move the files to their new home") # update the statuses before we rename so the quality goes into the name properly for cur_ep in [ep_obj] + ep_obj.relatedEps: with cur_ep.lock: cur_ep.location = ek.ek(os.path.join, dest_path, self._destination_file_name(ep_obj.prettyName())) cur_ep.status = common.Quality.compositeStatus(common.DOWNLOADED, new_ep_quality) cur_ep.saveToDB() # log it to history history.logDownload(ep_obj, self.file_path) # send notifications notifiers.notify(common.NOTIFY_DOWNLOAD, ep_obj.prettyName(True)) # generate nfo/tbn ep_obj.createMetaFiles() ep_obj.saveToDB() # this needs to be factored out into the notifiers if sickbeard.XBMC_UPDATE_LIBRARY: for curHost in [x.strip() for x in sickbeard.XBMC_HOST.split(",")]: # do a per-show update first, if possible if not xbmc.updateLibrary(curHost, showName=ep_obj.show.name) and sickbeard.XBMC_UPDATE_FULL: # do a full update if requested self._log(u"Update of show directory failed on " + curHost + ", trying full update as requested") xbmc.updateLibrary(curHost) # run extra_scripts