diff --git a/modules/url.py b/modules/url.py index 7cb6df3..5a8a7b4 100755 --- a/modules/url.py +++ b/modules/url.py @@ -30,6 +30,22 @@ def get_puush_fname(bot, url): bot.msg(f"[ \x0310puu.sh \x03] - \x0304{fname}") +@url_callback("youtube.com/") +@url_callback("youtu.be/") +def youtube_title(bot, url): + """ + Retrieve the title of the YouTube video and display it. + """ + url = "https://www.youtube.com/oembed?url=" + url + res = requests.get(url) + res.raise_for_status() + + title = res.json()['title'] + hostname = urlparse(url).hostname + + bot.msg(f"[ \x0310{title} \x03] - \x0304{hostname}") + + @hook(True) def title_auto(bot, trigger): """ @@ -45,6 +61,7 @@ def title_auto(bot, trigger): return for url in urls: + url = url.replace('twitter.com', 'nitter.net') broken = False for key in bot.url_callbacks: if key in url: diff --git a/modules/youtube.py b/modules/youtube.py deleted file mode 100644 index e5e7cdb..0000000 --- a/modules/youtube.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 -""" -Display the YouTube video titles. -""" -from urllib.parse import urlparse - -import requests - -from module import url_callback - -@url_callback("youtube.com/") -@url_callback("youtu.be/") -def youtube_title(bot, url): - """ - Retrieve the title of the YouTube video and display it. - """ - url = "https://www.youtube.com/oembed?url=" + url - res = requests.get(url) - res.raise_for_status() - - title = res.json()['title'] - hostname = urlparse(url).hostname - - bot.msg(f"[ \x0310{title} \x03] - \x0304{hostname}")