PortValhalla/scripts/Common/Software/Chromium/ytmdl.sh

33 lines
957 B
Bash

#!/bin/bash
pushd "${BASH_SOURCE%/*}" > /dev/null;
BROWSER_BIN="${BROWSER_BIN}";
EXTENSION_DIR="${EXTENSION_DIR}";
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}";
archiveName="$(mktemp)";
extensionDir="$(mktemp -d)";
manifestFile="$extensionDir/manifest.json";
chmod a+rwx "$extensionDir";
# Download `youtube-music-dl`
wget https://github.com/dougppaz/youtube-music-dl/releases/download/v1.2.1/youtube-music-dl.zip -O "$archiveName" > /dev/null 2>&1;
# Prepare extension
mkdir -p "$extensionDir";
unzip "$archiveName" -d "$extensionDir";
rm "$archiveName";
# Tamper manifest file
manifest="$(cat "$manifestFile" | jq ".background.persistent = false")";
echo "$manifest" > "$manifestFile";
BROWSER_BIN="${BROWSER_BIN}" \
EXTENSION_NAME="youtube-music-dl" \
UNPACKED_EXTENSION="$extensionDir" \
EXTENSION_DIR="${EXTENSION_DIR}" \
EXTENSION_POLICY_DIR="${EXTENSION_POLICY_DIR}" \
. ./install-extension.sh;
rm -rf "$extensionDir";
popd > /dev/null;