reduced slack functionality, higher ease of use. Database migration wip

This commit is contained in:
2022-09-05 16:29:19 +02:00
parent 60c9e88c7b
commit 2e65828bbb
35 changed files with 789 additions and 998 deletions

View File

@@ -0,0 +1,20 @@
import time
from waybackpy import WaybackMachineSaveAPI # upload to archive.org
import logging
logger = logging.getLogger(__name__)
def upload_to_archive(article_object):
"""uploads to archive.org and returns the archived url"""
user_agent = "Mozilla/5.0 (Windows NT 5.1; rv:40.0) Gecko/20100101 Firefox/40.0" # needed?
url = article_object.article_url
try:
wayback = WaybackMachineSaveAPI(url, user_agent)
archive_url = wayback.save()
# logger.info(f"{url} uploaded to archive successfully")
article_object.archive_url = archive_url
except Exception as e:
article_object.archive_url = "Error while uploading: {}".format(e)
logger.error(f"Error while generating archive url: {e}")
return article_object