mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-07 03:48:02 -05:00
Fixed issues with parsing release names and naming patterns including regex for sports is now more accurate then ever!
Added option under general settings to allow specifiying a default indexer to be used for adding newshows and existing shows (All, TVDB, TVRage)
This commit is contained in:
parent
85a9a81f4e
commit
3a60683327
@ -19,6 +19,12 @@
|
|||||||
#else
|
#else
|
||||||
<h1 class="title">$title</h1>
|
<h1 class="title">$title</h1>
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
|
#set $indexer = 0
|
||||||
|
#if $sickbeard.INDEXER_DEFAULT
|
||||||
|
#set $indexer = $sickbeard.INDEXER_DEFAULT
|
||||||
|
#end if
|
||||||
|
|
||||||
<script type="text/javascript" src="$sbRoot/js/config.js?$sbPID"></script>
|
<script type="text/javascript" src="$sbRoot/js/config.js?$sbPID"></script>
|
||||||
|
|
||||||
<div id="config">
|
<div id="config">
|
||||||
@ -107,6 +113,7 @@
|
|||||||
<span class="component-title">Default Indexer:</span>
|
<span class="component-title">Default Indexer:</span>
|
||||||
<span class="component-desc">
|
<span class="component-desc">
|
||||||
<select id="indexer_default" name="indexer_default">
|
<select id="indexer_default" name="indexer_default">
|
||||||
|
<option value="0" #if $indexer == 0 then "selected=\"selected\"" else ""#>All Indexers</option>
|
||||||
#for $indexer in $sickbeard.indexerApi().indexers
|
#for $indexer in $sickbeard.indexerApi().indexers
|
||||||
<option value="$indexer" #if $indexer == $sickbeard.INDEXER_DEFAULT then "selected=\"selected\"" else ""#>$sickbeard.indexerApi().indexers[$indexer]</option>
|
<option value="$indexer" #if $indexer == $sickbeard.INDEXER_DEFAULT then "selected=\"selected\"" else ""#>$sickbeard.indexerApi().indexers[$indexer]</option>
|
||||||
#end for
|
#end for
|
||||||
|
@ -14,12 +14,18 @@
|
|||||||
#end if
|
#end if
|
||||||
|
|
||||||
#set $show_id = $curDir['dir']
|
#set $show_id = $curDir['dir']
|
||||||
#set $indexer = 1
|
|
||||||
#if $curDir['existing_info'][0]:
|
#if $curDir['existing_info'][0]:
|
||||||
#set $show_id = $show_id + '|' + $str($curDir['existing_info'][0]) + '|' + $str($curDir['existing_info'][1])
|
#set $show_id = $show_id + '|' + $str($curDir['existing_info'][0]) + '|' + $str($curDir['existing_info'][1])
|
||||||
#set $indexer = $curDir['existing_info'][2]
|
#set $indexer = $curDir['existing_info'][2]
|
||||||
#end if
|
#end if
|
||||||
|
|
||||||
|
#set $indexer = 0
|
||||||
|
#if #if $curDir['existing_info'][0]:
|
||||||
|
#set $indexer = $curDir['existing_info'][2]
|
||||||
|
#elif $sickbeard.INDEXER_DEFAULT
|
||||||
|
#set $indexer = $sickbeard.INDEXER_DEFAULT
|
||||||
|
#end if
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><input type="checkbox" id="$show_id" class="dirCheck" checked=checked></td>
|
<td><input type="checkbox" id="$show_id" class="dirCheck" checked=checked></td>
|
||||||
<td><label for="$show_id">$curDir['display_dir']</label></td>
|
<td><label for="$show_id">$curDir['display_dir']</label></td>
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<select name="indexerLang" id="indexerLangSelect" style="height: 26px;margin-top: 1px;">
|
<select name="indexerLang" id="indexerLangSelect" style="height: 26px;margin-top: 1px;">
|
||||||
<option value="en" selected="selected">en</option>
|
<option value="en" selected="selected">en</option>
|
||||||
</select><b>*</b>
|
</select><b>*</b>
|
||||||
|
|
||||||
<select name="providedIndexer" id="providedIndexer" style="height: 26px;margin-top: 1px;">
|
<select name="providedIndexer" id="providedIndexer" style="height: 26px;margin-top: 1px;">
|
||||||
<option value="0" #if $provided_indexer == 0 then "selected=\"selected\"" else ""#>All Indexers</option>
|
<option value="0" #if $provided_indexer == 0 then "selected=\"selected\"" else ""#>All Indexers</option>
|
||||||
#for $indexer in $indexers
|
#for $indexer in $indexers
|
||||||
|
@ -602,7 +602,7 @@ def initialize(consoleLogging=True):
|
|||||||
VERSION_NOTIFY = check_setting_int(CFG, 'General', 'version_notify', 1)
|
VERSION_NOTIFY = check_setting_int(CFG, 'General', 'version_notify', 1)
|
||||||
AUTO_UPDATE = check_setting_int(CFG, 'General', 'auto_update', 1)
|
AUTO_UPDATE = check_setting_int(CFG, 'General', 'auto_update', 1)
|
||||||
FLATTEN_FOLDERS_DEFAULT = bool(check_setting_int(CFG, 'General', 'flatten_folders_default', 0))
|
FLATTEN_FOLDERS_DEFAULT = bool(check_setting_int(CFG, 'General', 'flatten_folders_default', 0))
|
||||||
INDEXER_DEFAULT = check_setting_int(CFG, 'General', 'indexer_default', 1)
|
INDEXER_DEFAULT = check_setting_int(CFG, 'General', 'indexer_default', 0)
|
||||||
|
|
||||||
PROVIDER_ORDER = check_setting_str(CFG, 'General', 'provider_order', '').split()
|
PROVIDER_ORDER = check_setting_str(CFG, 'General', 'provider_order', '').split()
|
||||||
|
|
||||||
|
@ -943,6 +943,8 @@ def _check_against_names(name, show):
|
|||||||
|
|
||||||
|
|
||||||
def get_show_by_name(name, checkIndexers=False):
|
def get_show_by_name(name, checkIndexers=False):
|
||||||
|
if not sickbeard.showList: return
|
||||||
|
|
||||||
in_cache = False
|
in_cache = False
|
||||||
foundResult = None
|
foundResult = None
|
||||||
|
|
||||||
|
@ -106,11 +106,7 @@ class NameParser(object):
|
|||||||
result.series_name = match.group('series_name')
|
result.series_name = match.group('series_name')
|
||||||
if result.series_name:
|
if result.series_name:
|
||||||
result.series_name = self.clean_series_name(result.series_name)
|
result.series_name = self.clean_series_name(result.series_name)
|
||||||
|
self.show = helpers.get_show_by_name(result.series_name)
|
||||||
if 'sports_event_title' in named_groups:
|
|
||||||
result.sports_event_title = match.group('sports_event_title')
|
|
||||||
if result.sports_event_title:
|
|
||||||
result.sports_event_title = self.clean_series_name(result.sports_event_title)
|
|
||||||
|
|
||||||
if 'season_num' in named_groups:
|
if 'season_num' in named_groups:
|
||||||
tmp_season = int(match.group('season_num'))
|
tmp_season = int(match.group('season_num'))
|
||||||
@ -130,8 +126,8 @@ class NameParser(object):
|
|||||||
if sports_event_date:
|
if sports_event_date:
|
||||||
try:
|
try:
|
||||||
result.sports_event_date = parser.parse(sports_event_date, fuzzy=True).date()
|
result.sports_event_date = parser.parse(sports_event_date, fuzzy=True).date()
|
||||||
except ValueError, e:
|
except:
|
||||||
raise InvalidNameException(e.message)
|
continue
|
||||||
|
|
||||||
if 'air_year' in named_groups and 'air_month' in named_groups and 'air_day' in named_groups:
|
if 'air_year' in named_groups and 'air_month' in named_groups and 'air_day' in named_groups:
|
||||||
year = int(match.group('air_year'))
|
year = int(match.group('air_year'))
|
||||||
@ -141,8 +137,8 @@ class NameParser(object):
|
|||||||
try:
|
try:
|
||||||
dtStr = '%s-%s-%s' % (year, month, day)
|
dtStr = '%s-%s-%s' % (year, month, day)
|
||||||
result.air_date = datetime.datetime.strptime(dtStr, "%Y-%m-%d").date()
|
result.air_date = datetime.datetime.strptime(dtStr, "%Y-%m-%d").date()
|
||||||
except ValueError, e:
|
except:
|
||||||
raise InvalidNameException(e.message)
|
continue
|
||||||
|
|
||||||
if 'extra_info' in named_groups:
|
if 'extra_info' in named_groups:
|
||||||
tmp_extra_info = match.group('extra_info')
|
tmp_extra_info = match.group('extra_info')
|
||||||
@ -247,8 +243,9 @@ class NameParser(object):
|
|||||||
|
|
||||||
# if the dirname has a release group/show name I believe it over the filename
|
# if the dirname has a release group/show name I believe it over the filename
|
||||||
final_result.series_name = self._combine_results(dir_name_result, file_name_result, 'series_name')
|
final_result.series_name = self._combine_results(dir_name_result, file_name_result, 'series_name')
|
||||||
if final_result.sports:
|
|
||||||
final_result.series_name = str(final_result.series_name).partition(" ")[0]
|
# if final_result.sports:
|
||||||
|
# final_result.series_name = str(final_result.series_name).partition(" ")[0]
|
||||||
|
|
||||||
final_result.extra_info = self._combine_results(dir_name_result, file_name_result, 'extra_info')
|
final_result.extra_info = self._combine_results(dir_name_result, file_name_result, 'extra_info')
|
||||||
final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
|
final_result.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
|
||||||
@ -275,7 +272,6 @@ class ParseResult(object):
|
|||||||
def __init__(self,
|
def __init__(self,
|
||||||
original_name,
|
original_name,
|
||||||
series_name=None,
|
series_name=None,
|
||||||
sports_event_title=None,
|
|
||||||
sports_event_date=None,
|
sports_event_date=None,
|
||||||
season_number=None,
|
season_number=None,
|
||||||
episode_numbers=None,
|
episode_numbers=None,
|
||||||
@ -286,7 +282,6 @@ class ParseResult(object):
|
|||||||
):
|
):
|
||||||
|
|
||||||
self.show = show
|
self.show = show
|
||||||
|
|
||||||
self.original_name = original_name
|
self.original_name = original_name
|
||||||
|
|
||||||
self.series_name = series_name
|
self.series_name = series_name
|
||||||
@ -301,7 +296,6 @@ class ParseResult(object):
|
|||||||
|
|
||||||
self.air_date = air_date
|
self.air_date = air_date
|
||||||
|
|
||||||
self.sports_event_title = sports_event_title
|
|
||||||
self.sports_event_date = sports_event_date
|
self.sports_event_date = sports_event_date
|
||||||
|
|
||||||
self.which_regex = None
|
self.which_regex = None
|
||||||
@ -355,15 +349,11 @@ class ParseResult(object):
|
|||||||
return to_return.encode('utf-8')
|
return to_return.encode('utf-8')
|
||||||
|
|
||||||
def convert(self):
|
def convert(self):
|
||||||
|
if not self.show: return self
|
||||||
if self.air_by_date: return self # scene numbering does not apply to air-by-date
|
if self.air_by_date: return self # scene numbering does not apply to air-by-date
|
||||||
if self.season_number == None: return self # can't work without a season
|
if self.season_number == None: return self # can't work without a season
|
||||||
if len(self.episode_numbers) == 0: return self # need at least one episode
|
if len(self.episode_numbers) == 0: return self # need at least one episode
|
||||||
|
|
||||||
# convert scene numbered releases before storing to cache
|
|
||||||
self.show = helpers.get_show_by_name(self.series_name)
|
|
||||||
if not self.show:
|
|
||||||
return self
|
|
||||||
|
|
||||||
new_episode_numbers = []
|
new_episode_numbers = []
|
||||||
new_season_numbers = []
|
new_season_numbers = []
|
||||||
for epNo in self.episode_numbers:
|
for epNo in self.episode_numbers:
|
||||||
@ -398,7 +388,7 @@ class ParseResult(object):
|
|||||||
air_by_date = property(_is_air_by_date)
|
air_by_date = property(_is_air_by_date)
|
||||||
|
|
||||||
def _is_sports(self):
|
def _is_sports(self):
|
||||||
if self.sports_event_title or self.sports_event_date:
|
if self.sports_event_date:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
sports = property(_is_sports)
|
sports = property(_is_sports)
|
||||||
|
@ -192,7 +192,7 @@ sports_regexs = [
|
|||||||
# Sports.Name.2010.11.23.Source.Quality.Etc-Group
|
# Sports.Name.2010.11.23.Source.Quality.Etc-Group
|
||||||
# Sports.Name.23rd.Nov.2010.Source.Quality.Etc-Group
|
# Sports.Name.23rd.Nov.2010.Source.Quality.Etc-Group
|
||||||
'''
|
'''
|
||||||
^(?P<series_name>.+?)[. _-]+
|
^(?P<series_name>.*?(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOGP).*?)[. _-]+
|
||||||
(?P<sports_event_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4}))
|
(?P<sports_event_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4}))
|
||||||
[. _-]*((?P<extra_info>.+?)((?<![. _-])(?<!WEB)
|
[. _-]*((?P<extra_info>.+?)((?<![. _-])(?<!WEB)
|
||||||
-(?P<release_group>[^- ]+))?)?$
|
-(?P<release_group>[^- ]+))?)?$
|
||||||
|
@ -152,7 +152,7 @@ def validate_name(pattern, multi=None, file_only=False, abd=False, sports=False)
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = parser.parse(new_name)
|
result = parser.parse(new_name)
|
||||||
except InvalidNameException:
|
except InvalidNameException, e :
|
||||||
logger.log(u"Unable to parse " + new_name + ", not valid", logger.DEBUG)
|
logger.log(u"Unable to parse " + new_name + ", not valid", logger.DEBUG)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -259,10 +259,6 @@ class GenericProvider:
|
|||||||
if self.show.air_by_date or self.show.sports:
|
if self.show.air_by_date or self.show.sports:
|
||||||
useDate = True
|
useDate = True
|
||||||
|
|
||||||
regexMode = 0
|
|
||||||
if self.show.sports:
|
|
||||||
regexMode = 2
|
|
||||||
|
|
||||||
for ep_obj in ep_objs:
|
for ep_obj in ep_objs:
|
||||||
logger.log(u'Searching "%s" for "%s" as "%s"' % (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
logger.log(u'Searching "%s" for "%s" as "%s"' % (self.name, ep_obj.prettyName(), ep_obj.scene_prettyName()))
|
||||||
|
|
||||||
@ -281,7 +277,7 @@ class GenericProvider:
|
|||||||
|
|
||||||
# parse the file name
|
# parse the file name
|
||||||
try:
|
try:
|
||||||
myParser = NameParser(False, regexMode=regexMode)
|
myParser = NameParser(False)
|
||||||
parse_result = myParser.parse(title).convert()
|
parse_result = myParser.parse(title).convert()
|
||||||
except InvalidNameException:
|
except InvalidNameException:
|
||||||
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
|
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
|
||||||
|
@ -198,7 +198,7 @@ class TVCache():
|
|||||||
|
|
||||||
# if we don't have complete info then parse the filename to get it
|
# if we don't have complete info then parse the filename to get it
|
||||||
try:
|
try:
|
||||||
myParser = NameParser(0)
|
myParser = NameParser()
|
||||||
parse_result = myParser.parse(name).convert()
|
parse_result = myParser.parse(name).convert()
|
||||||
except InvalidNameException:
|
except InvalidNameException:
|
||||||
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
|
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
|
||||||
|
@ -1008,7 +1008,7 @@ class ConfigGeneral:
|
|||||||
sickbeard.DATE_PRESET = date_preset
|
sickbeard.DATE_PRESET = date_preset
|
||||||
|
|
||||||
if indexer_default:
|
if indexer_default:
|
||||||
sickbeard.INDEXER_DEFAULT = indexer_default
|
sickbeard.INDEXER_DEFAULT = config.to_int(indexer_default)
|
||||||
|
|
||||||
if time_preset:
|
if time_preset:
|
||||||
sickbeard.TIME_PRESET_W_SECONDS = time_preset
|
sickbeard.TIME_PRESET_W_SECONDS = time_preset
|
||||||
@ -2130,7 +2130,7 @@ class NewHomeAddShows:
|
|||||||
|
|
||||||
t.provided_show_dir = show_dir
|
t.provided_show_dir = show_dir
|
||||||
t.other_shows = other_shows
|
t.other_shows = other_shows
|
||||||
t.provided_indexer = int(indexer or 0)
|
t.provided_indexer = int(indexer or sickbeard.INDEXER_DEFAULT)
|
||||||
t.indexers = sickbeard.indexerApi().indexers
|
t.indexers = sickbeard.indexerApi().indexers
|
||||||
|
|
||||||
return _munge(t)
|
return _munge(t)
|
||||||
|
@ -28,7 +28,8 @@ sys.path.append(os.path.abspath('../lib'))
|
|||||||
|
|
||||||
import test_lib as test
|
import test_lib as test
|
||||||
import sickbeard
|
import sickbeard
|
||||||
from sickbeard.helpers import sanitizeSceneName, custom_strftime
|
from sickbeard.helpers import sanitizeSceneName
|
||||||
|
from sickbeard.name_parser.parser import NameParser
|
||||||
from sickbeard.tv import TVShow
|
from sickbeard.tv import TVShow
|
||||||
|
|
||||||
class XEMBasicTests(test.SickbeardTestDBCase):
|
class XEMBasicTests(test.SickbeardTestDBCase):
|
||||||
@ -49,39 +50,13 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
|||||||
|
|
||||||
def test_formating(self):
|
def test_formating(self):
|
||||||
self.loadFromDB()
|
self.loadFromDB()
|
||||||
show = sickbeard.helpers.findCertainShow(sickbeard.showList, 75978)
|
|
||||||
ep = show.getEpisode(7, 6)
|
|
||||||
ep.airdate = datetime.datetime.now()
|
|
||||||
|
|
||||||
print format(ep.episode, '02d')
|
release = "d:\\Downloads\\newdownload\\2.Broke.Girls.S03E10.And.the.First.Day.of.School.720p.WEB-DL.DD5.1.H.264-BS.mkv"
|
||||||
print format(ep.scene_episode, '02d')
|
# parse the name to break it into show name, season, and episode
|
||||||
|
np = NameParser(file)
|
||||||
|
parse_result = np.parse(release).convert()
|
||||||
|
|
||||||
search_string = {'Episode':[]}
|
print(parse_result)
|
||||||
episode = ep.airdate
|
|
||||||
str(episode).replace('-', '|')
|
|
||||||
ep_string = sanitizeSceneName(show.name) + ' ' + \
|
|
||||||
str(episode).replace('-', '|') + '|' + \
|
|
||||||
sickbeard.helpers.custom_strftime('%b', episode)
|
|
||||||
|
|
||||||
search_string['Episode'].append(ep_string)
|
|
||||||
|
|
||||||
scene_ep_string = sanitizeSceneName(show.name) + ' ' + \
|
|
||||||
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep.scene_season,
|
|
||||||
'episodenumber': ep.scene_episode} + '|' + \
|
|
||||||
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep.scene_season,
|
|
||||||
'episodenumber': ep.scene_episode} + '|' + \
|
|
||||||
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep.scene_season,
|
|
||||||
'episodenumber': ep.scene_episode} + ' %s category:tv' % ''
|
|
||||||
|
|
||||||
scene_season_string = show.name + ' S%02d' % int(ep.scene_season) + ' -S%02d' % int(ep.scene_season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE
|
|
||||||
|
|
||||||
|
|
||||||
print(
|
|
||||||
u'Searching "%s" for "%s" as "%s"' % (show.name, ep.prettyName(), ep.scene_prettyName()))
|
|
||||||
|
|
||||||
print('Scene episode search strings: %s' % (scene_ep_string))
|
|
||||||
|
|
||||||
print('Scene season search strings: %s' % (scene_season_string))
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print "=================="
|
print "=================="
|
||||||
|
Loading…
Reference in New Issue
Block a user