add handling of missing urls

This commit is contained in:
Thomas Peetz
2025-11-07 08:00:52 +01:00
parent 4a2048c378
commit 6c71086104
+16 -13
View File
@@ -45,19 +45,22 @@ if __name__ == '__main__':
log.info(f"{item['id']} - {str(link)}")
if not link:
continue
try:
r = requests.get(link)
soup = BeautifulSoup(r.content, "html.parser")
title_tag = soup.find('title')
if title_tag:
title= title_tag.get_text()
title = soup.title.string
item['title'] = title
item['review'] = False
except Exception as error:
log.info(f"something went wrong: {error}")
item['title'] = None
item['review'] = True
if link == "None":
item['url'] = None
else:
try:
r = requests.get(link)
soup = BeautifulSoup(r.content, "html.parser")
title_tag = soup.find('title')
if title_tag:
title= title_tag.get_text()
title = soup.title.string
item['title'] = title
item['review'] = False
except Exception as error:
log.info(f"something went wrong: {error}")
item['title'] = None
item['review'] = True
update = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}", json=item)
log.info(f"update status: {update.status_code}")
log.info(f"update result: {update.json()}")