youtube module, error when incorrect url (or otherwise failed to parse data from server)
This commit is contained in:
parent
03e3980d10
commit
3bd2c2dfb0
|
@ -59,7 +59,7 @@ class YouTube:
|
|||
return f"{m}m {s}s"
|
||||
|
||||
def yt(self, url):
|
||||
# self.util.mesg("hello")
|
||||
# self.util.mesg("dbg hello")
|
||||
url = url.rstrip("\x01")
|
||||
if self.is_embed(url):
|
||||
videoId = url.split("/")[4]
|
||||
|
@ -70,6 +70,11 @@ class YouTube:
|
|||
# url="https://www.youtube.com/watch?v=gyMpI8csWis"
|
||||
data = urlopen(url).read().decode()
|
||||
p.feed(data)
|
||||
if y == z == {}:
|
||||
irc_string = "[\x0304Youtube\x03] \x0307ERROR:\x0308,01 got no data from server! \x0315(check your URL for typos!)\x03"
|
||||
ansi_string = "[\x1b[31mYoutube\x1b[0m] \x1b[33;2;40mERROR:\x1b[33;1m got no data from server! \x1b[37;2m(check your URL for typos!)\x1b[0m"
|
||||
print(ansi_string)
|
||||
return irc_string
|
||||
z.update({"duration": self.fmt_dur(z["duration"])})
|
||||
url = f"https://www.youtube.com/channel/{z['channelId']}"
|
||||
data = urlopen(url).read().decode()
|
||||
|
|
Loading…
Reference in New Issue