reduced slack functionality, higher ease of use. Database migration wip
This commit is contained in:
20
news_fetch/utils_worker/upload/runner.py
Normal file
20
news_fetch/utils_worker/upload/runner.py
Normal 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
|
Reference in New Issue
Block a user