kopia lustrzana https://github.com/bellingcat/auto-archiver
Add conditional check to setup bgutils token generation script.
TODO: Update testspull/222/head
rodzic
b83bfda187
commit
c4e63ebd8c
|
@ -7,7 +7,7 @@ GEN_SCRIPT="$TARGET_DIR/build/generate_once.js"
|
|||
|
||||
# Ensure the server directory exists
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "Error: PO Token provider server directory is missing! Please run update_pot_provider.sh first."
|
||||
echo "Error: PO Token provider server directory is missing! Please run scripts/update_pot_provider.sh first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -23,18 +23,19 @@ else
|
|||
fi
|
||||
|
||||
# Check if build directory exists and if transpiling is needed
|
||||
if [ ! -d "build" ] || [ "src" -nt "$GEN_SCRIPT" ]; then
|
||||
if [ ! -d "build" ]; then
|
||||
echo "Build directory missing or outdated. Running transpilation..."
|
||||
npx tsc
|
||||
else
|
||||
echo "Build directory is up to date. Skipping transpilation."
|
||||
fi
|
||||
|
||||
# Ensure the script exists after transpilation
|
||||
if [ ! -f "$GEN_SCRIPT" ]; then
|
||||
echo "Error: PO Token script not found after attempting transpilation."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Ensure the script exists after transpilation
|
||||
#if [ ! -f "$GEN_SCRIPT" ]; then
|
||||
# echo "Error: PO Token script not found after attempting transpilation."
|
||||
# exit 1
|
||||
#fi
|
||||
|
||||
|
||||
# Confirm success
|
||||
|
|
|
@ -74,9 +74,9 @@ If you are having issues with the extractor, you can review the version of `yt-d
|
|||
"default": "inf",
|
||||
"help": "Use to limit the number of videos to download when a channel or long page is being extracted. 'inf' means no limit.",
|
||||
},
|
||||
"update_pots": {
|
||||
"default": False,
|
||||
"help": "If set, will run the script to update the pot generation script.",
|
||||
"pot_provider": {
|
||||
"default": "bgutils",
|
||||
"help": "The Proof of origin provider method.",
|
||||
},
|
||||
"extractor_args": {
|
||||
"default": {},
|
||||
|
|
|
@ -71,23 +71,21 @@ class GenericExtractor(Extractor):
|
|||
def setup_token_script(self):
|
||||
"""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.join(
|
||||
# "scripts", "potoken_provider", "bgutil-server", "build", "generate_once.js"
|
||||
"scripts", "potoken_provider", "bgutil-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...")
|
||||
if self.pot_provider == "bgutils":
|
||||
|
||||
# Check if the PO token generation script exists, set it up if not.
|
||||
try:
|
||||
subprocess.run(["bash", "scripts/potoken_provider/setup_pot_provider.sh"], check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
logger.error(f"Failed to setup PO Token script: {e}")
|
||||
return
|
||||
|
||||
# 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}")
|
||||
# Use the PO Token script in yt-dlp to fetch tokens on demand.
|
||||
pot_script = os.path.join(
|
||||
"scripts", "potoken_provider", "bgutil-provider", "build", "generate_once.js"
|
||||
)
|
||||
self.extractor_args.setdefault("youtube", {})["getpot_bgutil_script"] = pot_script
|
||||
|
||||
|
||||
def suitable_extractors(self, url: str) -> Generator[str, None, None]:
|
||||
"""
|
||||
|
@ -446,8 +444,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
|
||||
"--verbose"
|
||||
]
|
||||
|
||||
# proxy handling
|
||||
|
|
|
@ -29,6 +29,7 @@ class TestGenericExtractor(TestExtractorBase):
|
|||
"proxy": None,
|
||||
"cookies_from_browser": False,
|
||||
"cookie_file": None,
|
||||
"pot_provider": False,
|
||||
}
|
||||
|
||||
def test_load_dropin(self):
|
||||
|
|
Ładowanie…
Reference in New Issue