Skip to content

Commit

Permalink
fix title command for YouTube, NY Times, and probably other sites
Browse files Browse the repository at this point in the history
  • Loading branch information
dpk authored and sbp committed May 20, 2021
1 parent 3161958 commit d3f5a38
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions commands/title
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit d3f5a38

Please sign in to comment.