Merge pull request #29 from djhmateer/fb-cookie

This commit is contained in:
Miguel Sozinho Ramalho
2022-05-09 15:53:07 +01:00
committed by GitHub
3 changed files with 12 additions and 6 deletions

View File

@@ -5,4 +5,6 @@ DO_BUCKET=
INTERNET_ARCHIVE_S3_KEY=
INTERNET_ARCHIVE_S3_SECRET=
TELEGRAM_API_ID=
TELEGRAM_API_HASH=
TELEGRAM_API_HASH=
FACEBOOK_COOKIE=cookie: datr= xxxx

View File

@@ -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

View File

@@ -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)
]