mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-02-06 06:40:34 +01:00
added logging for get yt link
This commit is contained in:
@@ -4,8 +4,10 @@ import urllib
|
||||
from html.parser import HTMLParser
|
||||
from urllib.request import Request
|
||||
|
||||
from app.commons import log
|
||||
|
||||
_YT_PATTERN = re.compile(r"https://www.youtube.com/.+(?:v=)([\w-]{11}).*")
|
||||
_YT_LIST_PATTERN = re.compile(r"https://www.youtube.com/.+?(?:list=)([\w-]{34})?.*")
|
||||
_YT_LIST_PATTERN = re.compile(r"https://www.youtube.com/.+?(?:list=)([\w-]{23,})?.*")
|
||||
_YT_VIDEO_PATTERN = re.compile(r"https://r\d+---sn-[\w]{10}-[\w]{3,5}.googlevideo.com/videoplayback?.*")
|
||||
_HEADERS = {"User-Agent": "Mozilla/5.0"}
|
||||
|
||||
@@ -46,7 +48,12 @@ class YouTube:
|
||||
s_map = {k: v for k, sep, v in (str(d).partition("=") for d in stream_map.split("&"))}
|
||||
url, title = s_map.get("url", None), out.get("title", None)
|
||||
return urllib.request.unquote(url) if url else "", title.replace("+", " ") if title else ""
|
||||
return "", ""
|
||||
|
||||
rsn = out.get("reason", None)
|
||||
rsn = rsn.replace("+", " ") if rsn else ""
|
||||
log("{}: Getting link to video with id {} filed! Cause: {}".format(__class__.__name__, video_id, rsn))
|
||||
|
||||
return "", rsn
|
||||
|
||||
|
||||
class PlayListParser(HTMLParser):
|
||||
@@ -75,7 +82,7 @@ class PlayListParser(HTMLParser):
|
||||
self._is_header = False
|
||||
|
||||
def error(self, message):
|
||||
pass
|
||||
log("{} Parsing error: {}".format(__class__.__name__, message))
|
||||
|
||||
@property
|
||||
def header(self):
|
||||
|
||||
Reference in New Issue
Block a user