A working app with a few bugs sprinkled in. Configuration saved externally

This commit is contained in:
Remy Moll
2022-04-17 21:58:58 +02:00
commit 0a6dde8c78
26 changed files with 1742 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
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 new url: {e}")
return article_object