mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-08 03:18:28 +03:00
Add POT setup script.
This commit is contained in:
25
scripts/potoken_provider/setup_pot_provider.sh
Normal file
25
scripts/potoken_provider/setup_pot_provider.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SCRIPTS_DIR="scripts/potoken_provider"
|
||||
BGUTIL_DIR="$SCRIPTS_DIR/bgutil-ytdlp-pot-provider"
|
||||
|
||||
# Clone the repository, or update if it exists
|
||||
if [ ! -d "$BGUTIL_DIR" ]; then
|
||||
echo "Cloning bgutil-ytdlp-pot-provider repository..."
|
||||
git clone https://github.com/Brainicism/bgutil-ytdlp-pot-provider.git "$BGUTIL_DIR"
|
||||
else
|
||||
echo "Updating existing bgutil-ytdlp-pot-provider repository..."
|
||||
cd "$BGUTIL_DIR" || exit 1
|
||||
git pull origin master
|
||||
fi
|
||||
|
||||
# Move into the server directory
|
||||
cd "$BGUTIL_DIR/server" || exit 1
|
||||
|
||||
# Install dependencies and transpile the script
|
||||
yarn install --frozen-lockfile
|
||||
npx tsc
|
||||
|
||||
# The built script is now available
|
||||
echo "PO Token provider script is ready: $BGUTIL_DIR/server/build/generate_once.js"
|
||||
@@ -72,7 +72,9 @@ class GenericExtractor(Extractor):
|
||||
"""Setup PO Token provider https://github.com/Brainicism/bgutil-ytdlp-pot-provider."""
|
||||
|
||||
# Determine the default location for the transpiled PO token script.
|
||||
default_script = os.path.expanduser("~/bgutil-ytdlp-pot-provider/server/build/generate_once.js")
|
||||
default_script = os.path.join(
|
||||
"scripts", "potoken_provider", "bgutil-ytdlp-pot-provider", "server", "build", "generate_once.js"
|
||||
)
|
||||
# Check if the PO token script exists. if not, trigger the script generation.
|
||||
if not os.path.exists(default_script):
|
||||
logger.info("PO Token script not found. Running setup...")
|
||||
@@ -82,8 +84,8 @@ class GenericExtractor(Extractor):
|
||||
logger.error(f"Failed to setup PO Token script: {e}")
|
||||
return
|
||||
|
||||
# Set the extractor_args to point to the default script, if not already provided.
|
||||
# self.extractor_args.setdefault("youtube", {})["getpot_bgutil_script"] = default_script
|
||||
# Use the PO Token script in yt-dlp to fetch tokens on demand.
|
||||
self.extractor_args.setdefault("youtube", {})["getpot_bgutil_script"] = default_script
|
||||
logger.info(f"Using PO Token script at: {default_script}")
|
||||
|
||||
def suitable_extractors(self, url: str) -> Generator[str, None, None]:
|
||||
@@ -443,9 +445,6 @@ class GenericExtractor(Extractor):
|
||||
"--write-subs" if self.subtitles else "--no-write-subs",
|
||||
"--write-auto-subs" if self.subtitles else "--no-write-auto-subs",
|
||||
"--live-from-start" if self.live_from_start else "--no-live-from-start",
|
||||
# TODO: Move this to documentation
|
||||
# Note: add the --verbose flag for debugging
|
||||
"--verbose",
|
||||
]
|
||||
|
||||
# proxy handling
|
||||
|
||||
Reference in New Issue
Block a user