#!/usr/bin/env python # -*- coding: utf-8 -*- # Patterns are either just a regex, or a tuple (or list of) that contains the regex # to match, (optional) what it should be replaced with when keep_raw is False (None # if to not replace), and (optional) a string function's name to transform the value # after everything (None if to do nothing). from .extras import * delimiters = '[\.\s\-\+_\/]' langs = [('rus(?:sian)?', 'Russian'), ('(?:True)?fr(?:ench)?', 'French'), ('ita(?:liano?)?', 'Italian'), ('castellano|spanish', 'Spanish'), ('swedish', 'Swedish'), ('dk|danish', 'Danish'), ('german', 'German'), ('nordic', 'Nordic'), ('exyu', 'ExYu'), ('chs', 'Chinese'), ('hindi', 'Hindi'), ('polish', 'Polish'), ('mandarin', 'Mandarin'), ('kor(?:ean)?', 'Korean'), ('en?(?:g(?:lish)?)?', 'English') # Must be at end, matches just an 'e' ] season_range_pattern = '(?:Complete' + delimiters + '*)?(?:' + delimiters + '*)?(?:s(?:easons?)?)?' + delimiters + \ '?(?:s?[0-9]{1,2}[\s]*(?:\-|(?:\s*to\s*))[\s]*s?[0-9]{1,2})(?:' + delimiters + '*Complete)?' lang_list_pattern = '(?:(?:' + link_pattern_options(langs) + ')' + delimiters + '*)' year_pattern = '(?:19[0-9]|20[0-2])[0-9]' month_pattern = '0[1-9]|1[0-2]' day_pattern = '[0-2][0-9]|3[01]' # Forces an order to go by the regexes, as we want this to be deterministic (different # orders can generate different matchings). e.g. "doctor_who_2005..." in input.json patterns_ordered = ['season', 'episode', 'year', 'month', 'day', 'resolution', 'quality', 'producer', 'codec', 'audio', 'region', 'extended', 'hardcoded', 'proper', 'repack', 'container', 'widescreen', 'website', 'subtitles', 'language', 'sbs', 'unrated', 'size', 'bitDepth', '3d', 'internal', 'readnfo'] patterns = dict() patterns['episode'] = '(?