diff --git a/lib/svtplay_dl/fetcher/dash.py b/lib/svtplay_dl/fetcher/dash.py index ada0953..96a98d2 100644 --- a/lib/svtplay_dl/fetcher/dash.py +++ b/lib/svtplay_dl/fetcher/dash.py @@ -69,7 +69,7 @@ def templateelemt(element, filename, idnumber, offset_sec, duration_sec): time = [0] for n in selements: time.append(int(n.attrib["d"])) - match = re.search("\$Time\$", name) + match = re.search(r"\$Time\$", name) if rvalue and match and len(selements) < 3: for n in range(start, start + total): new = name.replace("$Time$", str(n * int(rvalue[0].attrib["d"]))) @@ -81,7 +81,7 @@ def templateelemt(element, filename, idnumber, offset_sec, duration_sec): new = name.replace("$Time$", str(number)) files.append(urljoin(filename, new)) if "$Number" in name: - if re.search("\$Number(\%\d+)d\$", name): + if re.search(r"\$Number(\%\d+)d\$", name): vname = name.replace("$Number", "").replace("$", "") for n in range(start, start + total): files.append(urljoin(filename, vname % n)) diff --git a/lib/svtplay_dl/fetcher/hls.py b/lib/svtplay_dl/fetcher/hls.py index 1d5fcb0..e690f0a 100644 --- a/lib/svtplay_dl/fetcher/hls.py +++ b/lib/svtplay_dl/fetcher/hls.py @@ -423,7 +423,7 @@ class M3U8(): def _get_tag_attribute(line): line = line[1:] try: - search_line = re.search("^([A-Z\-]*):(.*)", line) + search_line = re.search(r"^([A-Z\-]*):(.*)", line) return search_line.group(1), search_line.group(2) except Exception: return line, None @@ -436,7 +436,7 @@ def _get_tuple_attribute(attribute): name, value = art_l.split("=", 1) name = name.strip() # Checks for attribute name - if not re.match("^[A-Z0-9\-]*$", name): + if not re.match(r"^[A-Z0-9\-]*$", name): raise ValueError("Not a valid attribute name.") # Remove extra quotes of string diff --git a/lib/svtplay_dl/postprocess/__init__.py b/lib/svtplay_dl/postprocess/__init__.py index b60cce1..b42f57f 100644 --- a/lib/svtplay_dl/postprocess/__init__.py +++ b/lib/svtplay_dl/postprocess/__init__.py @@ -214,7 +214,7 @@ class postprocess(object): os.rename(tempfile, orig_filename) def _checktracks(self, output): - allstuff = re.findall("Stream \#\d:(\d)\[[^\[]+\]([\(\)\w]+)?: (Video|Audio): (.*)", output) + allstuff = re.findall(r"Stream \#\d:(\d)\[[^\[]+\]([\(\)\w]+)?: (Video|Audio): (.*)", output) videotrack = 0 audiotrack = 1 for stream in allstuff: diff --git a/lib/svtplay_dl/service/cmore.py b/lib/svtplay_dl/service/cmore.py index e4d698e..f8d7e67 100644 --- a/lib/svtplay_dl/service/cmore.py +++ b/lib/svtplay_dl/service/cmore.py @@ -73,7 +73,7 @@ class Cmore(Service): parse = urlparse(self.url[0]) else: parse = urlparse(self.url) - return re.search('\.(\w{2})$', parse.netloc).group(1) + return re.search(r'\.(\w{2})$', parse.netloc).group(1) def _login(self): tld = self._gettld() diff --git a/lib/svtplay_dl/service/mtvnn.py b/lib/svtplay_dl/service/mtvnn.py index 55dea43..7039f52 100644 --- a/lib/svtplay_dl/service/mtvnn.py +++ b/lib/svtplay_dl/service/mtvnn.py @@ -20,13 +20,13 @@ class Mtvnn(Service, OpenGraphThumbMixin): parse = urlparse(self.url) if parse.netloc.endswith("se"): - match = re.search('
', data) + match = re.search(r'
', data) if not match: yield ServiceError("Can't find video info") return - match_id = re.search('data-id="([0-9a-fA-F|\-]+)" ', match.group(1)) + match_id = re.search(r'data-id="([0-9a-fA-F|\-]+)" ', match.group(1)) if not match_id: yield ServiceError("Can't find video info") diff --git a/lib/svtplay_dl/service/nhl.py b/lib/svtplay_dl/service/nhl.py index 31ed2f6..74a0d7c 100644 --- a/lib/svtplay_dl/service/nhl.py +++ b/lib/svtplay_dl/service/nhl.py @@ -12,7 +12,7 @@ class NHL(Service, OpenGraphThumbMixin): supported_domains = ['nhl.com'] def get(self): - match = re.search("var initialMedia\s+= ({[^;]+);", self.get_urldata()) + match = re.search(r"var initialMedia\s+= ({[^;]+);", self.get_urldata()) if not match: yield ServiceError("Cant find any media on that page") return @@ -29,7 +29,7 @@ class NHL(Service, OpenGraphThumbMixin): for n in list(streams.keys()): yield streams[n] else: - match = re.search("var mediaConfig\s+= ({[^;]+);", self.get_urldata()) + match = re.search(r"var mediaConfig\s+= ({[^;]+);", self.get_urldata()) if not match: yield ServiceError("Cant find any media on that page") return diff --git a/lib/svtplay_dl/service/oppetarkiv.py b/lib/svtplay_dl/service/oppetarkiv.py index 9e0ae5f..8ea44c4 100644 --- a/lib/svtplay_dl/service/oppetarkiv.py +++ b/lib/svtplay_dl/service/oppetarkiv.py @@ -138,12 +138,12 @@ class OppetArkiv(Service, OpenGraphThumbMixin): self.seasoninfo(datat) def seasoninfo(self, data): - match = re.search("S.song (\d+) - Avsnitt (\d+)", data) + match = re.search(r"S.song (\d+) - Avsnitt (\d+)", data) if match: self.output["season"] = int(match.group(1)) self.output["episode"] = int(match.group(2)) else: - match = re.search("Avsnitt (\d+)", data) + match = re.search(r"Avsnitt (\d+)", data) if match: self.output["episode"] = int(match.group(1)) diff --git a/lib/svtplay_dl/service/sr.py b/lib/svtplay_dl/service/sr.py index 79b266f..7e37243 100644 --- a/lib/svtplay_dl/service/sr.py +++ b/lib/svtplay_dl/service/sr.py @@ -18,7 +18,7 @@ class Sr(Service, OpenGraphThumbMixin): def get(self): data = self.get_urldata() - match = re.search('data-audio-type="publication" data-audio-id="(\d+)">', data) # Nyheter + match = re.search(r'data-audio-type="publication" data-audio-id="(\d+)">', data) # Nyheter if match: dataurl = "https://sverigesradio.se/sida/playerajax/" \ "getaudiourl?id={0}&type={1}&quality=high&format=iis".format(match.group(1), "publication") @@ -31,8 +31,8 @@ class Sr(Service, OpenGraphThumbMixin): yield HTTP(copy.copy(self.config), urljoin("https://sverigesradio.se", match.group(1)), 128) return else: - match = re.search('data-audio-type="episode" data-audio-id="(\d+)"', data) # Ladda ner med musik - match2 = re.search('data-audio-type="secondary" data-audio-id="(\d+)"', data) # Ladda ner utan musik + match = re.search(r'data-audio-type="episode" data-audio-id="(\d+)"', data) # Ladda ner med musik + match2 = re.search(r'data-audio-type="secondary" data-audio-id="(\d+)"', data) # Ladda ner utan musik if match: aid = match.group(1) type = "episode" diff --git a/lib/svtplay_dl/service/svtplay.py b/lib/svtplay_dl/service/svtplay.py index 8519345..ae6d8f1 100644 --- a/lib/svtplay_dl/service/svtplay.py +++ b/lib/svtplay_dl/service/svtplay.py @@ -48,7 +48,7 @@ class Svtplay(Service, MetadataThumbMixin): yield i return - match = re.search("__svtplay'] = ({.*});", self.get_urldata()) + match = re.search(r"__svtplay'] = ({.*});", self.get_urldata()) if not match: yield ServiceError("Can't find video info.") return @@ -274,8 +274,7 @@ class Svtplay(Service, MetadataThumbMixin): return season, episode def extrametadata(self, data): - self.output["tvshow"] = (self.output["season"] is not None and - self.output["episode"] is not None) + self.output["tvshow"] = (self.output["season"] is not None and self.output["episode"] is not None) try: self.output["publishing_datetime"] = data["video"]["broadcastDate"] / 1000 except KeyError: diff --git a/lib/svtplay_dl/service/tv4play.py b/lib/svtplay_dl/service/tv4play.py index 94fa807..a1f3508 100644 --- a/lib/svtplay_dl/service/tv4play.py +++ b/lib/svtplay_dl/service/tv4play.py @@ -83,7 +83,7 @@ class Tv4play(Service, OpenGraphThumbMixin): yield streams[n] def _getjson(self): - match = re.search(".prefetched = (\[.*\]);", self.get_urldata()) + match = re.search(r".prefetched = (\[.*\]);", self.get_urldata()) return match def find_all_episodes(self, config): diff --git a/lib/svtplay_dl/service/twitch.py b/lib/svtplay_dl/service/twitch.py index 0df2c01..8ae9a93 100644 --- a/lib/svtplay_dl/service/twitch.py +++ b/lib/svtplay_dl/service/twitch.py @@ -152,11 +152,11 @@ class Twitch(Service): yield streams[n] def _get_clips(self): - match = re.search("quality_options: (\[[^\]]+\])", self.get_urldata()) + match = re.search(r"quality_options: (\[[^\]]+\])", self.get_urldata()) if not match: yield ServiceError("Can't find the video clip") return - name = re.search('slug: "([^"]+)"', self.get_urldata()).group(1) + name = re.search(r'slug: "([^"]+)"', self.get_urldata()).group(1) brodcaster = re.search('broadcaster_login: "([^"]+)"', self.get_urldata()).group(1) self.output["title"] = "twitch-{0}".format(brodcaster) self.output["episodename"] = name diff --git a/lib/svtplay_dl/service/urplay.py b/lib/svtplay_dl/service/urplay.py index e4e24b2..03a111d 100644 --- a/lib/svtplay_dl/service/urplay.py +++ b/lib/svtplay_dl/service/urplay.py @@ -79,14 +79,14 @@ class Urplay(Service, OpenGraphThumbMixin): if url not in episodes: episodes.append(url) else: - match = re.search("/program/\d+-(\w+)-", parse.path) + match = re.search(r"/program/\d+-(\w+)-", parse.path) if not match: log.error("Can't find any videos") return None keyword = match.group(1) all_links = re.findall('card-link" href="([^"]+)"', self.get_urldata()) for i in all_links: - match = re.search("/program/\d+-(\w+)-", i) + match = re.search(r"/program/\d+-(\w+)-", i) if match and match.group(1) == keyword: episodes.append(urljoin("https://urplay.se/", i)) diff --git a/lib/svtplay_dl/service/viaplay.py b/lib/svtplay_dl/service/viaplay.py index 5a023b0..bb5e9af 100644 --- a/lib/svtplay_dl/service/viaplay.py +++ b/lib/svtplay_dl/service/viaplay.py @@ -53,7 +53,7 @@ class Viaplay(Service, OpenGraphThumbMixin): jansson = json.loads(match.group(1)) if "seasonNumberOrVideoId" in jansson: season = jansson["seasonNumberOrVideoId"] - match = re.search("\w-(\d+)$", season) + match = re.search(r"\w-(\d+)$", season) if match: season = match.group(1) else: @@ -66,18 +66,18 @@ class Viaplay(Service, OpenGraphThumbMixin): return None if "videoIdOrEpisodeNumber" in jansson: videp = jansson["videoIdOrEpisodeNumber"] - match = re.search('(\w+)-(\d+)', videp) + match = re.search(r'(\w+)-(\d+)', videp) if match: episodenr = match.group(2) else: episodenr = videp clips = True - match = re.search('(s\w+)-(\d+)', season) + match = re.search(r'(s\w+)-(\d+)', season) if match: season = match.group(2) else: # sometimes videoIdOrEpisodeNumber does not work.. this is a workaround - match = re.search('(episode|avsnitt)-(\d+)', self.url) + match = re.search(r'(episode|avsnitt)-(\d+)', self.url) if match: episodenr = match.group(2) else: @@ -197,7 +197,7 @@ class Viaplay(Service, OpenGraphThumbMixin): def find_all_episodes(self, config): seasons = [] - match = re.search("(sasong|sesong)-(\d+)", urlparse(self.url).path) + match = re.search(r"(sasong|sesong)-(\d+)", urlparse(self.url).path) if match: seasons.append(match.group(2)) else: @@ -215,9 +215,9 @@ class Viaplay(Service, OpenGraphThumbMixin): def _grab_episodes(self, config, seasons): episodes = [] baseurl = self.url - match = re.search("(saeson|sasong|sesong)-\d+", urlparse(self.url).path) + match = re.search(r"(saeson|sasong|sesong)-\d+", urlparse(self.url).path) if match: - if re.search("(avsnitt|episode)", urlparse(baseurl).path): + if re.search(r"(avsnitt|episode)", urlparse(baseurl).path): baseurl = baseurl[:baseurl.rfind("/")] baseurl = baseurl[:baseurl.rfind("/")] @@ -238,15 +238,15 @@ class Viaplay(Service, OpenGraphThumbMixin): return episodes def _isswe(self, url): - if re.search(".se$", urlparse(url).netloc): + if re.search(r".se$", urlparse(url).netloc): return "sasong" - elif re.search(".dk$", urlparse(url).netloc): + elif re.search(r".dk$", urlparse(url).netloc): return "saeson" else: return "sesong" def _conentpage(self, data): - return re.search('=({"sportsPlayer.*}); window.__config', data) + return re.search(r'=({"sportsPlayer.*}); window.__config', data) def _videos_to_list(self, url, vid, episodes): dataj = json.loads(self._get_video_data(vid).text) diff --git a/lib/svtplay_dl/subtitle/__init__.py b/lib/svtplay_dl/subtitle/__init__.py index 98585fe..b3a29a3 100644 --- a/lib/svtplay_dl/subtitle/__init__.py +++ b/lib/svtplay_dl/subtitle/__init__.py @@ -141,7 +141,7 @@ class subtitle(object): try: number = int(sub.attrib["SpotNumber"]) except ValueError: - number = int(re.search("(\d+)", sub.attrib["SpotNumber"]).group(1)) + number = int(re.search(r"(\d+)", sub.attrib["SpotNumber"]).group(1)) increase += 1 n = number + increase @@ -365,7 +365,7 @@ def tt_text(node, data): def strdate(datestring): - match = re.search("^(\d+:\d+:[\.0-9]+) --> (\d+:\d+:[\.0-9]+)", datestring) + match = re.search(r"^(\d+:\d+:[\.0-9]+) --> (\d+:\d+:[\.0-9]+)", datestring) return match diff --git a/lib/svtplay_dl/utils/getmedia.py b/lib/svtplay_dl/utils/getmedia.py index a5ff471..53bb45f 100644 --- a/lib/svtplay_dl/utils/getmedia.py +++ b/lib/svtplay_dl/utils/getmedia.py @@ -116,7 +116,7 @@ def get_one_media(stream): videos.append(i) if isinstance(i, subtitle): subs.append(i) - except Exception as e: + except Exception: if stream.config.get("verbose"): raise else: diff --git a/lib/svtplay_dl/utils/output.py b/lib/svtplay_dl/utils/output.py index 917c6cd..6b9bcb9 100644 --- a/lib/svtplay_dl/utils/output.py +++ b/lib/svtplay_dl/utils/output.py @@ -133,8 +133,7 @@ def formatname(output, config, extension="mp4"): if not output.get("basedir", False): # If tvshow have not been derived by service do it by if season and episode is set if output.get("tvshow", None) is None: - tvshow = (output.get("season", None) is not None and - output.get("episode", None) is not None) + tvshow = (output.get("season", None) is not None and output.get("episode", None) is not None) else: tvshow = output.get("tvshow", False) if config.get("subfolder") and "title" in output and tvshow: @@ -175,9 +174,9 @@ def _formatname(output, config, extension): name = name.replace("{ext}", output[key]) # Remove all {text} we cant replace with something - for item in re.findall("([\.\-]?(([^\.\-]+\w+)?\{[\w\-]+\}))", name): - if "season" in output and output["season"] and re.search("(e\{[\w\-]+\})", name): - name = name.replace(re.search("(e\{[\w\-]+\})", name).group(1), "") + for item in re.findall(r"([\.\-]?(([^\.\-]+\w+)?\{[\w\-]+\}))", name): + if "season" in output and output["season"] and re.search(r"(e\{[\w\-]+\})", name): + name = name.replace(re.search(r"(e\{[\w\-]+\})", name).group(1), "") else: name = name.replace(item[0], "")