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

@@ -6,3 +6,5 @@ INTERNET_ARCHIVE_S3_KEY=
INTERNET_ARCHIVE_S3_SECRET= INTERNET_ARCHIVE_S3_SECRET=
TELEGRAM_API_ID= 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 loguru import logger
from .base_archiver import Archiver, ArchiveResult from .base_archiver import Archiver, ArchiveResult
from storages import Storage
class YoutubeDLArchiver(Archiver): class YoutubeDLArchiver(Archiver):
name = "youtube_dl" name = "youtube_dl"
ydl_opts = {'outtmpl': 'tmp/%(id)s.%(ext)s', 'quiet': False} 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): def download(self, url, check_if_exists=False):
netloc = self.get_netloc(url) netloc = self.get_netloc(url)
if netloc in ['facebook.com', 'www.facebook.com'] and os.getenv('FB_COOKIE'): if netloc in ['facebook.com', 'www.facebook.com']:
logger.info('Using Facebook cookie') logger.debug('Using Facebook cookie')
yt_dlp.utils.std_headers['cookie'] = os.getenv('FB_COOKIE') yt_dlp.utils.std_headers['cookie'] = self.fb_cookie
ydl = yt_dlp.YoutubeDL(YoutubeDLArchiver.ydl_opts) ydl = yt_dlp.YoutubeDL(YoutubeDLArchiver.ydl_opts)
cdn_url = None 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.TelethonArchiver(s3_client, driver, telegram_config),
archivers.TelegramArchiver(s3_client, driver), archivers.TelegramArchiver(s3_client, driver),
archivers.TiktokArchiver(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.TwitterArchiver(s3_client, driver),
archivers.WaybackArchiver(s3_client, driver) archivers.WaybackArchiver(s3_client, driver)
] ]