mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 04:05:39 +01:00
flake8: new version detecting more stuff
This commit is contained in:
parent
b034d92773
commit
ca295d461d
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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()
|
||||
|
@ -20,13 +20,13 @@ class Mtvnn(Service, OpenGraphThumbMixin):
|
||||
parse = urlparse(self.url)
|
||||
|
||||
if parse.netloc.endswith("se"):
|
||||
match = re.search('<div class="video-player" (.*)>', data)
|
||||
match = re.search(r'<div class="video-player" (.*)>', 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")
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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], "")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user