mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-05 10:58:01 -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
|
||||
<h1 class="title">$title</h1>
|
||||
#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>
|
||||
|
||||
<div id="config">
|
||||
@ -107,6 +113,7 @@
|
||||
<span class="component-title">Default Indexer:</span>
|
||||
<span class="component-desc">
|
||||
<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
|
||||
<option value="$indexer" #if $indexer == $sickbeard.INDEXER_DEFAULT then "selected=\"selected\"" else ""#>$sickbeard.indexerApi().indexers[$indexer]</option>
|
||||
#end for
|
||||
|
@ -14,12 +14,18 @@
|
||||
#end if
|
||||
|
||||
#set $show_id = $curDir['dir']
|
||||
#set $indexer = 1
|
||||
#if $curDir['existing_info'][0]:
|
||||
#set $show_id = $show_id + '|' + $str($curDir['existing_info'][0]) + '|' + $str($curDir['existing_info'][1])
|
||||
#set $indexer = $curDir['existing_info'][2]
|
||||
#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>
|
||||
<td><input type="checkbox" id="$show_id" class="dirCheck" checked=checked></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;">
|
||||
<option value="en" selected="selected">en</option>
|
||||
</select><b>*</b>
|
||||
|
||||
<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>
|
||||
#for $indexer in $indexers
|
||||
|
@ -602,7 +602,7 @@ def initialize(consoleLogging=True):
|
||||
VERSION_NOTIFY = check_setting_int(CFG, 'General', 'version_notify', 1)
|
||||
AUTO_UPDATE = check_setting_int(CFG, 'General', 'auto_update', 1)
|
||||
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()
|
||||
|
||||
|
@ -943,6 +943,8 @@ def _check_against_names(name, show):
|
||||
|
||||
|
||||
def get_show_by_name(name, checkIndexers=False):
|
||||
if not sickbeard.showList: return
|
||||
|
||||
in_cache = False
|
||||
foundResult = None
|
||||
|
||||
|
@ -106,11 +106,7 @@ class NameParser(object):
|
||||
result.series_name = match.group('series_name')
|
||||
if result.series_name:
|
||||
result.series_name = self.clean_series_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)
|
||||
self.show = helpers.get_show_by_name(result.series_name)
|
||||
|
||||
if 'season_num' in named_groups:
|
||||
tmp_season = int(match.group('season_num'))
|
||||
@ -130,8 +126,8 @@ class NameParser(object):
|
||||
if sports_event_date:
|
||||
try:
|
||||
result.sports_event_date = parser.parse(sports_event_date, fuzzy=True).date()
|
||||
except ValueError, e:
|
||||
raise InvalidNameException(e.message)
|
||||
except:
|
||||
continue
|
||||
|
||||
if 'air_year' in named_groups and 'air_month' in named_groups and 'air_day' in named_groups:
|
||||
year = int(match.group('air_year'))
|
||||
@ -141,8 +137,8 @@ class NameParser(object):
|
||||
try:
|
||||
dtStr = '%s-%s-%s' % (year, month, day)
|
||||
result.air_date = datetime.datetime.strptime(dtStr, "%Y-%m-%d").date()
|
||||
except ValueError, e:
|
||||
raise InvalidNameException(e.message)
|
||||
except:
|
||||
continue
|
||||
|
||||
if 'extra_info' in named_groups:
|
||||
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
|
||||
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.release_group = self._combine_results(dir_name_result, file_name_result, 'release_group')
|
||||
@ -275,7 +272,6 @@ class ParseResult(object):
|
||||
def __init__(self,
|
||||
original_name,
|
||||
series_name=None,
|
||||
sports_event_title=None,
|
||||
sports_event_date=None,
|
||||
season_number=None,
|
||||
episode_numbers=None,
|
||||
@ -286,7 +282,6 @@ class ParseResult(object):
|
||||
):
|
||||
|
||||
self.show = show
|
||||
|
||||
self.original_name = original_name
|
||||
|
||||
self.series_name = series_name
|
||||
@ -301,7 +296,6 @@ class ParseResult(object):
|
||||
|
||||
self.air_date = air_date
|
||||
|
||||
self.sports_event_title = sports_event_title
|
||||
self.sports_event_date = sports_event_date
|
||||
|
||||
self.which_regex = None
|
||||
@ -355,15 +349,11 @@ class ParseResult(object):
|
||||
return to_return.encode('utf-8')
|
||||
|
||||
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.season_number == None: return self # can't work without a season
|
||||
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_season_numbers = []
|
||||
for epNo in self.episode_numbers:
|
||||
@ -398,7 +388,7 @@ class ParseResult(object):
|
||||
air_by_date = property(_is_air_by_date)
|
||||
|
||||
def _is_sports(self):
|
||||
if self.sports_event_title or self.sports_event_date:
|
||||
if self.sports_event_date:
|
||||
return True
|
||||
return False
|
||||
sports = property(_is_sports)
|
||||
|
@ -192,7 +192,7 @@ sports_regexs = [
|
||||
# Sports.Name.2010.11.23.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<extra_info>.+?)((?<![. _-])(?<!WEB)
|
||||
-(?P<release_group>[^- ]+))?)?$
|
||||
|
@ -152,7 +152,7 @@ def validate_name(pattern, multi=None, file_only=False, abd=False, sports=False)
|
||||
|
||||
try:
|
||||
result = parser.parse(new_name)
|
||||
except InvalidNameException:
|
||||
except InvalidNameException, e :
|
||||
logger.log(u"Unable to parse " + new_name + ", not valid", logger.DEBUG)
|
||||
return False
|
||||
|
||||
|
@ -259,10 +259,6 @@ class GenericProvider:
|
||||
if self.show.air_by_date or self.show.sports:
|
||||
useDate = True
|
||||
|
||||
regexMode = 0
|
||||
if self.show.sports:
|
||||
regexMode = 2
|
||||
|
||||
for ep_obj in ep_objs:
|
||||
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
|
||||
try:
|
||||
myParser = NameParser(False, regexMode=regexMode)
|
||||
myParser = NameParser(False)
|
||||
parse_result = myParser.parse(title).convert()
|
||||
except InvalidNameException:
|
||||
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
|
||||
try:
|
||||
myParser = NameParser(0)
|
||||
myParser = NameParser()
|
||||
parse_result = myParser.parse(name).convert()
|
||||
except InvalidNameException:
|
||||
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
|
||||
|
||||
if indexer_default:
|
||||
sickbeard.INDEXER_DEFAULT = indexer_default
|
||||
sickbeard.INDEXER_DEFAULT = config.to_int(indexer_default)
|
||||
|
||||
if time_preset:
|
||||
sickbeard.TIME_PRESET_W_SECONDS = time_preset
|
||||
@ -2130,7 +2130,7 @@ class NewHomeAddShows:
|
||||
|
||||
t.provided_show_dir = show_dir
|
||||
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
|
||||
|
||||
return _munge(t)
|
||||
|
@ -28,7 +28,8 @@ sys.path.append(os.path.abspath('../lib'))
|
||||
|
||||
import test_lib as test
|
||||
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
|
||||
|
||||
class XEMBasicTests(test.SickbeardTestDBCase):
|
||||
@ -49,39 +50,13 @@ class XEMBasicTests(test.SickbeardTestDBCase):
|
||||
|
||||
def test_formating(self):
|
||||
self.loadFromDB()
|
||||
show = sickbeard.helpers.findCertainShow(sickbeard.showList, 75978)
|
||||
ep = show.getEpisode(7, 6)
|
||||
ep.airdate = datetime.datetime.now()
|
||||
|
||||
print format(ep.episode, '02d')
|
||||
print format(ep.scene_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"
|
||||
# parse the name to break it into show name, season, and episode
|
||||
np = NameParser(file)
|
||||
parse_result = np.parse(release).convert()
|
||||
|
||||
search_string = {'Episode':[]}
|
||||
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))
|
||||
print(parse_result)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print "=================="
|
||||
|
Loading…
Reference in New Issue
Block a user