support YouTube Music
This commit is contained in:
parent
6b5080220f
commit
6500a4e12c
|
@ -18,6 +18,7 @@ class YouTube:
|
|||
or "https://youtube.com/watch?v=" in i
|
||||
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
|
||||
]
|
||||
r = list(dict.fromkeys(r))
|
||||
return r
|
||||
|
@ -27,6 +28,9 @@ class YouTube:
|
|||
"https://www.youtube-nocookie.com/embed/"
|
||||
)
|
||||
|
||||
def is_ytmusic(str):
|
||||
return str.startswith("https://music.youtube.com/watch?v=")
|
||||
|
||||
class parseprop(HTMLParser):
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag != "meta" or [i for i in attrs if "itemprop" in i] == []:
|
||||
|
@ -64,6 +68,10 @@ class YouTube:
|
|||
if self.is_embed(url):
|
||||
videoId = url.split("/")[4]
|
||||
url = f"https://www.youtube.com/watch?v={videoId}"
|
||||
if self.is_ytmusic(url):
|
||||
for i in url.split("?")[1].split("&"):
|
||||
if i[0:2]=="v=": videoId=i[2:]
|
||||
url = f"https://www.youtube.com/watch?v={videoId}"
|
||||
global y, z
|
||||
y, z = {}, {}
|
||||
p = self.parseprop()
|
||||
|
|
Loading…
Reference in New Issue