[webpages] Fix bad title scrapes
All checks were successful
build & deploy / test (push) Successful in 1m40s
build & deploy / deploy (push) Successful in 21s

This commit is contained in:
2026-03-14 13:58:21 -04:00
parent 223de52a12
commit 052d75ea26

View File

@ -161,9 +161,11 @@ class WebPage(ScrobblableMixin):
if not raw_text:
return
self.title = raw_text[raw_text.find("<title>") + 7 : raw_text.find("</title>")]
if not self.title and self.extract:
soup = BeautifulSoup(raw_text, "html.parser")
title_tag = soup.find("title")
if title_tag and title_tag.string:
self.title = title_tag.string
elif not self.title and self.extract:
first_line = self.extract.split("\n")[0]
self.title = first_line[:254]