Skip to content

Commit

Permalink
Merge pull request #174 from ZeroQI/EndOfLine369-patch-1
Browse files Browse the repository at this point in the history
Multiple Updates (again) by EndOfLine369
  • Loading branch information
ZeroQI authored Aug 19, 2018
2 parents dd180a5 + 49927bb commit 306101e
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions Scanners/Series/Absolute Series Scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@
ANIDB_TVDB_MAPPING = 'https://rawgit.com/ScudLee/anime-lists/master/anime-list-master.xml' #
ANIDB_TVDB_MAPPING_MOD = 'https://rawgit.com/ZeroQI/Absolute-Series-Scanner/master/anime-list-corrections.xml' #
ANIDB_TVDB_MAPPING_CUSTOM = 'anime-list-custom.xml' # custom local correction for ScudLee mapping file url
SOURCE_IDS = '\[((?P<source>(anidb|anidb2|tvdb|tvdb2|tvdb3|tvdb4|tvdb5|tmdb|tsdb|imdb|youtube|youtube2))-)?(?P<id>[^\[\]]*)\]' #
SOURCE_IDS = '\[((?P<source>(anidb|anidb2|tvdb|tvdb2|tvdb3|tvdb4|tvdb5|tmdb|tsdb|imdb|youtube|youtube2))-)?(?P<id>[^\[\]]*)\]' #
SOURCE_ID_FILES = ["anidb.id", "anidb2.id", "tvdb.id", "tvdb2.id", "tvdb3.id", "tvdb4.id", "tvdb5.id", "tmdb.id", "tsdb.id", "imdb.id", "youtube.id"] #
TVDB_MODE_IDS = ".*?\[tvdb(?P<mode>(2|3|4|5))-(tt)?(?P<guid>[0-9]{1,7})(-s[0-9]{1,3}(e[0-9]{1,3})?)?\]" #
TVDB_MODE_ID_OFFSET = ".*? ?\[(?P<source>(tvdb|tvdb2|tvdb3|tvdb4|tvdb5))-(tt)?[0-9]{1,7}-(?P<season>s[0-9]{1,3})?(?P<episode>e[0-9]{1,3})?\]" #
ANIDB2_MODE = ".*? ?\[anidb2-(?P<guid>[0-9]{1,7})\]" #
TVDB_MODE_IDS = "\[tvdb(?P<mode>(2|3|4|5))-(tt)?(?P<guid>[0-9]{1,7})(-s[0-9]{1,3}(e[0-9]{1,3})?)?\]" #
TVDB_MODE_ID_OFFSET = "\[(?P<source>(tvdb|tvdb2|tvdb3|tvdb4|tvdb5))-(tt)?[0-9]{1,7}-(?P<season>s[0-9]{1,3})?(?P<episode>e[0-9]{1,3})?\]" #
ANIDB2_MODE = "\[anidb2-(?P<guid>[0-9]{1,7})\]" #
SEASON_RX = [ ### Seasons Folders
'^Specials', # Specials (season 0)
'^(Season|Series|Book|Saison|Livre|S)[ _\-]*(?P<season>[0-9]{1,2})', # Season / Series / Book / Saison / Livre / S
'^(?P<show>.*?)[\._\- ]+[sS](?P<season>[0-9]{2})$', # (title) S01
'^(?P<show>.*?)[\._\- ]+S(?P<season>[0-9]{2})$', # (title) S01
'^(?P<season>[0-9]{1,2})', # ##
'^([Ss]aga]|([Ss]tory )?[Aa][Rr][KkCc])' # Last entry, folder name droped but files kept: Saga / Story Ar[kc] / Ar[kc]
'^(Saga|(Story )?Ar[kc])' # Last entry, folder name droped but files kept: Saga / Story Ar[kc] / Ar[kc]
] #
SERIES_RX = [ ######### Series regex - "serie - xxx - title" ###
'(^|(?P<show>.*?)[ _\.\-]+)(?P<season>[0-9]{1,2})[Xx](?P<ep>[0-9]{1,3})(([_\-Xx]|[_\-][0-9]{1,2}[Xx])(?P<ep2>[0-9]{1,3}))?([ _\.\-]+(?P<title>.*))?$', # 0 # 1x01
'(^|(?P<show>.*?)[ _\.\-]+)s(?P<season>[0-9]{1,2})([ _\.\-])?(e| e|ep| ep)(?P<ep>[0-9]{1,3})(([ _\.\-]|(e|ep)|[ _\.\-](e|ep))(?P<ep2>[0-9]{1,3}))?($|( | - |)(?P<title>.*?)$)', # 1 # s01e01-02 | ep01-ep02 | e01-02 | s01-e01 | s01 e01'(^|(?P<show>.*?)[ _\.\-]+)(?P<ep>[0-9]{1,3})[ _\.\-]?of[ _\.\-]?[0-9]{1,3}([ _\.\-]+(?P<title>.*?))?$', # 2 # 01 of 08 (no stacking for this one ?)
'^(?P<show>.*?) - (E|e|Ep|ep|EP)?(?P<ep>[0-9]{1,3})(-(?P<ep2>[0-9]{1,3}))?(v[0-9]{1})?( - |.)?(?P<title>.*)$', # 2 # Serie - xx - title.ext | ep01-ep02 | e01-02
'^(?P<show>.*?) \[(?P<season>[0-9]{1,2})\] \[(?P<ep>[0-9]{1,3})\] (?P<title>.*)$'] # 3 # Serie [Sxx] [Exxx] title.ext
'(^|(?P<show>.*?)[ _\.\-]+)(?P<season>[0-9]{1,2})X(?P<ep>[0-9]{1,3})(([_\-X]|[_\-][0-9]{1,2}X)(?P<ep2>[0-9]{1,3}))?([ _\.\-]+(?P<title>.*))?$', # 0 # 1x01
'(^|(?P<show>.*?)[ _\.\-]+)S(?P<season>[0-9]{1,2})[ _\.\-]?EP?(?P<ep>[0-9]{1,3})(([ _\.\-]|EP?|[ _\.\-]EP?)(?P<ep2>[0-9]{1,3}))?[ _\.]*(?P<title>.*?)$', # 1 # s01e01-02 | ep01-ep02 | e01-02 | s01-e01 | s01 e01'(^|(?P<show>.*?)[ _\.\-]+)(?P<ep>[0-9]{1,3})[ _\.\-]?of[ _\.\-]?[0-9]{1,3}([ _\.\-]+(?P<title>.*?))?$', # 2 # 01 of 08 (no stacking for this one ?)
'^(?P<show>.*?)[ _\.]-[ _\.](EP?)?(?P<ep>[0-9]{1,3})(-(?P<ep2>[0-9]{1,3}))?(V[0-9])?[ _\.]*?(?P<title>.*)$', # 2 # Serie - xx - title.ext | ep01-ep02 | e01-02
'^(?P<show>.*?)[ _\.]\[(?P<season>[0-9]{1,2})\][ _\.]\[(?P<ep>[0-9]{1,3})\][ _\.](?P<title>.*)$'] # 3 # Serie [Sxx] [Exxx] title.ext
#|Ep #
DATE_RX = [ '(?P<year>[0-9]{4})[^0-9a-zA-Z]+(?P<month>[0-9]{2})[^0-9a-zA-Z]+(?P<day>[0-9]{2})([^0-9]|$)', # 2009-02-10
'(?P<month>[0-9]{2})[^0-9a-zA-Z]+(?P<day>[0-9]{2})[^0-9a-zA-Z(]+(?P<year>[0-9]{4})([^0-9a-zA-Z]|$)', # 02-10-2009
DATE_RX = [ '(?P<year>[0-9]{4})\W+(?P<month>[0-9]{2})\W+(?P<day>[0-9]{2})([^0-9]|$)', # 2009-02-10
'(?P<month>[0-9]{2})\W+(?P<day>[0-9]{2})\W+(?P<year>[0-9]{4})(\W|$)', # 02-10-2009
] #https://support.plex.tv/articles/200381053-naming-date-based-tv-shows/
ANIDB_OFFSET = [0, 100, 150, 200, 400, 0, 0]; ###### AniDB Specials episode offset value array
ANIDB_RX = [ ###### AniDB Specials episode offset regex array
'(^|(?P<show>.*?)[ _\.\-]+)(SP|SPECIAL)[ _\.]?(?P<ep>\d{1,2})(-(?P<ep2>[0-9]{1,3}))?(v0|v1|v2|v3|v4|v5)?[ _\.]?(?P<title>.*)$', # 0 # 001-099 Specials
'(^|(?P<show>.*?)[ _\.\-]+)(OP|NCOP|OPENING)[ _\.]?(?P<ep>\d{1,2}[a-z]?)?[ _\.]?(v0|v1|v2|v3|v4|v5)?([ _\.\-]+(?P<title>.*))?$', # 1 # 100-149 Openings
'(^|(?P<show>.*?)[ _\.\-]+)(ED|NCED|ENDING)[ _\.]?(?P<ep>\d{1,2}[a-z]?)?[ _\.]?(v0|v1|v2|v3|v4|v5)?([ _\.\-]+(?P<title>.*))?$', # 2 # 150-199 Endings
'(^|(?P<show>.*?)[ _\.\-]+)(TRAILER|PROMO|PV|T)[ _\.]?(?P<ep>\d{1,2})[ _\.]?(v0|v1|v2|v3|v4|v5)?([ _\.\-]+(?P<title>.*))?$', # 3 # 200-299 Trailer, Promo with a number '(^|(?P<show>.*?)[ _\.\-]+)((?<=E)P|PARODY|PARODIES?) ?(?P<ep>\d{1,2})? ?(v2|v3|v4|v5)?(?P<title>.*)$', # 10 # 300-399 Parodies
'(^|(?P<show>.*?)[ _\.\-]+)(O|OTHERS?)(?P<ep>\d{1,2})[ _\.]?(v0|v1|v2|v3|v4|v5)?[ _\.\-]+(?P<title>.*)$', # 4 # 400-499 Others
'(^|(?P<show>.*?)[ _\.\-]+)(e|ep|e[ _\.]|ep[ _\.]|e-|ep-)?(?P<ep>[0-9]{1,3})((e|ep|-e|-ep|-)(?P<ep2>[0-9]{1,3})|)?[ _\.]?(v0|v1|v2|v3|v4|v5)?([ _\.\-]+(?P<title>.*))?$', # 5 # E01 | E01-02| E01-E02 | E01E02 # __ # look behind: (?<=S) < position < look forward: (?!S)
'(^|(?P<show>.*?)[ _\.\-]+)SP?[ _\.]?(?P<ep>\d{1,2})[ _\.]?(?P<title>.*)$'] # 6 # 001-099 Specials #'S' moved to the end to make sure season strings are not caught in prev regex
ANIDB_OFFSET = [0, 100, 150, 200, 400, 0, 0]; ###### AniDB Specials episode offset value array
ANIDB_RX = [ ###### AniDB Specials episode offset regex array
'(^|(?P<show>.*?)[ _\.\-]+)(SP|SPECIAL)[ _\.]?(?P<ep>\d{1,2})(-(?P<ep2>[0-9]{1,3}))?(V[0-9])?[ _\.]?(?P<title>.*)$', # 0 # 001-099 Specials
'(^|(?P<show>.*?)[ _\.\-]+)(OP|NCOP|OPENING)[ _\.]?(?P<ep>\d{1,2}[a-z]?)?[ _\.]?(V[0-9])?([ _\.\-]+(?P<title>.*))?$', # 1 # 100-149 Openings
'(^|(?P<show>.*?)[ _\.\-]+)(ED|NCED|ENDING)[ _\.]?(?P<ep>\d{1,2}[a-z]?)?[ _\.]?(V[0-9])?([ _\.\-]+(?P<title>.*))?$', # 2 # 150-199 Endings
'(^|(?P<show>.*?)[ _\.\-]+)(TRAILER|PROMO|PV|T)[ _\.]?(?P<ep>\d{1,2})[ _\.]?(V[0-9])?([ _\.\-]+(?P<title>.*))?$', # 3 # 200-299 Trailer, Promo with a number '(^|(?P<show>.*?)[ _\.\-]+)((?<=E)P|PARODY|PARODIES?) ?(?P<ep>\d{1,2})? ?(v2|v3|v4|v5)?(?P<title>.*)$', # 10 # 300-399 Parodies
'(^|(?P<show>.*?)[ _\.\-]+)(O|OTHERS?)(?P<ep>\d{1,2})[ _\.]?(V[0-9])?[ _\.\-]+(?P<title>.*)$', # 4 # 400-499 Others
'(^|(?P<show>.*?)[ _\.\-]+)(EP?[ _\.\-]?)?(?P<ep>[0-9]{1,3})((-|-?EP?)(?P<ep2>[0-9]{1,3})|)?[ _\.]?(V[0-9])?([ _\.\-]+(?P<title>.*))?$', # 5 # E01 | E01-02| E01-E02 | E01E02 # __ # look behind: (?<=S) < position < look forward: (?!S)
'(^|(?P<show>.*?)[ _\.\-]+)SP?[ _\.]?(?P<ep>\d{1,2})[ _\.]?(?P<title>.*)$'] # 6 # 001-099 Specials #'S' moved to the end to make sure season strings are not caught in prev regex
# Uses re.match() so forces a '^'
IGNORE_DIRS_RX = [ '@Recycle', '.@__thumb', 'lost\+found', '.AppleDouble','\$Recycle.Bin', 'System Volume Information', 'Temporary Items', 'Network Trash Folder', '@eaDir', ###### Ignored folders
IGNORE_DIRS_RX = [ '@Recycle', '.@__thumb', 'lost\+found', '.AppleDouble','\$Recycle.Bin', 'System Volume Information', 'Temporary Items', 'Network Trash Folder', '@eaDir', ###### Ignored folders
'Extras', 'Samples?', 'bonus', '.*bonus disc.*', 'trailers?', '.*_UNPACK_.*', '.*_FAILED_.*', 'misc', '_Misc'] #, "VIDEO_TS"] # source: Filters.py removed '\..*',
# Uses re.match() so forces a '^'
IGNORE_FILES_RX = ['[ _\.\-]sample', 'sample[ _\.\-]', '-Recap\.', 'OST', 'soundtrack', 'Thumbs.db', '\.xml$', '\.smi$', '^\._']#, '\.plexignore', '.*\.id'] #, '.*\.log$' # Skipped files (samples, trailers)
VIDEO_EXTS = [ '3g2', '3gp', 'asf', 'asx', 'avc', 'avi', 'avs', 'bin', 'bivx', 'divx', 'dv', 'dvr-ms', 'evo', 'fli', 'flv', 'img', 'iso', 'm2t', 'm2ts', 'm2v', #
'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mts', 'nrg', 'nsv', 'nuv', 'ogm', 'ogv', 'tp', 'pva', 'qt', 'rm', 'rmvb', 'sdp', 'swf', 'svq3', 'strm', #
'ts', 'ty', 'vdr', 'viv', 'vp3', 'wmv', 'wpl', 'wtv', 'xsp', 'xvid', 'webm', 'ifo', 'disc'] # DVD: 'ifo', 'bup', 'vob'
'ts', 'ty', 'vdr', 'viv', 'vp3', 'wmv', 'wpl', 'wtv', 'xsp', 'xvid', 'webm', 'ifo', 'disc'] # DVD: 'ifo', 'bup', 'vob'
FILTER_CHARS = "\\/:*?<>|~;" #_;. # Windows file naming limitations + "~-,._" + ';' as plex cut title at this for the agent
WHACK_PRE_CLEAN = [ "x264-FMD Release", "x264-h65", "x264-mSD", "x264-BAJSKORV", "x264-MgB", "x264-SYS", "x264-FQM", "x264-ASAP", "x264-QCF", "x264-W4F", 'x264-w4f', "x264-AAC",
'x264-2hd', "x264-ASAP", 'x264-bajskorv', 'x264-batv', "x264-BATV", "x264-EXCELLENCE", "x264-KILLERS", "x264-LOL", 'x264-MgB', 'x264-qcf', 'x264-SnowDoN', 'x264-xRed',
Expand Down Expand Up @@ -104,7 +104,7 @@
"mthd", "thora", 'sickrage', 'brrip', "remastered", "yify", "tsr", "reidy", "gerdhanse", 'remux', #'limited',
'rikou', 'hom?', "it00nz", "nn92", "mthd", "elysium", "encodebyjosh", "krissy", "reidy", "it00nz", "s4a" # Release group
]
CHARACTERS_MAP = { #Specials characters to re-map
CHARACTERS_MAP = { #Specials characters to re-map
14844057:"'", 14844051:'-', 14844052:'-', 14844070:'...', 15711386:':', 14846080:'∀', 15711646:'~', #['’' \xe2\x80\x99] ['–' \xe2\x80\x93] ['…' \xe2\x80\xa6] # ':' # 12770:'', # '∀ Gundam' no need #'´' ['\xc2', '\xb4']
50048:'A' , 50050:'A' , 50052:'Ä' , 50080:'a' , 50082:'a' , 50084:'a' , 50305:'a' , 50308:'A' , 50309:'a' , 50055:'C' , 50087:'c' , 50310:'C' , 50311:'c' , #'à' ['\xc3', '\xa0'] #'â' ['\xc3', '\xa2'] #'Ä' ['\xc3', '\x84'] #'ā' ['\xc4', '\x81'] #'À' ['\xc3', '\x80'] #'Â' ['\xc3', '\x82'] # 'Märchen Awakens Romance', 'Rozen Maiden Träumend' #'Ç' ['\xc3', '\x87'] #'ç' ['\xc3', '\xa7']
50057:'E' , 50088:'e' , 50089:'e' , 50090:'e' , 50091:'e' , 50323:'e' , 50328:'E' , 50329:'e' , #'É' ['\xc3', '\x89'] #'è' ['\xc3', '\xa8'] #'é' ['\xc3', '\xa9'] #'ē' ['\xc4', '\x93'] #'ê' ['\xc3', '\xaa'] #'ë' ['\xc3', '\xab']
Expand Down Expand Up @@ -758,7 +758,7 @@ def getmtime(name): return os.path.getmtime(os.path.join(root, path, name))
words, loop_completed, rx, is_special = filter(None, clean_string(ep, False, no_underscore=True).split()), False, "Word Search", False #
for word in words: #
ep=word.lower().strip('-.') # cannot use words[words.index(word)] otherwise# if word=='': continue filter prevent "" on double spaces
if ep.endswith(("v1", "v2", "v3", "v4", "v5")): ep=ep[:-2].rstrip('-.') #
if re.search("V[0-9]$", ep, re.IGNORECASE): ep=ep[:-2].rstrip('-.') #
if not ep: continue #
for prefix in ["ep", "e", "act", "s"]: #
if ep.startswith(prefix) and len(ep)>len(prefix) and re.search("^\d+(\.\d+)?$", ep[len(prefix):]):
Expand All @@ -772,7 +772,7 @@ def getmtime(name): return os.path.getmtime(os.path.join(root, path, name))
elif path and ( (misc.count(ep)==1 and len(files)>=2) or ep not in clean_string(folder_show, True).lower().split() ):
ep = ep.split('-',1)[0] if ''.join(letter for letter in ep.split('-',1)[0] if letter.isdigit()) else ep.split('-',1)[1]; # otherwise all after separator becomes word#words.insert(words.index(word)+1, "-".join(ep.split("-",1)[1:])) #.insert(len(a), x) is equivalent to a.append(x). #???
else: continue
if re.search("^((t|o)[0-9]{1,3}$|(sp|special|oav|op|ncop|opening|ed|nced|ending|trailer|promo|pv|others?)($|[0-9]{1,3}$))", ep): is_special = True; break # Specials go to regex # 's' is ignored as dealt with later in prefix processing # '(t|o)' require a number to make sure a word is not accidently matched
if re.search("^((t|o)[0-9]{1,3}$|(sp|special|op|ncop|opening|ed|nced|ending|trailer|promo|pv|others?)($|[0-9]{1,3}$))", ep): is_special = True; break # Specials go to regex # 's' is ignored as dealt with later in prefix processing # '(t|o)' require a number to make sure a word is not accidently matched
if ''.join(letter for letter in ep if letter.isdigit())=="": continue # Continue if there are no numbers in the string
if path and ep in misc_count.keys() and misc_count[ep]>=2: continue # Continue if not root folder and string found in in any other filename
if ep in clean_string(folder_show, True).split() and clean_string(filename, True).split().count(ep)!=2: continue # Continue if string is in the folder name & string is not in the filename only twice
Expand Down

0 comments on commit 306101e

Please sign in to comment.