mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-02 17:33:37 +00:00
Change try to use folder name when filename does not contain show name.
Add analyse filename with a previously found showobj from folder name.
This commit is contained in:
parent
3107049161
commit
050b823f2b
4 changed files with 52 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
||||||
* Update SimpleJSON 3.13.2 (6ffddbe) to 3.16.0 (e2a54f7)
|
* Update SimpleJSON 3.13.2 (6ffddbe) to 3.16.0 (e2a54f7)
|
||||||
* Update unidecode module 1.0.22 (81f938d) to 1.0.22 (578cdb9)
|
* Update unidecode module 1.0.22 (81f938d) to 1.0.22 (578cdb9)
|
||||||
* Change site services tester to fallback to http if error with SSL
|
* Change site services tester to fallback to http if error with SSL
|
||||||
|
* Change try to use folder name when filename does not contain show name
|
||||||
|
|
||||||
|
|
||||||
[develop changelog]
|
[develop changelog]
|
||||||
|
|
|
@ -273,6 +273,8 @@ class NameParser(object):
|
||||||
elif not show and self.showObj:
|
elif not show and self.showObj:
|
||||||
show = self.showObj
|
show = self.showObj
|
||||||
best_result.show = show
|
best_result.show = show
|
||||||
|
if not best_result.series_name and getattr(show, 'name', None):
|
||||||
|
best_result.series_name = show.name
|
||||||
|
|
||||||
if show and show.is_anime and 1 < len(self.compiled_regexes[1]) and 1 != reg_ex:
|
if show and show.is_anime and 1 < len(self.compiled_regexes[1]) and 1 != reg_ex:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -452,7 +452,7 @@ class PostProcessor(object):
|
||||||
|
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def _analyze_name(self, name, resource=True):
|
def _analyze_name(self, name, resource=True, show=None, rel_grp=None):
|
||||||
"""
|
"""
|
||||||
Takes a name and tries to figure out a show, season, and episode from it.
|
Takes a name and tries to figure out a show, season, and episode from it.
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ class PostProcessor(object):
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
# 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(resource, try_scene_exceptions=True, convert=True, showObj=self.showObj)
|
np = NameParser(resource, try_scene_exceptions=True, convert=True, showObj=self.showObj or show)
|
||||||
parse_result = np.parse(name)
|
parse_result = np.parse(name)
|
||||||
self._log(u'Parsed %s<br />.. from %s' % (str(parse_result).decode('utf-8', 'xmlcharrefreplace'), name), logger.DEBUG)
|
self._log(u'Parsed %s<br />.. from %s' % (str(parse_result).decode('utf-8', 'xmlcharrefreplace'), name), logger.DEBUG)
|
||||||
|
|
||||||
|
@ -483,6 +483,8 @@ class PostProcessor(object):
|
||||||
|
|
||||||
# show object
|
# show object
|
||||||
show = parse_result.show
|
show = parse_result.show
|
||||||
|
if show and rel_grp and not parse_result.release_group:
|
||||||
|
parse_result.release_group = rel_grp
|
||||||
to_return = (show, season, episodes, parse_result.quality)
|
to_return = (show, season, episodes, parse_result.quality)
|
||||||
|
|
||||||
self._finalize(parse_result)
|
self._finalize(parse_result)
|
||||||
|
@ -518,7 +520,7 @@ class PostProcessor(object):
|
||||||
For a given file try to find the showid, season, and episode.
|
For a given file try to find the showid, season, and episode.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
show = season = quality = None
|
show = season = quality = rel_grp = None
|
||||||
episodes = []
|
episodes = []
|
||||||
|
|
||||||
# try to look up the nzb in history
|
# try to look up the nzb in history
|
||||||
|
@ -537,7 +539,10 @@ class PostProcessor(object):
|
||||||
lambda: self._analyze_name(self.file_path),
|
lambda: self._analyze_name(self.file_path),
|
||||||
|
|
||||||
# try to analyze the dir + file name together as one name
|
# try to analyze the dir + file name together as one name
|
||||||
lambda: self._analyze_name(self.folder_name + u' ' + self.file_name)]
|
lambda: self._analyze_name(self.folder_name + u' ' + self.file_name),
|
||||||
|
|
||||||
|
# try to analyze file name with previously parsed show
|
||||||
|
lambda: self._analyze_name(self.file_name, show=show, rel_grp=rel_grp)]
|
||||||
|
|
||||||
# attempt every possible method to get our info
|
# attempt every possible method to get our info
|
||||||
for cur_attempt in attempt_list:
|
for cur_attempt in attempt_list:
|
||||||
|
@ -553,6 +558,8 @@ class PostProcessor(object):
|
||||||
|
|
||||||
# if we already did a successful history lookup then keep that show value
|
# if we already did a successful history lookup then keep that show value
|
||||||
show = cur_show
|
show = cur_show
|
||||||
|
if self.release_group:
|
||||||
|
rel_grp = self.release_group
|
||||||
|
|
||||||
if cur_quality and not (self.in_history and quality):
|
if cur_quality and not (self.in_history and quality):
|
||||||
quality = cur_quality
|
quality = cur_quality
|
||||||
|
|
|
@ -169,6 +169,11 @@ simple_test_cases = {
|
||||||
parser.ParseResult(None, 'Show Name', None, [], 'WEB-DL', None, datetime.date(2010, 11, 23)),
|
parser.ParseResult(None, 'Show Name', None, [], 'WEB-DL', None, datetime.date(2010, 11, 23)),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'folder_filename': {
|
||||||
|
'Show.Name.S01.DVDRip.XviD-NOGRP/1x10 - The Episode Name.avi':
|
||||||
|
parser.ParseResult(None, 'Show Name', 1, [10], 'The Episode Name', 'NOGRP')
|
||||||
|
},
|
||||||
|
|
||||||
'anime_ultimate': {
|
'anime_ultimate': {
|
||||||
'[Tsuki] Bleach - 301 [1280x720][61D1D4EE]':
|
'[Tsuki] Bleach - 301 [1280x720][61D1D4EE]':
|
||||||
parser.ParseResult(None, 'Bleach', None, [], '1280x720', 'Tsuki', None, [301]),
|
parser.ParseResult(None, 'Bleach', None, [], '1280x720', 'Tsuki', None, [301]),
|
||||||
|
@ -468,6 +473,36 @@ class ComboTests(test.SickbeardTestDBCase):
|
||||||
|
|
||||||
|
|
||||||
class BasicTests(test.SickbeardTestDBCase):
|
class BasicTests(test.SickbeardTestDBCase):
|
||||||
|
def _test_folder_file(self, section, verbose=False):
|
||||||
|
if VERBOSE or verbose:
|
||||||
|
print('Running', section, 'tests')
|
||||||
|
for cur_test_base in simple_test_cases[section]:
|
||||||
|
cur_test_dir, cur_test_file = cur_test_base.split('/')
|
||||||
|
if VERBOSE or verbose:
|
||||||
|
print('Testing dir: %s file: %s' % (cur_test_dir, cur_test_file))
|
||||||
|
|
||||||
|
result = simple_test_cases[section][cur_test_base]
|
||||||
|
showobj = TVShow(name=result.series_name)
|
||||||
|
np = parser.NameParser(testing=True, showObj=showobj)
|
||||||
|
|
||||||
|
if not result:
|
||||||
|
self.assertRaises(parser.InvalidNameException, np.parse, cur_test_file)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
test_result = np.parse(cur_test_file)
|
||||||
|
|
||||||
|
test_result.release_group = result.release_group
|
||||||
|
|
||||||
|
try:
|
||||||
|
# self.assertEqual(test_result.which_regex, [section])
|
||||||
|
self.assertEqual(test_result, result)
|
||||||
|
except(StandardError, Exception):
|
||||||
|
print('air_by_date:', test_result.is_air_by_date, 'air_date:', test_result.air_date)
|
||||||
|
print('anime:', test_result.is_anime, 'ab_episode_numbers:', test_result.ab_episode_numbers)
|
||||||
|
print(test_result)
|
||||||
|
print(result)
|
||||||
|
raise
|
||||||
|
|
||||||
def _test_names(self, np, section, transform=None, verbose=False):
|
def _test_names(self, np, section, transform=None, verbose=False):
|
||||||
|
|
||||||
if VERBOSE or verbose:
|
if VERBOSE or verbose:
|
||||||
|
@ -597,6 +632,9 @@ class BasicTests(test.SickbeardTestDBCase):
|
||||||
np = parser.NameParser(testing=True)
|
np = parser.NameParser(testing=True)
|
||||||
self._test_names(np, 'scene_date_format', lambda x: x + '.avi')
|
self._test_names(np, 'scene_date_format', lambda x: x + '.avi')
|
||||||
|
|
||||||
|
def test_folder_filename(self):
|
||||||
|
self._test_folder_file('folder_filename')
|
||||||
|
|
||||||
def test_combination_names(self):
|
def test_combination_names(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue