-
Notifications
You must be signed in to change notification settings - Fork 0
/
revanced
executable file
·107 lines (92 loc) · 5.94 KB
/
revanced
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
info() {
printf "\033[1;35m=> \033[1;${2:-36}m%s\033[0m\n" "$1"
}
download_apk() {
[ -z "$1" ] && info "[ $app ][ v$version ] Version doesn't Exist!" "31" && exit 0
info "[ $app ][ v$version ] Fetching Download page.."
final_page=$(curl -s "${apk_provider_url}${1}" --tlsv1.3 -A "$agent" | sed -nE 's|.*href="(.*\/download\/[^"]*)".*|\1|p' | sed 's|&|\&|g')
[ -z "$final_page" ] && info "[ $app ][ v$version ] Unable to Fetch Download Page.." "31" && exit 0
info "[ $app ][ v$version ] Fetching Download URL.."
download_url=$(curl -s "${apk_provider_url}${final_page}" --tlsv1.3 -A "$agent" | sed -nE 's|.*href="(.*download.php[^"]*)".*|\1|p' | sed 's|&|\&|g')
[ -z "$download_url" ] && info "[ $app ][ v$version ] Unable to Fetch Download URL.." "31" && exit 0
info "[ $app ][ v$version ] Downloading App.."
aria2c -x16 -s16 "${apk_provider_url}${download_url}" --user-agent="$agent" -d "$tmp_dir" -o "$app-$version.apk" --allow-overwrite=true --check-certificate=false --download-result=hide --summary-interval=0 && info "[ $app ][ v$version ] App Downloaded.." && return 0
info "[ $app ][ v$version ] Unable to Download.." "31" && exit 0
}
tmp_dir="${TMPDIR:-/tmp}/revanced"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '2-5' | cut -c1).0.0.0 Safari/537.36"
apk_provider_url="https://www.apkmirror.com"
date=$(date +%F)
rv_cli="cli-$date.jar"
rv_patch="patches-$date.jar"
rv_inte="integrations-$date.apk"
keystore="$(dirname "$0")/yt-revanced.keystore"
track_file="track"
corp="google-inc"
#check if directory is there
[ -d "$tmp_dir" ] || mkdir "$tmp_dir"
#choose your app
[ -z "$1" ] && app="youtube" || app=$1
[ -z "$app" ] && exit 0
#set variables according to selected app
case $app in
youtube)
arch="universal"
[ -z "$2" ] && version=$(curl -s "https://api.revanced.app/v2/patches/latest" | sed -nE 's|.*youtube","versions":\[[0-9\.",]*,"([^\}]*)"\].*|\1|p' | tr '.' '-') || version=$2
exclude_patch_list="always-repeat,disable-auto-captions,disable-zoom-haptics,enable-debugging,downloads,hide-autoplay-button,hide-captions-button,hide-cast-button,hide-floating-microphone-button,hide-layout-components,hide-player-buttons,custom-player-overlay-opacity,hide-seekbar,hide-timestamp,hide-video-action-buttons,navigation-buttons,player-flyout-menu,remove-player-controls-background,spoof-app-version,swipe-controls"
;;
youtube-music)
arch="arm64-v8a"
[ -z "$2" ] && version=$(curl -s "https://api.revanced.app/v2/patches/latest" | sed -nE 's|.*youtube.music","versions":\[[0-9\.",]*,"([^\}]*)"\].*|\1|p' | tr '.' '-') || version=$2
exclude_patch_list=""
;;
twitter)
arch="universal"
[ -z "$2" ] && version=$(curl -s "$apk_provider_url/apk/$corp/$app/" -A "$agent" | sed -nE 's|.*x-corp/twitter/twitter-(.*-release-[0-9])-release/".*|\1|p' | head -1) || version=$2
exclude_patch_list="hide-view-count,sanitize-sharing-links,open-links-with-app-chooser"
corp="x-corp"
;;
*)
info "Wrong Package Name, please pass either 'youtube','youtube-music' or 'twitter'" "31"
exit 1
;;
esac
grep -q "$version" "$track_file" && info "No New Updates for $app." && exit 0
out="revanced-$app-$version.apk" # output filename
#pre-requisite
if [ ! -f "$tmp_dir/$rv_cli.aria2" ] && [ ! -f "$tmp_dir/$rv_patch.aria2" ] && [ ! -f "$tmp_dir/$rv_inte.aria2" ] && [ -f "$tmp_dir/$rv_cli" ] && [ -f "$tmp_dir/$rv_patch" ] && [ -f "$tmp_dir/$rv_inte" ]; then
info "revanced-cli,revanced-patches,revanced-integrations already downloaded" "32"
else
rm -f "$tmp_dir"/*.aria2
info "Downloading revanced-cli,revanced-patches,revanced-integrations.."
printf "%s\n%s\n%s" "$(curl -s "https://api.github.com/repos/revanced/revanced-cli/releases/latest" -L -A "$agent" | sed -nE "s|.*browser_download_url\": \"([^\"]*.jar)\"|\1\n\tout=$rv_cli|p")" "$(curl -s "https://api.github.com/repos/revanced/revanced-patches/releases/latest" -L -A "$agent" | sed -nE "s|.*browser_download_url\": \"([^\"]*.jar)\"|\1\n\tout=$rv_patch|p")" "$(curl -s "https://api.github.com/repos/revanced/revanced-integrations/releases/latest" -L -A "$agent" | sed -nE "s|.*browser_download_url\": \"([^\"]*.apk)\"|\1\n\tout=$rv_inte|p")" | aria2c -j3 -x16 -s16 -i - --check-certificate=false --download-result=hide --summary-interval=0 --allow-overwrite=true -d "$tmp_dir" && info "Downloaded revanced-cli,revanced-patches,revanced-integrations at $tmp_dir"
fi
if [ -f "$tmp_dir/$app-$version.apk" ] && [ ! -f "$tmp_dir/$app-$version.apk.aria2" ]; then
info "Latest Recommended $app v$version already downloaded" "32"
else
info "[ $app ][ v$version ] Fetching App.."
download_apk "$(curl -s "$apk_provider_url/apk/$corp/$app/$app-$version-release/" -A "$agent" --tlsv1.3 | tr -d '\n' | sed 's|svg class|\n|g' | sed -nE "s|.*$arch.*nodpi.*accent_color\" href=\"([^\"]*)\".*|\1|p")"
fi
info "Checking Patches for excluding.."
patch_list=$(java -jar "$tmp_dir/$rv_cli" list-patches "$tmp_dir/$rv_patch" --with-descriptions=false)
if [ -n "$exclude_patch_list" ]; then
info "Excluding Patches.." "33"
for i in $(printf "%s" "$exclude_patch_list" | tr ',' '\n'); do
if printf "%s" "$patch_list" | grep -iq "$(printf '%s' "$i" | tr '-' ' ')"; then
res="32m ✓"
else
res="31m "
check=1
fi
printf "\033[2K\r\033[1;%s %s\n" "$res" "$i"
done
exclude_patches=$(printf "%s" "$exclude_patch_list" | tr ',' '\n' | sed 's|^|--exclude |g' | tr '\n' ' ')
else
info "Nothing to Exclude.." "32"
fi
[ -n "$check" ] && info "Some of the patches are not Excluded,Check all failed patches using :" "31" && info "java -jar '$tmp_dir/$rv_cli' list-patches '$tmp_dir/$rv_patch' --with-packages" "33" && exit 1
info "All listed Patches Excluded"
info "Patching $app-$version.apk.."
#shellcheck disable=SC2086
java -jar "$tmp_dir/$rv_cli" patch --patch-bundle "$tmp_dir/$rv_patch" --merge "$tmp_dir/$rv_inte" --out "./$out" --keystore "$keystore" -t "$tmp_dir/revanced-resource-cache" "$tmp_dir/$app-$version.apk" $exclude_patches && sed -i "s|$app\t.*|$app\t$version|g" "$track_file"