mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-12 11:02:21 -05:00
Quality is now set during parsing of results.
Fixed more anime regex bugs. Fixed Indexer API issues for anime shows and unicode problems.
This commit is contained in:
parent
31ce517e8f
commit
24dfbc3f15
@ -598,11 +598,11 @@ class Tvdb:
|
||||
zipdata = StringIO.StringIO()
|
||||
zipdata.write(resp.content)
|
||||
myzipfile = zipfile.ZipFile(zipdata)
|
||||
return xmltodict.parse(myzipfile.read('%s.xml' % language).strip(), postprocessor=process)
|
||||
return xmltodict.parse(myzipfile.read('%s.xml' % language).strip().encode('utf-8'), postprocessor=process)
|
||||
except zipfile.BadZipfile:
|
||||
raise tvdb_error("Bad zip file received from thetvdb.com, could not read it")
|
||||
else:
|
||||
return xmltodict.parse(resp.content.strip(), postprocessor=process)
|
||||
return xmltodict.parse(resp.content.strip().encode('utf-8'), postprocessor=process)
|
||||
|
||||
def _getetsrc(self, url, params=None, language=None):
|
||||
"""Loads a URL using caching, returns an ElementTree of the source
|
||||
|
@ -462,7 +462,7 @@ class TVRage:
|
||||
return (key, value)
|
||||
|
||||
if resp.ok:
|
||||
return xmltodict.parse(resp.content.strip(), postprocessor=remap_keys)
|
||||
return xmltodict.parse(resp.content.strip().encode('utf-8'), postprocessor=remap_keys)
|
||||
|
||||
def _getetsrc(self, url, params=None):
|
||||
"""Loads a URL using caching, returns an ElementTree of the source
|
||||
@ -527,6 +527,7 @@ class TVRage:
|
||||
if not isinstance(data, dict or list):
|
||||
data = data.replace(u"&", u"&")
|
||||
data = data.strip()
|
||||
|
||||
return data
|
||||
|
||||
def search(self, series):
|
||||
@ -597,7 +598,7 @@ class TVRage:
|
||||
self.config['params_epInfo']['sid'] = sid
|
||||
epsEt = self._getetsrc(self.config['url_epInfo'], self.config['params_epInfo'])
|
||||
|
||||
for season in epsEt['episodelist']['season']:
|
||||
for season in epsEt['episodelist'].values():
|
||||
episodes = season['episode']
|
||||
if not isinstance(episodes, list):
|
||||
episodes = [episodes]
|
||||
|
@ -163,12 +163,12 @@ class AllShowsListUI:
|
||||
continue
|
||||
|
||||
if 'seriesname' in curShow:
|
||||
seriesnames.append(unicode(curShow['seriesname']))
|
||||
seriesnames.append(curShow['seriesname'].encode('utf-8'))
|
||||
if 'aliasnames' in curShow:
|
||||
seriesnames.extend(unicode(curShow['aliasnames']).split('|'))
|
||||
seriesnames.extend(curShow['aliasnames'].encode('utf-8').split('|'))
|
||||
|
||||
for name in seriesnames:
|
||||
if str(searchterm).lower() in str(name).lower():
|
||||
if searchterm.lower() in name.lower():
|
||||
if 'firstaired' not in curShow:
|
||||
curShow['firstaired'] = str(datetime.date.fromordinal(1))
|
||||
curShow['firstaired'] = re.sub("([-]0{2}){1,}", "", curShow['firstaired'])
|
||||
|
@ -23,7 +23,7 @@ import threading
|
||||
import regexes
|
||||
import sickbeard
|
||||
|
||||
from sickbeard import logger, helpers, scene_numbering
|
||||
from sickbeard import logger, helpers, scene_numbering, common
|
||||
from dateutil import parser
|
||||
|
||||
nameparser_lock = threading.Lock()
|
||||
@ -214,6 +214,7 @@ class NameParser(object):
|
||||
result.score += 1
|
||||
elif self.showObj.anime and len(result.ab_episode_numbers):
|
||||
result.score += 1
|
||||
|
||||
matches.append(result)
|
||||
continue
|
||||
|
||||
@ -234,6 +235,10 @@ class NameParser(object):
|
||||
if len(matches):
|
||||
result = max(matches, key=lambda x: x.score)
|
||||
|
||||
# get quality
|
||||
if result.show:
|
||||
result.quality = common.Quality.nameQuality(name, bool(result.show and result.show.is_anime))
|
||||
|
||||
return result
|
||||
|
||||
def _combine_results(self, first, second, attr):
|
||||
@ -355,6 +360,7 @@ class NameParser(object):
|
||||
final_result.which_regex += dir_name_result.which_regex
|
||||
|
||||
final_result.show = self._combine_results(file_name_result, dir_name_result, 'show')
|
||||
final_result.quality = self._combine_results(file_name_result, dir_name_result, 'quality')
|
||||
|
||||
# if there's no useful info in it then raise an exception
|
||||
if final_result.season_number == None and not final_result.episode_numbers and final_result.air_date == None and not final_result.series_name:
|
||||
@ -380,7 +386,8 @@ class ParseResult(object):
|
||||
air_date=None,
|
||||
ab_episode_numbers=None,
|
||||
show=None,
|
||||
score=None
|
||||
score=None,
|
||||
quality=None
|
||||
):
|
||||
|
||||
self.original_name = original_name
|
||||
@ -397,6 +404,11 @@ class ParseResult(object):
|
||||
else:
|
||||
self.ab_episode_numbers = ab_episode_numbers
|
||||
|
||||
if not quality:
|
||||
self.quality = common.Quality.UNKNOWN
|
||||
else:
|
||||
self.quality = quality
|
||||
|
||||
self.extra_info = extra_info
|
||||
self.release_group = release_group
|
||||
|
||||
@ -438,6 +450,8 @@ class ParseResult(object):
|
||||
return False
|
||||
if self.score != other.score:
|
||||
return False
|
||||
if self.quality != other.quality:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
@ -222,8 +222,8 @@ anime_regexes = {'anime':[
|
||||
"""
|
||||
^(?:\[(?P<release_group>.+?)\][ ._-]*)
|
||||
(?P<series_name>.+?)[ ._-]+
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3})
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))?[ ._-]+?
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+)
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))?[ ._-]+?
|
||||
(?:v(?P<version>[0-9]))?
|
||||
(?:[\w\.]*)
|
||||
(?:(?:(?:[\[\(])(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)(?:[\]\)]))|(?:\d{3,4}[xp]))
|
||||
@ -241,8 +241,8 @@ anime_regexes = {'anime':[
|
||||
'''
|
||||
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
|
||||
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # E01
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # E01
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # E02
|
||||
(v(?P<version>[0-9]))? # version
|
||||
[ ._-]+\[(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)\] # Source_Quality_Etc-
|
||||
(\[(?P<crc>\w{8})\])? # CRC
|
||||
@ -256,8 +256,8 @@ anime_regexes = {'anime':[
|
||||
'''
|
||||
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
|
||||
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # E01
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # E01
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # E02
|
||||
(v(?P<version>[0-9]))? # version
|
||||
[ ._-]+\((?P<extra_info>(CX[ ._-]?)?\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)\) # Source_Quality_Etc-
|
||||
(\[(?P<crc>\w{8})\])? # CRC
|
||||
@ -269,8 +269,8 @@ anime_regexes = {'anime':[
|
||||
'''
|
||||
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
|
||||
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # E01
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # E01
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # E02
|
||||
(v(?P<version>[0-9]))? # version
|
||||
[ ._-]+\[(?P<extra_info>\d{3,4}p) # Source_Quality_Etc-
|
||||
(\[(?P<crc>\w{8})\])? # CRC
|
||||
@ -285,8 +285,8 @@ anime_regexes = {'anime':[
|
||||
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
|
||||
(?P<series_name>.+?)[ ._]* # Show_Name and separator
|
||||
([ ._-]+-[ ._-]+[A-Z]+[ ._-]+)?[ ._-]+ # funny stuff, this is sooo nuts ! this will kick me in the butt one day
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # E01
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # E01
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # E02
|
||||
(v(?P<version>[0-9]))? # version
|
||||
([ ._-](\[\w{1,2}\])?\[[a-z][.]?\w{2,4}\])? #codec
|
||||
[ ._-]*\[(?P<extra_info>(\d{3,4}[xp]?\d{0,4})?[\.\w\s-]*)\] # Source_Quality_Etc-
|
||||
@ -315,8 +315,8 @@ anime_regexes = {'anime':[
|
||||
(([. _-]*e|-) # linking e/- char
|
||||
(?P<extra_ep_num>\d+))* # additional E03/etc
|
||||
([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # absolute number
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # absolute number
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # "-" as separator and anditional absolute number, all optinal
|
||||
(v(?P<version>[0-9]))? # the version e.g. "v2"
|
||||
.*?
|
||||
'''
|
||||
@ -334,8 +334,8 @@ anime_regexes = {'anime':[
|
||||
(([. _-]*e|-) # linking e/- char
|
||||
(?P<extra_ep_num>\d+))* # additional E03/etc
|
||||
([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # absolute number
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # absolute number
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # "-" as separator and anditional absolute number, all optinal
|
||||
(v(?P<version>[0-9]))? # the version e.g. "v2"
|
||||
.*?
|
||||
'''
|
||||
@ -346,8 +346,8 @@ anime_regexes = {'anime':[
|
||||
# Bleach - 313-314 - s16e03-04
|
||||
'''
|
||||
^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # absolute number
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # absolute number
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # "-" as separator and anditional absolute number, all optinal
|
||||
(v(?P<version>[0-9]))? # the version e.g. "v2"
|
||||
([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be there(->{2,}) "s16e03-04-313-314" would make sens any way
|
||||
[sS](?P<season_num>\d+)[. _-]* # S01 and optional separator
|
||||
@ -361,8 +361,8 @@ anime_regexes = {'anime':[
|
||||
('anime_and_normal_front',
|
||||
# 165.Naruto Shippuuden.s08e014
|
||||
'''
|
||||
^(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # start of string and absolute number
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
|
||||
^(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # start of string and absolute number
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # "-" as separator and anditional absolute number, all optinal
|
||||
(v(?P<version>[0-9]))?[ ._-]+ # the version e.g. "v2"
|
||||
(?P<series_name>.+?)[ ._-]+
|
||||
[sS](?P<season_num>\d+)[. _-]* # S01 and optional separator
|
||||
@ -377,8 +377,8 @@ anime_regexes = {'anime':[
|
||||
'''
|
||||
^(?:\[(?P<release_group>.+?)\][ ._-]*)
|
||||
(?P<series_name>.+?)[ ._-]+
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3})
|
||||
(-(?P<extra_ab_ep_num>\d{1,3}))?[ ._-]*?
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+)
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))?[ ._-]*?
|
||||
(?:v(?P<version>[0-9])[ ._-]+?)?
|
||||
(?:.+?[ ._-]+?)?
|
||||
\[(?P<extra_info>\w+)\][ ._-]?
|
||||
@ -393,8 +393,8 @@ anime_regexes = {'anime':[
|
||||
'''
|
||||
^(\[(?P<release_group>.+?)\][ ._-]*)?
|
||||
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d{1,3}) # E01
|
||||
(-(?P<extra_ab_ep_num>\d{3}))? # E02
|
||||
(?P<ep_ab_num>(?!(1080|720|480)[pi])\d+) # E01
|
||||
(-(?P<extra_ab_ep_num>(?!(1080|720|480)[pi])\d+))? # E02
|
||||
(v(?P<version>[0-9]))? # v2
|
||||
.*? # Separator and EOL
|
||||
''')
|
||||
|
@ -498,7 +498,7 @@ class PostProcessor(object):
|
||||
season = parse_result.season_number
|
||||
episodes = parse_result.episode_numbers
|
||||
|
||||
to_return = (parse_result.show, season, episodes, None)
|
||||
to_return = (parse_result.show, season, episodes, parse_result.quality)
|
||||
|
||||
self._finalize(parse_result)
|
||||
return to_return
|
||||
|
@ -284,7 +284,7 @@ class GenericProvider:
|
||||
logger.log(u"Unable to parse the filename " + title + " into a valid episode", logger.WARNING)
|
||||
continue
|
||||
|
||||
quality = self.getQuality(item, parse_result.is_anime)
|
||||
quality = parse_result.quality
|
||||
|
||||
if not (self.show.air_by_date or self.show.sports):
|
||||
if search_mode == 'sponly' and len(parse_result.episode_numbers):
|
||||
|
@ -200,7 +200,7 @@ class TVShow(object):
|
||||
ep = None
|
||||
|
||||
# if we get an anime get the real season and episode
|
||||
if self.is_anime and not self.is_scene and absolute_number and not season and not episode:
|
||||
if self.is_anime and absolute_number and not season and not episode:
|
||||
myDB = db.DBConnection()
|
||||
sql = "SELECT * FROM tv_episodes WHERE showid = ? and absolute_number = ? and season != 0"
|
||||
sqlResults = myDB.select(sql, [self.indexerid, absolute_number])
|
||||
|
@ -2191,6 +2191,8 @@ class NewHomeAddShows:
|
||||
if not lang or lang == 'null':
|
||||
lang = "en"
|
||||
|
||||
search_term = search_term.encode('utf-8')
|
||||
|
||||
results = {}
|
||||
final_results = []
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user