diff --git a/.example.env b/.example.env index deb01a2..4a200cf 100644 --- a/.example.env +++ b/.example.env @@ -5,4 +5,6 @@ DO_BUCKET= INTERNET_ARCHIVE_S3_KEY= INTERNET_ARCHIVE_S3_SECRET= TELEGRAM_API_ID= -TELEGRAM_API_HASH= \ No newline at end of file +TELEGRAM_API_HASH= + +FACEBOOK_COOKIE=cookie: datr= xxxx \ No newline at end of file diff --git a/archivers/youtubedl_archiver.py b/archivers/youtubedl_archiver.py index 1ea194c..ad8756b 100644 --- a/archivers/youtubedl_archiver.py +++ b/archivers/youtubedl_archiver.py @@ -5,17 +5,21 @@ import yt_dlp from loguru import logger from .base_archiver import Archiver, ArchiveResult - +from storages import Storage class YoutubeDLArchiver(Archiver): name = "youtube_dl" ydl_opts = {'outtmpl': 'tmp/%(id)s.%(ext)s', 'quiet': False} + def __init__(self, storage: Storage, driver, fb_cookie): + super().__init__(storage, driver) + self.fb_cookie = fb_cookie + def download(self, url, check_if_exists=False): netloc = self.get_netloc(url) - if netloc in ['facebook.com', 'www.facebook.com'] and os.getenv('FB_COOKIE'): - logger.info('Using Facebook cookie') - yt_dlp.utils.std_headers['cookie'] = os.getenv('FB_COOKIE') + if netloc in ['facebook.com', 'www.facebook.com']: + logger.debug('Using Facebook cookie') + yt_dlp.utils.std_headers['cookie'] = self.fb_cookie ydl = yt_dlp.YoutubeDL(YoutubeDLArchiver.ydl_opts) cdn_url = None diff --git a/auto_archive.py b/auto_archive.py index d3db9a2..a7bde8b 100644 --- a/auto_archive.py +++ b/auto_archive.py @@ -108,7 +108,7 @@ def process_sheet(sheet, header=1, columns=GWorksheet.COLUMN_NAMES): archivers.TelethonArchiver(s3_client, driver, telegram_config), archivers.TelegramArchiver(s3_client, driver), archivers.TiktokArchiver(s3_client, driver), - archivers.YoutubeDLArchiver(s3_client, driver), + archivers.YoutubeDLArchiver(s3_client, driver, os.getenv('FACEBOOK_COOKIE')), archivers.TwitterArchiver(s3_client, driver), archivers.WaybackArchiver(s3_client, driver) ]