support youtube shorts
This commit is contained in:
parent
6500a4e12c
commit
19e223ef99
|
@ -19,6 +19,8 @@ class YouTube:
|
|||
or "https://www.youtube.com/embed/" in i
|
||||
or "https://www.youtube-nocookie.com/embed/" in i
|
||||
or "https://music.youtube.com/watch?v=" in i
|
||||
or "https://youtube.com/shorts/" in i
|
||||
or "https://www.youtube.com/shorts/" in i
|
||||
]
|
||||
r = list(dict.fromkeys(r))
|
||||
return r
|
||||
|
@ -31,6 +33,9 @@ class YouTube:
|
|||
def is_ytmusic(str):
|
||||
return str.startswith("https://music.youtube.com/watch?v=")
|
||||
|
||||
def is_ytshorts(str):
|
||||
return str.startswith("https://youtube.com/shorts/") or str.startswith("https://www.youtube.com/shorts/")
|
||||
|
||||
class parseprop(HTMLParser):
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag != "meta" or [i for i in attrs if "itemprop" in i] == []:
|
||||
|
@ -72,6 +77,9 @@ class YouTube:
|
|||
for i in url.split("?")[1].split("&"):
|
||||
if i[0:2]=="v=": videoId=i[2:]
|
||||
url = f"https://www.youtube.com/watch?v={videoId}"
|
||||
if self.is_ytshorts(url):
|
||||
videoId=url.split("?")[0].split("/")[-1]
|
||||
url = f"https://www.youtube.com/watch?v={videoId}"
|
||||
global y, z
|
||||
y, z = {}, {}
|
||||
p = self.parseprop()
|
||||
|
|
Loading…
Reference in New Issue