Add scripts to pull only /server/ section of pots generator, adn only install at runtime.

pull/222/head
erinhmclark 2025-03-18 13:47:01 +00:00
rodzic 0c892f3cf1
commit cb632723bd
4 zmienionych plików z 69 dodań i 24 usunięć

Wyświetl plik

@ -1,31 +1,42 @@
#!/bin/bash #!/bin/bash
set -e set -e # Exit on error
SCRIPTS_DIR="scripts/potoken_provider" SCRIPTS_DIR="scripts/potoken_provider"
BGUTIL_DIR="$SCRIPTS_DIR/bgutil-ytdlp-pot-provider" TARGET_DIR="$SCRIPTS_DIR/bgutil-provider"
UPDATE=false SERVER_DIR="$TARGET_DIR/server"
GEN_SCRIPT="$SERVER_DIR/build/generate_once.js"
# Parse optional flag # Ensure the server directory exists
if [[ "$1" == "--update" ]]; then if [ ! -d "$SERVER_DIR" ]; then
UPDATE=true echo "Error: PO Token provider server directory is missing! Please run update_pot_provider.sh first."
fi exit 1
# 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"
elif [ "$UPDATE" == true ]; then
echo "Updating existing bgutil-ytdlp-pot-provider repository..."
cd "$BGUTIL_DIR" || exit 1
git pull origin master
fi fi
# Move into the server directory # Move into the server directory
cd "$BGUTIL_DIR/server" || exit 1 cd "$SERVER_DIR" || exit 1
# Install dependencies and transpile the script # Check if dependencies need installation
if [ ! -d "node_modules" ]; then
echo "Installing dependencies..."
yarn install --frozen-lockfile yarn install --frozen-lockfile
npx tsc else
echo "Dependencies already installed. Skipping yarn install."
fi
# The transpiled POT generation script is now available and will be used automatically by the generic extractor # Check if build directory exists and if transpiling is needed
echo "PO Token provider script is ready: $BGUTIL_DIR/server/build/generate_once.js" if [ ! -d "build" ] || [ "$SERVER_DIR/src" -nt "$GEN_SCRIPT" ]; 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
# Confirm success
echo "PO Token provider script is ready for use."

Wyświetl plik

@ -0,0 +1,27 @@
#!/bin/bash
set -e # Exit on error
SCRIPTS_DIR="scripts/potoken_provider"
TARGET_DIR="$SCRIPTS_DIR/bgutil-provider"
BGUTIL_REPO="https://github.com/Brainicism/bgutil-ytdlp-pot-provider.git"
BGUTIL_TEMP_DIR="$SCRIPTS_DIR/bgutil-temp"
# Clone fresh copy into temporary directory
git clone --depth 1 "$REPO_URL" "$TMP_DIR"
# Ensure the target directory exists
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"
# Copy the entire server directory
echo "Copying /server/ directory..."
cp -r "$BGUTIL_TEMP_DIR/server" "$TARGET_DIR/"
# Clean up: remove the cloned repository
echo "Cleaning up temporary files..."
rm -rf "$BGUTIL_TEMP_DIR"
# Confirm success
echo "PO Token provider script is ready in: $TARGET_DIR/server"
echo "Commit and push changes to include it in version control."

Wyświetl plik

@ -74,8 +74,12 @@ If you are having issues with the extractor, you can review the version of `yt-d
"default": "inf", "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.", "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.",
},
"extractor_args": { "extractor_args": {
"default": {"youtube": {"getpot_bgutil_script": "scripts/potoken_provider/bgutil-ytdlp-pot-provider/server/build/generate_once.js"}}, "default": {},
"help": "Additional arguments to pass to the yt-dlp extractor. See https://github.com/yt-dlp/yt-dlp/blob/master/README.md#extractor-arguments.", "help": "Additional arguments to pass to the yt-dlp extractor. See https://github.com/yt-dlp/yt-dlp/blob/master/README.md#extractor-arguments.",
"type": "json_loader", "type": "json_loader",
}, },

Wyświetl plik

@ -73,7 +73,8 @@ class GenericExtractor(Extractor):
# Determine the default location for the transpiled PO token script. # Determine the default location for the transpiled PO token script.
default_script = os.path.join( default_script = os.path.join(
"scripts", "potoken_provider", "bgutil-ytdlp-pot-provider", "server", "build", "generate_once.js" # "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. # Check if the PO token script exists. if not, trigger the script generation.
if not os.path.exists(default_script): if not os.path.exists(default_script):
@ -445,6 +446,8 @@ class GenericExtractor(Extractor):
"--write-subs" if self.subtitles else "--no-write-subs", "--write-subs" if self.subtitles else "--no-write-subs",
"--write-auto-subs" if self.subtitles else "--no-write-auto-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", "--live-from-start" if self.live_from_start else "--no-live-from-start",
# TODO
"--verbose"
] ]
# proxy handling # proxy handling