2023-12-04 16:02:20 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-14 15:35:58 +03:00
|
|
|
set -e
|
2023-12-04 16:02:20 +03:00
|
|
|
|
2024-01-14 15:35:58 +03:00
|
|
|
usage() {
|
2024-01-30 20:59:19 +03:00
|
|
|
echo "Usage: $(basename "$0") [-xh] [ -o DIR] YANDEX_MUSIC_EXE"
|
2024-01-14 15:35:58 +03:00
|
|
|
echo
|
|
|
|
echo " Options:"
|
2024-01-30 20:59:19 +03:00
|
|
|
echo " -o DIR Path to destination folder"
|
|
|
|
echo " -x Extract and fix only to destination folder"
|
2024-01-14 15:35:58 +03:00
|
|
|
echo " -h Show this help and exit"
|
|
|
|
}
|
|
|
|
|
|
|
|
exe_location=
|
2024-01-30 20:59:19 +03:00
|
|
|
dst="$PWD/app"
|
|
|
|
while getopts :xo:h name; do
|
2024-01-14 15:35:58 +03:00
|
|
|
case $name in
|
|
|
|
x) extract_only=1 ;;
|
2024-01-30 20:59:19 +03:00
|
|
|
o) dst="$OPTARG" ;;
|
2024-01-14 15:35:58 +03:00
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$OPTIND" -le "$#" ]; then
|
|
|
|
shift "$(( OPTIND - 1))"
|
|
|
|
exe_location="$1"
|
|
|
|
fi
|
2023-12-04 16:02:20 +03:00
|
|
|
|
|
|
|
|
2024-01-14 15:35:58 +03:00
|
|
|
if [ -z "$exe_location" ]; then
|
|
|
|
echo "No exe file specified"
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-01-30 20:59:19 +03:00
|
|
|
clear() {
|
|
|
|
rm -rf "$TEMPDIR"
|
|
|
|
}
|
|
|
|
TEMPDIR="$(mktemp -d)"
|
|
|
|
trap clear EXIT
|
|
|
|
|
|
|
|
|
|
|
|
EXTRACTED="$TEMPDIR/Extracted"
|
2024-01-14 15:35:58 +03:00
|
|
|
# unpacking
|
2024-01-30 20:59:19 +03:00
|
|
|
7z x "$exe_location" -o"$EXTRACTED"
|
|
|
|
mv "$EXTRACTED/\$PLUGINSDIR/app-64.7z" "$TEMPDIR/app-64.7z"
|
|
|
|
rm -rf "$EXTRACTED"
|
|
|
|
7z x "$TEMPDIR/app-64.7z" -o"$EXTRACTED"
|
|
|
|
mv "$EXTRACTED/resources/app.asar" "$TEMPDIR/app.asar"
|
|
|
|
rm -rf "$EXTRACTED"
|
|
|
|
rm "$TEMPDIR/app-64.7z"
|
|
|
|
asar extract "$TEMPDIR/app.asar" "$TEMPDIR/app"
|
|
|
|
rm "$TEMPDIR/app.asar"
|
|
|
|
|
|
|
|
curdir="$PWD"
|
|
|
|
cd "$TEMPDIR/app"
|
2024-01-14 15:35:58 +03:00
|
|
|
|
2023-12-04 16:02:20 +03:00
|
|
|
# fixing secretKey issue
|
|
|
|
echo "Fixing SecretKey"
|
|
|
|
find "./" -type f \( -name "*.js" -o -name "*.js.map" \) -print0 | while IFS= read -r -d $'\0' file; do
|
|
|
|
# Use 'sed' to perform the replacement in-place
|
|
|
|
sed -i "s/secretKey:this.secretKey/secretKey:'superSecretKey'/g" "$file"
|
|
|
|
done
|
|
|
|
echo "SecretKey replaced"
|
|
|
|
|
|
|
|
|
|
|
|
echo "Fixing Title"
|
|
|
|
#fixing title
|
|
|
|
find "./" -type f -name "*.html" -print0 | while IFS= read -r -d $'\0' file; do
|
|
|
|
# Use 'sed' to perform the replacement in-place
|
|
|
|
sed -i "s/Яндекс Музыка — собираем музыку для вас/Яндекс Музыка/g" "$file"
|
|
|
|
done
|
|
|
|
echo "Title Fixed"
|
|
|
|
|
2024-01-29 19:48:31 +03:00
|
|
|
echo "Fixing App Quiting"
|
|
|
|
sed -i "s/window.on('close', (event) => {/window.on('close', (event) => {electron_1.app.quit();/g" "./main/lib/handlers/handleWindowLifecycleEvents.js"
|
|
|
|
|
2024-01-20 19:42:39 +03:00
|
|
|
if ! command -v jq &>/dev/null; then
|
|
|
|
echo "Error: jq is not installed. Please install jq to proceed." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-01-29 21:41:52 +03:00
|
|
|
|
2024-01-20 19:42:39 +03:00
|
|
|
jq --arg license "UNLICENSED" '. + {license: $license}' package.json > tmp_package.json
|
|
|
|
mv tmp_package.json package.json
|
|
|
|
echo "Updated license field in package.json"
|
|
|
|
|
2024-01-29 22:32:18 +03:00
|
|
|
jq '. + {icon: {"48x48": "build/next-desktop/favicon.png", "scalable": "build/next-desktop/favicon.svg"}}' package.json > tmp_package.json
|
2024-01-29 21:41:52 +03:00
|
|
|
mv tmp_package.json package.json
|
|
|
|
echo "Updated icon field in package.json"
|
2023-12-04 16:02:20 +03:00
|
|
|
|
2024-01-29 21:41:52 +03:00
|
|
|
if [ -n "$extract_only" ]; then
|
2024-01-30 20:59:19 +03:00
|
|
|
mkdir -p "$(dirname "$dst")"
|
|
|
|
mv "$TEMPDIR/app" "$dst"
|
2024-01-29 21:41:52 +03:00
|
|
|
exit 0
|
2023-12-04 16:02:20 +03:00
|
|
|
fi
|
|
|
|
|
2024-01-30 20:59:19 +03:00
|
|
|
mkdir -p "$dst"
|
2023-12-04 16:02:20 +03:00
|
|
|
|
2024-01-29 21:41:52 +03:00
|
|
|
echo "Packing"
|
2024-01-30 20:59:19 +03:00
|
|
|
cd "$curdir"
|
|
|
|
asar pack "$TEMPDIR/app" "$dst/yandexmusic.asar"
|
2024-01-30 21:21:59 +03:00
|
|
|
for ext in png svg; do
|
|
|
|
mv "$TEMPDIR/app/build/next-desktop/favicon.$ext" "$dst"
|
|
|
|
done
|
2024-01-29 21:41:52 +03:00
|
|
|
|
2024-01-30 20:59:19 +03:00
|
|
|
echo "Done"
|