add add_link.py and improve hamndling of MediaFile

This commit is contained in:
Thomas Peetz
2025-06-14 18:53:15 +02:00
parent 510e2f8130
commit 529a199262
6 changed files with 78 additions and 16 deletions
+3 -2
View File
@@ -42,14 +42,15 @@ if __name__ == '__main__':
log.info(f"data: {len(data)}")
for item in data:
link = item['url']
log.info(f"{item['id']} - {link}")
log.info(f"{item['id']} - {str(link)}")
try:
r = requests.get(link)
soup = BeautifulSoup(r.content, "html.parser")
title = soup.title.string
item['title'] = title
item['review'] = False
except:
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)