Merge branch 'origin/dev'

This commit is contained in:
echel0n 2014-06-06 18:08:11 -07:00
commit 4da7173fa4
14 changed files with 223 additions and 126 deletions

View file

@ -37,6 +37,64 @@ from lib.unrar2 import RarFile, RarInfo
from lib.unrar2.rar_exceptions import * from lib.unrar2.rar_exceptions import *
def delete_folder(folder, check_empty=True):
# check if it's a folder
if not ek.ek(os.path.isdir, folder):
return False
# check if it isn't TV_DOWNLOAD_DIR
if sickbeard.TV_DOWNLOAD_DIR:
if helpers.real_path(folder) == helpers.real_path(sickbeard.TV_DOWNLOAD_DIR):
return False
# check if it's empty folder when wanted checked
if check_empty:
check_files = ek.ek(os.listdir, folder)
if check_files:
return False
# try deleting folder
try:
logger.log(u"Deleting folder: " + folder)
shutil.rmtree(folder)
except (OSError, IOError), e:
logger.log(u"Warning: unable to delete folder: " + folder + ": " + ex(e), logger.WARNING)
return False
return True
def delete_files(processPath, notwantedFiles):
global returnStr, process_result
if not process_result:
return
#Delete all file not needed
for cur_file in notwantedFiles:
cur_file_path = ek.ek(os.path.join, processPath, cur_file)
if not ek.ek(os.path.isfile, cur_file_path):
continue #Prevent error when a notwantedfiles is an associated files
returnStr += logHelper(u"Deleting file " + cur_file, logger.DEBUG)
#check first the read-only attribute
file_attribute = ek.ek(os.stat, cur_file_path)[0]
if (not file_attribute & stat.S_IWRITE):
# File is read-only, so make it writeable
returnStr += logHelper(u"Changing ReadOnly Flag for file " + cur_file, logger.DEBUG)
try:
ek.ek(os.chmod, cur_file_path, stat.S_IWRITE)
except OSError, e:
returnStr += logHelper(u"Cannot change permissions of " + cur_file_path + ': ' + str(e.strerror),
logger.DEBUG)
try:
ek.ek(os.remove, cur_file_path)
except OSError, e:
returnStr += logHelper(u"Unable to delete file " + cur_file + ': ' + str(e.strerror), logger.DEBUG)
def logHelper(logMessage, logLevel=logger.MESSAGE): def logHelper(logMessage, logLevel=logger.MESSAGE):
logger.log(logMessage, logLevel) logger.log(logMessage, logLevel)
return logMessage + u"\n" return logMessage + u"\n"
@ -106,13 +164,13 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior
#Don't Link media when the media is extracted from a rar in the same path #Don't Link media when the media is extracted from a rar in the same path
if process_method in ('hardlink', 'symlink') and videoInRar: if process_method in ('hardlink', 'symlink') and videoInRar:
process_media(path, videoInRar, nzbName, 'move', force, is_priority) process_result = process_media(path, videoInRar, nzbName, 'move', force, is_priority)
delete_files(path, rarContent) delete_files(path, rarContent)
for video in set(videoFiles) - set(videoInRar): for video in set(videoFiles) - set(videoInRar):
process_media(path, [video], nzbName, process_method, force, is_priority) process_result = process_media(path, [video], nzbName, process_method, force, is_priority)
else: else:
for video in videoFiles: for video in videoFiles:
process_media(path, [video], nzbName, process_method, force, is_priority) process_result = process_media(path, [video], nzbName, process_method, force, is_priority)
#Process Video File in all TV Subdir #Process Video File in all TV Subdir
for dir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed)]: for dir in [x for x in dirs if validateDir(path, x, nzbNameOriginal, failed)]:
@ -147,8 +205,8 @@ def processDir(dirName, nzbName=None, process_method=None, force=False, is_prior
if process_method == "move" and \ if process_method == "move" and \
ek.ek(os.path.normpath, processPath) != ek.ek(os.path.normpath, ek.ek(os.path.normpath, processPath) != ek.ek(os.path.normpath,
sickbeard.TV_DOWNLOAD_DIR): sickbeard.TV_DOWNLOAD_DIR):
if processPath != sickbeard.TV_DOWNLOAD_DIR: if delete_folder(processPath, check_empty=False):
delete_dir(processPath) returnStr += logHelper(u"Deleted folder: " + processPath, logger.DEBUG)
if process_result: if process_result:
returnStr += logHelper(u"Successfully processed") returnStr += logHelper(u"Successfully processed")
@ -320,6 +378,7 @@ def already_postprocessed(dirName, videofile, force):
def process_media(processPath, videoFiles, nzbName, process_method, force, is_priority): def process_media(processPath, videoFiles, nzbName, process_method, force, is_priority):
global process_result, returnStr global process_result, returnStr
processor = None
for cur_video_file in videoFiles: for cur_video_file in videoFiles:
if already_postprocessed(processPath, cur_video_file, force): if already_postprocessed(processPath, cur_video_file, force):
@ -335,7 +394,8 @@ def process_media(processPath, videoFiles, nzbName, process_method, force, is_pr
process_result = False process_result = False
process_fail_message = ex(e) process_fail_message = ex(e)
returnStr += processor.log if processor:
returnStr += processor.log
if process_result: if process_result:
returnStr += logHelper(u"Processing succeeded for " + cur_video_file_path) returnStr += logHelper(u"Processing succeeded for " + cur_video_file_path)
@ -347,57 +407,10 @@ def process_media(processPath, videoFiles, nzbName, process_method, force, is_pr
if not process_result: if not process_result:
break break
def delete_files(processPath, notwantedFiles):
global returnStr, process_result
if not process_result:
return
#Delete all file not needed
for cur_file in notwantedFiles:
cur_file_path = ek.ek(os.path.join, processPath, cur_file)
if not ek.ek(os.path.isfile, cur_file_path):
continue #Prevent error when a notwantedfiles is an associated files
returnStr += logHelper(u"Deleting file " + cur_file, logger.DEBUG)
#check first the read-only attribute
file_attribute = ek.ek(os.stat, cur_file_path)[0]
if (not file_attribute & stat.S_IWRITE):
# File is read-only, so make it writeable
returnStr += logHelper(u"Changing ReadOnly Flag for file " + cur_file, logger.DEBUG)
try:
ek.ek(os.chmod, cur_file_path, stat.S_IWRITE)
except OSError, e:
returnStr += logHelper(u"Cannot change permissions of " + cur_file_path + ': ' + str(e.strerror),
logger.DEBUG)
try:
ek.ek(os.remove, cur_file_path)
except OSError, e:
returnStr += logHelper(u"Unable to delete file " + cur_file + ': ' + str(e.strerror), logger.DEBUG)
def delete_dir(processPath):
global returnStr
if not ek.ek(os.listdir, processPath) == []:
returnStr += logHelper(
u"Skipping Deleting folder " + processPath + ' because some files was not deleted/processed', logger.DEBUG)
return
returnStr += logHelper(u"Deleting folder " + processPath, logger.DEBUG)
try:
shutil.rmtree(processPath)
except (OSError, IOError), e:
returnStr += logHelper(u"Warning: unable to remove the folder " + processPath + ": " + ex(e), logger.WARNING)
def get_path_dir_files(dirName, nzbName, type): def get_path_dir_files(dirName, nzbName, type):
path = "" path = ""
dirs = []
files = []
if dirName == sickbeard.TV_DOWNLOAD_DIR and not nzbName or type == "manual": #Scheduled Post Processing Active if dirName == sickbeard.TV_DOWNLOAD_DIR and not nzbName or type == "manual": #Scheduled Post Processing Active
#Get at first all the subdir in the dirName #Get at first all the subdir in the dirName
@ -436,7 +449,8 @@ def process_failed(dirName, nzbName):
returnStr += processor.log returnStr += processor.log
if sickbeard.DELETE_FAILED and process_result: if sickbeard.DELETE_FAILED and process_result:
delete_dir(dirName) if delete_folder(dirName, check_empty=False):
returnStr += logHelper(u"Deleted folder: " + dirName, logger.DEBUG)
if process_result: if process_result:
returnStr += logHelper(u"Failed Download Processing succeeded: (" + str(nzbName) + ", " + dirName + ")") returnStr += logHelper(u"Failed Download Processing succeeded: (" + str(nzbName) + ", " + dirName + ")")

View file

@ -219,8 +219,7 @@ class BTNProvider(generic.TorrentProvider):
# Search for the year of the air by date show # Search for the year of the air by date show
whole_season_params['name'] = str(ep_obj.airdate).split('-')[0] whole_season_params['name'] = str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.is_anime: elif ep_obj.show.is_anime:
whole_season_params['name'] = 'S' + str(ep_obj.scene_season) whole_season_params['name'] = "%d" % ep_obj.scene_absolute_number
#whole_season_params['name'] = "%d" % ep_obj.scene_absolute_number
else: else:
whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season)
@ -253,8 +252,10 @@ class BTNProvider(generic.TorrentProvider):
# BTN uses dots in dates, we just search for the date since that # BTN uses dots in dates, we just search for the date since that
# combined with the series identifier should result in just one episode # combined with the series identifier should result in just one episode
search_params['name'] = date_str.replace('-', '.') search_params['name'] = ep_obj.airdate.strftime('%b')
elif not self.show.is_anime: elif self.show.anime:
search_params['name'] = "%i" % int(ep_obj.scene_absolute_number)
else:
# Do a general name search for the episode, formatted like SXXEYY # Do a general name search for the episode, formatted like SXXEYY
search_params['name'] = "S%02dE%02d" % (ep_obj.scene_season, ep_obj.scene_episode) search_params['name'] = "S%02dE%02d" % (ep_obj.scene_season, ep_obj.scene_episode)

View file

@ -81,8 +81,12 @@ class EZRSSProvider(generic.TorrentProvider):
params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8') params['show_name'] = helpers.sanitizeSceneName(self.show.name, ezrss=True).replace('.', ' ').encode('utf-8')
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date:
params['season'] = str(ep_obj.airdate).split('-')[0] params['date'] = str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.sports:
params['date'] = str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
params['season'] = "%d" % ep_obj.scene_absolute_number
else: else:
params['season'] = ep_obj.scene_season params['season'] = ep_obj.scene_season
@ -99,8 +103,10 @@ class EZRSSProvider(generic.TorrentProvider):
if self.show.air_by_date: if self.show.air_by_date:
params['date'] = str(ep_obj.airdate) params['date'] = str(ep_obj.airdate)
if self.show.sports: elif self.show.sports:
params['date'] = str(ep_obj.airdate) params['date'] = str(ep_obj.airdate)
elif self.show.anime:
params['episode'] = "%i" % int(ep_obj.scene_absolute_number)
else: else:
params['season'] = ep_obj.scene_season params['season'] = ep_obj.scene_season
params['episode'] = ep_obj.scene_episode params['episode'] = ep_obj.scene_episode

View file

@ -158,11 +158,27 @@ class HDBitsProvider(generic.TorrentProvider):
} }
if episode: if episode:
post_data['tvdb'] = { if show.air_by_date:
'id': show.indexerid, post_data['tvdb'] = {
'season': episode.scene_season, 'id': show.indexerid,
'episode': episode.scene_episode 'episode': str(episode.airdate).replace('-', '|')
} }
elif show.sports:
post_data['tvdb'] = {
'id': show.indexerid,
'episode': episode.airdate.strftime('%b')
}
elif show.anime:
post_data['tvdb'] = {
'id': show.indexerid,
'episode': "%i" % int(episode.scene_absolute_number)
}
else:
post_data['tvdb'] = {
'id': show.indexerid,
'season': episode.scene_season,
'episode': episode.scene_episode
}
if season: if season:
if show.air_by_date or show.sports: if show.air_by_date or show.sports:
@ -170,6 +186,11 @@ class HDBitsProvider(generic.TorrentProvider):
'id': show.indexerid, 'id': show.indexerid,
'season': str(episode.airdate)[:7], 'season': str(episode.airdate)[:7],
} }
elif show.anime:
post_data['tvdb'] = {
'id': show.indexerid,
'season': "%d" % episode.scene_absolute_number,
}
else: else:
post_data['tvdb'] = { post_data['tvdb'] = {
'id': show.indexerid, 'id': show.indexerid,

View file

@ -125,7 +125,9 @@ class HDTorrentsProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -151,6 +153,11 @@ class HDTorrentsProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -102,7 +102,9 @@ class IPTorrentsProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -128,6 +130,11 @@ class IPTorrentsProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -174,23 +174,22 @@ class KATProvider(generic.TorrentProvider):
def _get_season_search_strings(self, ep_obj): def _get_season_search_strings(self, ep_obj):
search_string = {'Season': []} search_string = {'Season': []}
if not (ep_obj.show.air_by_date or ep_obj.show.sports): for show_name in set(allPossibleShowNames(self.show)):
for show_name in set(allPossibleShowNames(self.show)): if ep_obj.show.air_by_date or ep_obj.show.sports:
if ep_obj.show.air_by_date or ep_obj.show.sports: ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0] search_string['Season'].append(ep_string)
search_string['Season'].append(ep_string) ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0]
ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0] search_string['Season'].append(ep_string)
search_string['Season'].append(ep_string) elif ep_obj.show.anime:
elif ep_obj.show.anime: ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number search_string['Season'].append(ep_string)
search_string['Season'].append(ep_string) else:
else: ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int(
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int( ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE
ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE search_string['Season'].append(ep_string)
search_string['Season'].append(ep_string) ep_string = show_name + ' Season ' + str(
ep_string = show_name + ' Season ' + str( ep_obj.scene_season) + ' -Ep*' + ' category:tv' # 2) showName Season X
ep_obj.scene_season) + ' -Ep*' + ' category:tv' # 2) showName Season X search_string['Season'].append(ep_string)
search_string['Season'].append(ep_string)
return [search_string] return [search_string]

View file

@ -141,7 +141,9 @@ class NextGenProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -167,6 +169,11 @@ class NextGenProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -112,7 +112,9 @@ class SCCProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -138,6 +140,11 @@ class SCCProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -102,7 +102,9 @@ class SpeedCDProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -128,6 +130,11 @@ class SpeedCDProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -167,17 +167,22 @@ class ThePirateBayProvider(generic.TorrentProvider):
def _get_season_search_strings(self, ep_obj): def _get_season_search_strings(self, ep_obj):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(allPossibleShowNames(self.show)) if not (ep_obj.show.air_by_date or ep_obj.show.sports) else []: for show_name in set(allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0]
else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
search_string['Season'].append(ep_string)
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
search_string['Season'].append(ep_string)
ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' Season ' + str(ep_obj.airdate).split('-')[0]
search_string['Season'].append(ep_string)
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
search_string['Season'].append(ep_string)
else: else:
ep_string = show_name + ' Season ' + str(ep_obj.scene_season) + ' -Ep*' #2) showName Season X ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) + ' -S%02d' % int(
ep_obj.scene_season) + 'E' + ' category:tv' #1) showName SXX -SXXE
search_string['Season'].append(ep_string)
ep_string = show_name + ' Season ' + str(
ep_obj.scene_season) + ' -Ep*' + ' category:tv' # 2) showName Season X
search_string['Season'].append(ep_string)
search_string['Season'].append(ep_string) search_string['Season'].append(ep_string)
@ -198,18 +203,18 @@ class ThePirateBayProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(allPossibleShowNames(self.show)): for show_name in set(allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \ ep_string = sanitizeSceneName(show_name) + ' ' + \
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season, sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
'episodenumber': ep_obj.scene_episode} + '|' + \ 'episodenumber': ep_obj.scene_episode} + '|' + \
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season, sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season,
'episodenumber': ep_obj.scene_episode} + '|' + \ 'episodenumber': ep_obj.scene_episode} + ' %s' % add_string
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep_obj.scene_season,
'episodenumber': ep_obj.scene_episode}
ep_string += ' %s' % add_string
search_string['Episode'].append(re.sub('\s+', ' ', ep_string)) search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
return [search_string] return [search_string]

View file

@ -133,7 +133,10 @@ class TorrentDayProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
search_string['Season'].append(ep_string)
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -159,6 +162,11 @@ class TorrentDayProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -107,7 +107,9 @@ class TorrentLeechProvider(generic.TorrentProvider):
search_string = {'Season': []} search_string = {'Season': []}
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if ep_obj.show.air_by_date or ep_obj.show.sports: if ep_obj.show.air_by_date or ep_obj.show.sports:
ep_string = show_name + str(ep_obj.airdate).split('-')[0] ep_string = show_name + ' ' + str(ep_obj.airdate).split('-')[0]
elif ep_obj.show.anime:
ep_string = show_name + ' ' + "%d" % ep_obj.scene_absolute_number
else: else:
ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX ep_string = show_name + ' S%02d' % int(ep_obj.scene_season) #1) showName SXX
@ -133,6 +135,11 @@ class TorrentLeechProvider(generic.TorrentProvider):
str(ep_obj.airdate).replace('-', '|') + '|' + \ str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b') ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string) search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else: else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)): for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \ ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \

View file

@ -216,34 +216,35 @@ class FailedQueueItem(generic_queue.QueueItem):
for season, episodes in self.segment.items(): for season, episodes in self.segment.items():
for epObj in episodes: for epObj in episodes:
logger.log(u"Marking episode as bad: [" + epObj.prettyName() + "]")
failed_history.markFailed(epObj)
(release, provider) = failed_history.findRelease(epObj) (release, provider) = failed_history.findRelease(epObj)
if release: if release:
logger.log(u"Marking release as bad: " + release)
failed_history.markFailed(epObj)
failed_history.logFailed(release) failed_history.logFailed(release)
history.logFailed(epObj, release, provider) history.logFailed(epObj, release, provider)
failed_history.revertEpisode(epObj)
logger.log( failed_history.revertEpisode(epObj)
"Beginning failed download search for [" + epObj.prettyName() + "]") logger.log("Beginning failed download search for [" + epObj.prettyName() + "]")
try:
searchResult = search.searchProviders(self.show, season, [epObj], True)
# reset thread back to original name try:
threading.currentThread().name = self.thread_name searchResult = search.searchProviders(self.show, season, [epObj], True)
if searchResult: # reset thread back to original name
for result in searchResult: threading.currentThread().name = self.thread_name
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break if searchResult:
time.sleep(common.cpu_presets[sickbeard.CPU_PRESET]) for result in searchResult:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
else: # give the CPU a break
logger.log(u"No valid episode found to retry for [" + epObj.prettyName() + "]") time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
except Exception, e:
logger.log(traceback.format_exc(), logger.DEBUG) else:
logger.log(u"No valid episode found to retry for [" + epObj.prettyName() + "]")
except Exception, e:
logger.log(traceback.format_exc(), logger.DEBUG)
self.finish() self.finish()