mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-13 03:22:22 -05:00
Fixed -RP release issues.
Removes .nzb and .torrent extensions from files for parsing purposes.
This commit is contained in:
parent
423c09fd9e
commit
02c8b867c6
@ -86,6 +86,29 @@ def indentXML(elem, level=0):
|
|||||||
if level and (not elem.tail or not elem.tail.strip()):
|
if level and (not elem.tail or not elem.tail.strip()):
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
|
|
||||||
|
def remove_extension(name):
|
||||||
|
"""
|
||||||
|
Remove download or media extension from name (if any)
|
||||||
|
"""
|
||||||
|
|
||||||
|
if name and "." in name:
|
||||||
|
base_name, sep, extension = name.rpartition('.') # @UnusedVariable
|
||||||
|
if base_name and extension.lower() in ['nzb', 'torrent'] + mediaExtensions:
|
||||||
|
name = base_name
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
|
def remove_non_release_groups(name):
|
||||||
|
"""
|
||||||
|
Remove non release groups from name
|
||||||
|
"""
|
||||||
|
|
||||||
|
if name and "-" in name:
|
||||||
|
name_group = name.rsplit('-', 1)
|
||||||
|
if name_group[-1].upper() in ["RP", "NZBGEEK"]:
|
||||||
|
name = name_group[0]
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
def replaceExtension(filename, newExt):
|
def replaceExtension(filename, newExt):
|
||||||
'''
|
'''
|
||||||
|
@ -26,7 +26,7 @@ import os.path
|
|||||||
import regexes
|
import regexes
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from sickbeard import logger, helpers, scene_numbering, common, exceptions, scene_exceptions
|
from sickbeard import logger, helpers, scene_numbering, common, exceptions, scene_exceptions, encodingKludge as ek
|
||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
|
||||||
|
|
||||||
@ -329,10 +329,10 @@ class NameParser(object):
|
|||||||
return cached
|
return cached
|
||||||
|
|
||||||
# break it into parts if there are any (dirname, file name, extension)
|
# break it into parts if there are any (dirname, file name, extension)
|
||||||
dir_name, file_name = os.path.split(name)
|
dir_name, file_name = ek.ek(os.path.split, name)
|
||||||
ext_match = re.match('(.*)\.\w{3,4}$', file_name)
|
|
||||||
if ext_match and self.file_name:
|
if self.file_name:
|
||||||
base_file_name = ext_match.group(1)
|
base_file_name = helpers.remove_extension(file_name)
|
||||||
else:
|
else:
|
||||||
base_file_name = file_name
|
base_file_name = file_name
|
||||||
|
|
||||||
|
@ -74,20 +74,19 @@ class PostProcessor(object):
|
|||||||
self.file_path = file_path
|
self.file_path = file_path
|
||||||
|
|
||||||
# file name only
|
# file name only
|
||||||
self.file_name = ek.ek(os.path.basename, file_path)
|
self.file_name = helpers.remove_extension(ek.ek(os.path.basename, file_path))
|
||||||
|
|
||||||
# the name of the folder only
|
# the name of the folder only
|
||||||
self.folder_name = ek.ek(os.path.basename, self.folder_path)
|
self.folder_name = helpers.remove_extension(ek.ek(os.path.basename, self.folder_path))
|
||||||
|
|
||||||
# name of the NZB that resulted in this folder
|
# name of the NZB that resulted in this folder
|
||||||
self.nzb_name = nzb_name
|
self.nzb_name = helpers.remove_extension(nzb_name)
|
||||||
|
|
||||||
self.process_method = process_method if process_method else sickbeard.PROCESS_METHOD
|
self.process_method = process_method if process_method else sickbeard.PROCESS_METHOD
|
||||||
|
|
||||||
self.in_history = False
|
self.in_history = False
|
||||||
self.release_group = None
|
self.release_group = None
|
||||||
self.is_proper = False
|
self.is_proper = False
|
||||||
|
|
||||||
self.is_priority = is_priority
|
self.is_priority = is_priority
|
||||||
|
|
||||||
self.good_results = {self.NZB_NAME: False,
|
self.good_results = {self.NZB_NAME: False,
|
||||||
@ -444,7 +443,8 @@ class PostProcessor(object):
|
|||||||
|
|
||||||
# if the result is complete then remember that for later
|
# if the result is complete then remember that for later
|
||||||
if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group:
|
if parse_result.series_name and parse_result.season_number != None and parse_result.episode_numbers and parse_result.release_group:
|
||||||
test_name = ek.ek(os.path.basename, parse_result.original_name)
|
test_name = helpers.remove_extension(ek.ek(os.path.basename, parse_result.original_name))
|
||||||
|
|
||||||
if test_name == self.nzb_name:
|
if test_name == self.nzb_name:
|
||||||
self.good_results[self.NZB_NAME] = True
|
self.good_results[self.NZB_NAME] = True
|
||||||
elif test_name == self.folder_name:
|
elif test_name == self.folder_name:
|
||||||
@ -479,6 +479,8 @@ class PostProcessor(object):
|
|||||||
if not name:
|
if not name:
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
name = helpers.remove_non_release_groups(helpers.remove_extension(name))
|
||||||
|
|
||||||
# parse the name to break it into show name, season, and episode
|
# parse the name to break it into show name, season, and episode
|
||||||
np = NameParser(file, useIndexers=True, convert=True)
|
np = NameParser(file, useIndexers=True, convert=True)
|
||||||
parse_result = np.parse(name)
|
parse_result = np.parse(name)
|
||||||
@ -925,15 +927,10 @@ class PostProcessor(object):
|
|||||||
# use the best possible representation of the release name
|
# use the best possible representation of the release name
|
||||||
if self.good_results[self.NZB_NAME]:
|
if self.good_results[self.NZB_NAME]:
|
||||||
cur_release_name = self.nzb_name
|
cur_release_name = self.nzb_name
|
||||||
if cur_release_name.lower().endswith('.nzb'):
|
|
||||||
cur_release_name = cur_release_name.rpartition('.')[0]
|
|
||||||
elif self.good_results[self.FOLDER_NAME]:
|
elif self.good_results[self.FOLDER_NAME]:
|
||||||
cur_release_name = self.folder_name
|
cur_release_name = self.folder_name
|
||||||
elif self.good_results[self.FILE_NAME]:
|
elif self.good_results[self.FILE_NAME]:
|
||||||
cur_release_name = self.file_name
|
cur_release_name = self.file_name
|
||||||
# take the extension off the filename, it's not needed
|
|
||||||
if '.' in self.file_name:
|
|
||||||
cur_release_name = self.file_name.rpartition('.')[0]
|
|
||||||
|
|
||||||
if cur_release_name:
|
if cur_release_name:
|
||||||
self._log("Found release name " + cur_release_name, logger.DEBUG)
|
self._log("Found release name " + cur_release_name, logger.DEBUG)
|
||||||
|
@ -226,10 +226,11 @@ class ProperFinder():
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
# make sure that none of the existing history downloads are the same proper we're trying to download
|
# make sure that none of the existing history downloads are the same proper we're trying to download
|
||||||
|
clean_proper_name = self._genericName(helpers.remove_non_release_groups(curProper.name))
|
||||||
isSame = False
|
isSame = False
|
||||||
for curResult in historyResults:
|
for curResult in historyResults:
|
||||||
# if the result exists in history already we need to skip it
|
# if the result exists in history already we need to skip it
|
||||||
if self._genericName(curResult["resource"]) == self._genericName(curProper.name):
|
if self._genericName(helpers.remove_non_release_groups(curResult["resource"])) == clean_proper_name:
|
||||||
isSame = True
|
isSame = True
|
||||||
break
|
break
|
||||||
if isSame:
|
if isSame:
|
||||||
|
@ -2069,13 +2069,15 @@ class TVEpisode(object):
|
|||||||
return re.sub('[ -]', '_', name)
|
return re.sub('[ -]', '_', name)
|
||||||
|
|
||||||
def release_name(name):
|
def release_name(name):
|
||||||
if name and name.lower().endswith('.nzb'):
|
if name:
|
||||||
name = name.rpartition('.')[0]
|
name = helpers.remove_non_release_groups(helpers.remove_extension(name))
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def release_group(show, name):
|
def release_group(show, name):
|
||||||
if not name:
|
if name:
|
||||||
return ''
|
name = helpers.remove_non_release_groups(helpers.remove_extension(name))
|
||||||
|
else:
|
||||||
|
return ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
np = NameParser(name, showObj=show, naming_pattern=True)
|
np = NameParser(name, showObj=show, naming_pattern=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user