Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# V.2009.S01E10.HDTV.XviD-2HD.avi.
match = re.match(r"""^(.+) \d{4}$""", name)
if match:
names.append(match.group(1))
# Searching for possible aliases <--
# Checking gotten data -->
for name in names:
if not re.search("[a-z0-9]", name):
raise Not_found()
if not season or not episode:
raise Not_found()
# Checking gotten data <--
except Not_found:
raise Not_found("This is not a TV show {0} file or it has non-standard file name.",
"subtitles" if is_subtitles else "video" )
if is_subtitles:
if extra_info and (
len(extra_info[-1]) == 2 and extra_info[-1] in LANGUAGES or
len(extra_info[-1]) == 3 and extra_info[-1] in LANGUAGES.values()
):
language = extra_info[-1]
else:
language = "en"
return ( names, season, episode, delimiter, language )
else:
return ( names, season, episode, delimiter, extra_info )
# Sometimes releasers include in the show name a year when TV show was
# started. For example, "V" TV show files was named as
# V.2009.S01E10.HDTV.XviD-2HD.avi.
match = re.match(r"""^(.+) \d{4}$""", name)
if match:
names.append(match.group(1))
# Searching for possible aliases <--
# Checking gotten data -->
for name in names:
if not re.search("[a-z0-9]", name):
raise Not_found()
if not season or not episode:
raise Not_found()
# Checking gotten data <--
except Not_found:
raise Not_found("This is not a TV show {0} file or it has non-standard file name.",
"subtitles" if is_subtitles else "video" )
if is_subtitles:
if extra_info and (
len(extra_info[-1]) == 2 and extra_info[-1] in LANGUAGES or
len(extra_info[-1]) == 3 and extra_info[-1] in LANGUAGES.values()
):
language = extra_info[-1]
else:
language = "en"
return ( names, season, episode, delimiter, language )
else:
# "The Mentalist" == "Mentalist"
if name.startswith("the "):
names.append(name[4:])
# Sometimes releasers include in the show name a year when TV show was
# started. For example, "V" TV show files was named as
# V.2009.S01E10.HDTV.XviD-2HD.avi.
match = re.match(r"""^(.+) \d{4}$""", name)
if match:
names.append(match.group(1))
# Searching for possible aliases <--
# Checking gotten data -->
for name in names:
if not re.search("[a-z0-9]", name):
raise Not_found()
if not season or not episode:
raise Not_found()
# Checking gotten data <--
except Not_found:
raise Not_found("This is not a TV show {0} file or it has non-standard file name.",
"subtitles" if is_subtitles else "video" )
if is_subtitles:
if extra_info and (
len(extra_info[-1]) == 2 and extra_info[-1] in LANGUAGES or
len(extra_info[-1]) == 3 and extra_info[-1] in LANGUAGES.values()
):
language = extra_info[-1]
else:
language = "en"
def __get_episodes(self, show_name, season):
"""Returns a list of episodes for which we have subtitles."""
shows = self.__get_shows()
if show_name in shows:
show = shows[show_name]
else:
raise Not_found()
try:
if season not in show["seasons"]:
episodes = {}
episode_list_url = self.__url_prefix + "tvshow-{0}-{1}.html".format(show["id"], season)
episode_list_html = get_url_contents(episode_list_url).decode("utf-8", errors = "replace")
all_episodes_regex = re.compile(r"""
]*){0,1}>\s*\s*
]*){0,1}>\s*
]*){0,1}\s+
href\s*=\s*["']{0,1}
/{0,1}episode-""" + str(show["id"]) + "-" + str(season) + r"""\.html
["']{0,1}
(\s[^>]*){0,1}>