1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-18 15:25:07 -05:00
SickRage/sickbeard/failedProcessor.py

78 lines
3.1 KiB
Python
Raw Normal View History

# Author: Tyler Fenby <tylerfenby@gmail.com>
# URL: http://code.google.com/p/sickbeard/
#
2014-05-23 08:37:22 -04:00
# This file is part of SickRage.
#
2014-05-23 08:37:22 -04:00
# SickRage is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
2014-05-23 08:37:22 -04:00
# SickRage is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
from __future__ import with_statement
import sickbeard
from sickbeard import logger
from sickbeard import exceptions
from sickbeard import show_name_helpers
from sickbeard import search_queue
from sickbeard.name_parser.parser import NameParser, InvalidNameException, InvalidShowException
class FailedProcessor(object):
"""Take appropriate action when a download fails to complete"""
def __init__(self, dirName, nzbName):
"""
dirName: Full path to the folder of the failed download
nzbName: Full name of the nzb file that failed
"""
self.dir_name = dirName
self.nzb_name = nzbName
self.log = ""
def process(self):
self._log(u"Failed download detected: (" + str(self.nzb_name) + ", " + str(self.dir_name) + ")")
releaseName = show_name_helpers.determineReleaseName(self.dir_name, self.nzb_name)
if releaseName is None:
self._log(u"Warning: unable to find a valid release name.", logger.WARNING)
raise exceptions.FailedProcessingFailed()
try:
2014-05-31 06:35:57 -04:00
parser = NameParser(False, convert=True)
parsed = parser.parse(releaseName)
except InvalidNameException:
Fixed issues with editing/saving custom scene exceptions. Fixed charmap issues for anime show names. Fixed issues with display show page and epCat key errors. Fixed duplicate log messages for clearing provider caches. Fixed issues with email notifier ep names not properly being encoded to UTF-8. TVDB<->TVRAGE Indexer ID mapping is now performed on demand to be used when needed such as newznab providers can be searched with tvrage_id's and some will return tvrage_id's that later can be used to create show objects from for faster and more accurate name parsing, mapping is done via Trakt API calls. Added stop event signals to schedualed tasks, SR now waits indefinate till task has been fully stopped before completing a restart or shutdown event. NameParserCache is now persistent and stores 200 parsed results at any given time for quicker lookups and better performance, this helps maintain results between updates or shutdown/startup events. Black and White lists for anime now only get used for anime shows as intended, performance gain for non-anime shows that dont need to load these lists. Internal name cache now builds it self on demand when needed per show request plus checks if show is already in cache and if true exits routine to save time. Schedualer and QueueItems classes are now a sub-class of threading.Thread and a stop threading event signal has been added to each. If I forgot to list something it doesn't mean its not fixed so please test and report back if anything is wrong or has been corrected by this new release.
2014-07-14 22:00:53 -04:00
self._log(u"Error: release name is invalid: " + releaseName, logger.DEBUG)
raise exceptions.FailedProcessingFailed()
except InvalidShowException:
Fixed issues with editing/saving custom scene exceptions. Fixed charmap issues for anime show names. Fixed issues with display show page and epCat key errors. Fixed duplicate log messages for clearing provider caches. Fixed issues with email notifier ep names not properly being encoded to UTF-8. TVDB<->TVRAGE Indexer ID mapping is now performed on demand to be used when needed such as newznab providers can be searched with tvrage_id's and some will return tvrage_id's that later can be used to create show objects from for faster and more accurate name parsing, mapping is done via Trakt API calls. Added stop event signals to schedualed tasks, SR now waits indefinate till task has been fully stopped before completing a restart or shutdown event. NameParserCache is now persistent and stores 200 parsed results at any given time for quicker lookups and better performance, this helps maintain results between updates or shutdown/startup events. Black and White lists for anime now only get used for anime shows as intended, performance gain for non-anime shows that dont need to load these lists. Internal name cache now builds it self on demand when needed per show request plus checks if show is already in cache and if true exits routine to save time. Schedualer and QueueItems classes are now a sub-class of threading.Thread and a stop threading event signal has been added to each. If I forgot to list something it doesn't mean its not fixed so please test and report back if anything is wrong or has been corrected by this new release.
2014-07-14 22:00:53 -04:00
self._log(u"Error: unable to parse release name " + releaseName + " into a valid show", logger.DEBUG)
raise exceptions.FailedProcessingFailed()
logger.log(u"name_parser info: ", logger.DEBUG)
logger.log(u" - " + str(parsed.series_name), logger.DEBUG)
logger.log(u" - " + str(parsed.season_number), logger.DEBUG)
logger.log(u" - " + str(parsed.episode_numbers), logger.DEBUG)
logger.log(u" - " + str(parsed.extra_info), logger.DEBUG)
logger.log(u" - " + str(parsed.release_group), logger.DEBUG)
logger.log(u" - " + str(parsed.air_date), logger.DEBUG)
for episode in parsed.episode_numbers:
segment = parsed.show.getEpisode(parsed.season_number, episode)
cur_failed_queue_item = search_queue.FailedQueueItem(parsed.show, [segment])
sickbeard.searchQueueScheduler.action.add_item(cur_failed_queue_item)
return True
def _log(self, message, level=logger.INFO):
"""Log to regular logfile and save for return for PP script log"""
logger.log(message, level)
self.log += message + "\n"