diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index c15eb49..a58cfd5 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -26,19 +26,36 @@ jobs: | cut -d : -f 2,3 \ | tr -d \" \ | wget -qi - - RVVERSION=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json) + YT-RVVERSION=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json) rm -rf patches.json - curl -s https://api.github.com/repos/inotia00/revanced-patches/releases/latest \ | grep "browser_download_url.*json" \ | cut -d : -f 2,3 \ | tr -d \" \ | wget -qi - - RVEVERSION=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json) + YT-RVEVERSION=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.youtube") | .versions[-1]' patches.json) rm -rf patches.json + + curl -s https://api.github.com/repos/revanced/revanced-patches/releases/latest \ + | grep "browser_download_url.*json" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -qi - + YTM-RVVERSION=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.apps.youtube.music") | .versions[-1]' patches.json) + rm -rf patches.json + curl -s https://api.github.com/repos/inotia00/revanced-patches/releases/latest \ + | grep "browser_download_url.*json" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -qi - + YTM-RVEVERSION=$(jq -r '.[] | select(.name == "microg-support") | .compatiblePackages[] | select(.name == "com.google.android.apps.youtube.music") | .versions[-1]' patches.json) + rm -rf patches.json + echo "Download Below :point_down:" > ${{ github.workspace }}-CHANGELOG.txt - echo "INFO-RV=Revanced-v${RVVERSION}" >> $GITHUB_ENV - echo "INFO-RVE=Revanced Extended-v${RVEVERSION}" >> $GITHUB_ENV + echo "INFO-YT-RV=Youtube-Revanced-v${YT-RVVERSION}" >> $GITHUB_ENV + echo "INFO-YT-RVE=Youtube-Revanced Extended-v${YT-RVEVERSION}" >> $GITHUB_ENV + echo "INFO-YTM-RV=Youtube-Revanced-v${YTM-RVVERSION}" >> $GITHUB_ENV + echo "INFO-YTM-RVE=Youtube-Revanced Extended-v${YTM-RVEVERSION}" >> $GITHUB_ENV - uses: vishnudxb/cancel-workflow@v1.2 if: failure() @@ -59,8 +76,8 @@ jobs: uses: softprops/action-gh-release@v1 with: files: yt-revanced.apk - name: ${{ env.INFO-RV }} - tag_name: Revanced + name: ${{ env.INFO-YT-RV }} + tag_name: YT-Revanced body_path: ${{ github.workspace }}-CHANGELOG.txt env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -69,11 +86,31 @@ jobs: uses: softprops/action-gh-release@v1 with: files: yt-revanced-extended.apk - name: ${{ env.INFO-RVE }} - tag_name: Revanced-Extended + name: ${{ env.INFO-YT-RVE }} + tag_name: YT-Revanced-Extended body_path: ${{ github.workspace }}-CHANGELOG.txt env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release Youtube Music Revanced + uses: softprops/action-gh-release@v1 + with: + files: yt-revanced.apk + name: ${{ env.INFO-YTM-RV }} + tag_name: YT-Revanced + body_path: ${{ github.workspace }}-CHANGELOG.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release Youtube Music Revanced Extended + uses: softprops/action-gh-release@v1 + with: + files: yt-revanced-extended.apk + name: ${{ env.INFO-YTM-RVE }} + tag_name: YT-Revanced-Extended + body_path: ${{ github.workspace }}-CHANGELOG.txt + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Delete workflow runs uses: Mattraks/delete-workflow-runs@v2 diff --git a/ytm/ks.keystore b/ytm/ks.keystore new file mode 100644 index 0000000..1c07f38 Binary files /dev/null and b/ytm/ks.keystore differ diff --git a/ytm/patch-ytm.sh b/ytm/patch-ytm.sh new file mode 100644 index 0000000..a0ec03c --- /dev/null +++ b/ytm/patch-ytm.sh @@ -0,0 +1,103 @@ +`#!/bin/bash +set -e +# Set variables for Revanced +readonly revanced_name="revanced" +readonly revanced_user="revanced" +readonly revanced_patch="patches.rv" +readonly revanced_ytmsversion="" # Input version supported if you need patch specific YT version.Example: "18.03.36" +# Set variables for Revanced Extended +readonly revanced_extended_name="revanced-extended" +readonly revanced_extended_user="inotia00" +readonly revanced_extended_patch="patches.rve" +readonly revanced_extended_ytmsversion="" # Input version supported if you need patch specific YT version.Example: "18.07.35" +# Function prepare patches keywords +get_patch() { + local excluded_start=$(grep -n -m1 'EXCLUDE PATCHES' "$patch_file" | cut -d':' -f1) + local included_start=$(grep -n -m1 'INCLUDE PATCHES' "$patch_file" | cut -d':' -f1) + local excluded_patches=$(tail -n +$excluded_start $patch_file | head -n "$(( included_start - excluded_start ))" | grep '^[^#[:blank:]]') + local included_patches=$(tail -n +$included_start $patch_file | grep '^[^#[:blank:]]') + patches=() + if [[ -n "$excluded_patches" ]]; then + while read -r patch; do + patches+=("-e $patch") + done <<< "$excluded_patches" + fi + if [[ -n "$included_patches" ]]; then + while read -r patch; do + patches+=("-i $patch") + done <<< "$included_patches" + fi +} +# Function download latest github releases +download_latest_release() { + echo "⏬ Downloading $name resources..." + for repos in revanced-patches revanced-cli revanced-integrations; do + local url="https://api.github.com/repos/$user/$repos/releases/latest" + curl -s "$url" | jq -r '.assets[].browser_download_url' | xargs -n 1 curl -O -s -L + done +} +# Function download YouTube apk from APKmirror +req() { + curl -sSL -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:111.0) Gecko/20100101 Firefox/111.0" "$1" -o "$2" +} +dl_ytm() { + rm -rf $2 + echo "Downloading YouTubeMusic $1" + url="https://www.apkmirror.com/apk/google-inc/youtube/youtube-music-${1//./-}-release/" + url="$url$(req "$url" - | grep arm64 -A30 | grep youtube-music | head -1 | sed "s#.*-release/##g;s#/\".*##g")" + url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')" + url="https://www.apkmirror.com$(req "$url" - | tr '\n' ' ' | sed -n 's;.*href="\(.*key=[^"]*\)">.*;\1;p')" + req "$url" "$2" +} +get_latestytmversion() { + url="https://www.apkmirror.com/apk/google-inc/youtube-music/" + ytmsversion=$(req "$url" - | grep "All version" -A200 | grep app_release | sed 's:.*/youtube-music-::g;s:-release/.*::g;s:-:.:g' | sort -r | head -1) + echo "Latest YoutubeMusic Version: $ytmsversion" +} +get_support_version() { +ytmsversion=$(jq -r '.[] | select(.name == "hide-get-premium") | .compatiblePackages[] | select(.name == "com.google.android.apps.youtube.music") | .versions[-1]' patches.json) +} +# Function Patch APK +patch_apk() { +echo "⚙️ Patching YouTube..." +java -jar revanced-cli*.jar \ + -m revanced-integrations*.apk \ + -b revanced-patches*.jar \ + -a youtube-music-v$ytmsversion.apk \ + ${patches[@]} \ + --keystore=ks.keystore \ + -o ytms-$name.apk +} +# Function clean caches to new build +clean_cache() { +echo "🧹 Clean caches..." +rm -f revanced-cli*.jar \ + revanced-integrations*.apk \ + revanced-patches*.jar \ + patches.json \ + options.toml \ + youtube*.apk \ +} +# Loop over Revanced & Revanced Extended +for name in $revanced_name $revanced_extended_name ; do + # Select variables based on name + if [[ "$name" = "$revanced_name" ]]; then + user="$revanced_user" + patch_file="$revanced_patch" + ytmsversion="$revanced_ytmsversion" + else + user="$revanced_extended_user" + patch_file="$revanced_extended_patch" + ytmsversion="$revanced_extended_ytmsversion" + fi +get_patch +download_latest_release +if [[ "$name" = "$revanced_name" ]] ; then + get_support_version + dl_ytm $ytmsversion youtube-music-v$ytmsversion.apk + else get_latestytmversion + dl_ytm $ytmsversion youtube-music-v$ytmsversion.apk +fi +patch_apk +clean_cache +done` \ No newline at end of file diff --git a/ytm/patches-ytm.rv b/ytm/patches-ytm.rv new file mode 100644 index 0000000..1ed040f --- /dev/null +++ b/ytm/patches-ytm.rv @@ -0,0 +1,11 @@ +# EXCLUDE PATCHES FROM BELOW +compact-header +# INCLUDE PATCHES FROM BELOW +background-play +codecs-unlock +exclusive-audio-playback +hide-get-premium +minimized-playback-music +music-video-ads +tasteBuilder-remover +upgrade-button-remover \ No newline at end of file diff --git a/ytm/patches-ytm.rve b/ytm/patches-ytm.rve new file mode 100644 index 0000000..1ed040f --- /dev/null +++ b/ytm/patches-ytm.rve @@ -0,0 +1,11 @@ +# EXCLUDE PATCHES FROM BELOW +compact-header +# INCLUDE PATCHES FROM BELOW +background-play +codecs-unlock +exclusive-audio-playback +hide-get-premium +minimized-playback-music +music-video-ads +tasteBuilder-remover +upgrade-button-remover \ No newline at end of file