Url: Use og:title meta property if found. Fixes #90.
This commit is contained in:
parent
69c18070f7
commit
11f2917d49
|
@ -114,7 +114,11 @@ class MatrixModule(BotModule):
|
||||||
# try parse and get the title
|
# try parse and get the title
|
||||||
try:
|
try:
|
||||||
soup = BeautifulSoup(r.text, "html.parser")
|
soup = BeautifulSoup(r.text, "html.parser")
|
||||||
if soup.head and soup.head.title:
|
# Prefer og:title first (for example Youtube uses this)
|
||||||
|
ogtitle = soup.find("meta", property="og:title")
|
||||||
|
if ogtitle:
|
||||||
|
title = ogtitle["content"]
|
||||||
|
elif soup.head and soup.head.title:
|
||||||
title = soup.head.title.string.strip()
|
title = soup.head.title.string.strip()
|
||||||
descr_tag = soup.find("meta", attrs={"name": "description"})
|
descr_tag = soup.find("meta", attrs={"name": "description"})
|
||||||
if descr_tag:
|
if descr_tag:
|
||||||
|
|
Loading…
Reference in New Issue