From d3f5a388c048fab36c398b702fe8222451de3319 Mon Sep 17 00:00:00 2001 From: Daphne Preston-Kendal Date: Thu, 20 May 2021 09:42:51 +0200 Subject: [PATCH] fix title command for YouTube, NY Times, and probably other sites --- commands/title | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/commands/title b/commands/title index 3b3b3c2..391850e 100755 --- a/commands/title +++ b/commands/title @@ -68,14 +68,9 @@ def title(url): if blacklisted in url: return "Sorry, domain is blacklisted" - if "nytimes.com" in url: - return url.rsplit(".html", 1)[0].rsplit("/").pop() - - if (url.startswith("https://youtube.com/watch?v=") or - url.startswith("https://www.youtube.com/watch?v=")): - url = url.replace("/watch?v=", "/embed/", 1) - - page = saxo.request(url, limit=262144, follow=True) + page = saxo.request(url, limit=262144, follow=True, headers={ + "User-Agent": "saxo/0.0 (OpenGraph)" + }) if "html" not in page: return "Sorry, page isn't HTML" text = regex_script.sub("", page["html"])