From 052d75ea26a32595c1f1a3b178614e512a5db827 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sat, 14 Mar 2026 13:58:21 -0400 Subject: [PATCH] [webpages] Fix bad title scrapes --- vrobbler/apps/webpages/models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vrobbler/apps/webpages/models.py b/vrobbler/apps/webpages/models.py index 5442779..89b37e5 100644 --- a/vrobbler/apps/webpages/models.py +++ b/vrobbler/apps/webpages/models.py @@ -161,9 +161,11 @@ class WebPage(ScrobblableMixin): if not raw_text: return - self.title = raw_text[raw_text.find("") + 7 : raw_text.find("")] - - 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]