mirror of
https://github.com/DYefremov/DemonEditor.git
synced 2026-05-07 15:27:34 +02:00
yt list import dialog skeleton
This commit is contained in:
@@ -4,7 +4,8 @@ import urllib
|
||||
from html.parser import HTMLParser
|
||||
from urllib.request import Request
|
||||
|
||||
_YT_PATTERN = re.compile(r"https://www.youtube.com/.+(?:v=|\/)([\w-]{11})&?(list=)?([\w-]{34})?.*")
|
||||
_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_VIDEO_PATTERN = re.compile(r"https://r\d+---sn-[\w]{10}-[\w]{3,5}.googlevideo.com/videoplayback?.*")
|
||||
_HEADERS = {"User-Agent": "Mozilla/5.0"}
|
||||
|
||||
@@ -23,6 +24,13 @@ class YouTube:
|
||||
if yt:
|
||||
return yt.group(1)
|
||||
|
||||
@staticmethod
|
||||
def get_yt_list_id(url):
|
||||
""" Returns playlist id or None """
|
||||
yt = re.search(_YT_LIST_PATTERN, url)
|
||||
if yt:
|
||||
return yt.group(1)
|
||||
|
||||
@staticmethod
|
||||
def get_yt_link(video_id):
|
||||
""" Getting link to YouTube video by id.
|
||||
|
||||
Reference in New Issue
Block a user