Chuck Norris Emailed Me This Patch... I'm Not Going To Question It

This commit is contained in:
coolnsx
2023-11-02 13:27:04 +05:30
parent 273fdc35a3
commit 185d1ff9c6
3 changed files with 72 additions and 77 deletions

View File

@@ -1,11 +1,10 @@
#!/bin/sh #!/bin/sh
info() {
info(){
printf "\033[1;35m=> \033[1;${2:-36}m%s\033[0m\n" "$1" printf "\033[1;35m=> \033[1;${2:-36}m%s\033[0m\n" "$1"
} }
download_apk(){ download_apk() {
[ -z "$1" ] && info "[ $app ][ v$version ] Version doesn't Exist!" "31" && exit 1 [ -z "$1" ] && info "[ $app ][ v$version ] Version doesn't Exist!" "31" && exit 1
info "[ $app ][ v$version ] Fetching Download page.." 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') final_page=$(curl -s "${apk_provider_url}${1}" --tlsv1.3 -A "$agent" | sed -nE 's|.*href="(.*\/download\/[^"]*)".*|\1|p' | sed 's|&|\&|g')
@@ -18,7 +17,7 @@ download_apk(){
info "[ $app ][ v$version ] Unable to Download.." "31" && exit 1 info "[ $app ][ v$version ] Unable to Download.." "31" && exit 1
} }
download_keystore () { download_keystore() {
[ ! -f "$HOME/.secrets" ] && return 0 [ ! -f "$HOME/.secrets" ] && return 0
#shellcheck disable=SC1091 #shellcheck disable=SC1091
. "$HOME/.secrets" . "$HOME/.secrets"
@@ -41,7 +40,7 @@ keystore=""
[ -d "$tmp_dir" ] || mkdir "$tmp_dir" [ -d "$tmp_dir" ] || mkdir "$tmp_dir"
#pre-requisite #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 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" info "revanced-cli,revanced-patches,revanced-integrations already downloaded" "32"
else else
rm -f "$tmp_dir"/*.aria2 rm -f "$tmp_dir"/*.aria2
@@ -73,9 +72,10 @@ case $app in
*) *)
info "Wrong Package Name, please pass either 'youtube' or 'youtube-music'" "31" info "Wrong Package Name, please pass either 'youtube' or 'youtube-music'" "31"
exit 1 exit 1
;;
esac esac
if [ -f "$tmp_dir/$app-$version.apk" ] && [ ! -f "$tmp_dir/$app-$version.apk.aria2" ];then if [ -f "$tmp_dir/$app-$version.apk" ] && [ ! -f "$tmp_dir/$app-$version.apk.aria2" ]; then
info "Latest Recommended $app v$version already downloaded" "32" info "Latest Recommended $app v$version already downloaded" "32"
else else
info "[ $app ][ v$version ] Fetching App.." info "[ $app ][ v$version ] Fetching App.."
@@ -85,16 +85,16 @@ fi
info "Checking Patches for excluding.." info "Checking Patches for excluding.."
patch_list=$(java -jar "$tmp_dir/$rv_cli" list-patches "$tmp_dir/$rv_patch" --with-descriptions=false) patch_list=$(java -jar "$tmp_dir/$rv_cli" list-patches "$tmp_dir/$rv_patch" --with-descriptions=false)
if [ -n "$exclude_patch_list" ];then if [ -n "$exclude_patch_list" ]; then
info "Excluding Patches.." "33" info "Excluding Patches.." "33"
for i in $(printf "%s" "$exclude_patch_list" | tr ',' '\n');do for i in $(printf "%s" "$exclude_patch_list" | tr ',' '\n'); do
if printf "%s" "$patch_list" | grep -iq "$(printf '%s' "$i" | tr '-' ' ')";then if printf "%s" "$patch_list" | grep -iq "$(printf '%s' "$i" | tr '-' ' ')"; then
res="32m ✓" res="32m ✓"
else else
res="31m " res="31m "
check=1 check=1
fi fi
printf "\033[2K\r\033[1;%s %s\n" "$res" "$i" printf "\033[2K\r\033[1;%s %s\n" "$res" "$i"
done done
exclude_patches=$(printf "%s" "$exclude_patch_list" | tr ',' '\n' | sed 's|^|--exclude |g' | tr '\n' ' ') exclude_patches=$(printf "%s" "$exclude_patch_list" | tr ',' '\n' | sed 's|^|--exclude |g' | tr '\n' ' ')
else else

1
screen
View File

@@ -117,5 +117,4 @@ stop() {
tmp_file="/tmp/screenrecord.mp4" tmp_file="/tmp/screenrecord.mp4"
process_file="/tmp/processed.mp4" process_file="/tmp/processed.mp4"
[ "$#" -gt 0 ] && $1 "$2" [ "$#" -gt 0 ] && $1 "$2"

108
yt-music
View File

@@ -56,17 +56,16 @@ help() {
exit 0 exit 0
} }
cleanup_shit(){ cleanup_shit() {
pkill -f "nc -U $discord_ipc" > /dev/null pkill -f "nc -U $discord_ipc" >/dev/null
rm -rdf "$logdir" rm -rdf "$logdir"
exit 0 exit 0
} }
get_cookies() { get_cookies() {
for i in $(sqlite3 "$HOME/.config/google-chrome/Default/Cookies" "SELECT name,REPLACE(base64(SUBSTR(encrypted_value,4)),CHAR(10),'') FROM cookies WHERE host_key='.youtube.com';") for i in $(sqlite3 "$HOME/.config/google-chrome/Default/Cookies" "SELECT name,REPLACE(base64(SUBSTR(encrypted_value,4)),CHAR(10),'') FROM cookies WHERE host_key='.youtube.com';"); do
do
printf "%s=%s; " "$(printf '%s' "$i" | cut -d'|' -f1)" "$(printf '%s' "$i" | cut -d'|' -f2 | base64 -d | openssl enc -d -aes-128-cbc -K fd621fe5a2b402539dfa147ca9272778 -iv 20202020202020202020202020202020)" printf "%s=%s; " "$(printf '%s' "$i" | cut -d'|' -f1)" "$(printf '%s' "$i" | cut -d'|' -f2 | base64 -d | openssl enc -d -aes-128-cbc -K fd621fe5a2b402539dfa147ca9272778 -iv 20202020202020202020202020202020)"
done > "$cookie" done >"$cookie"
} }
get_data() { get_data() {
@@ -74,7 +73,7 @@ get_data() {
curl -X POST -A "${3:-$agent}" -s "$base_url/youtubei/v1/$1?key=${4:-AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30}&prettyPrint=false" -H "content-type:application/json" -d "$2" -b "$(cat "$cookie")" -e "$base_url" -H "$sapisid_header" curl -X POST -A "${3:-$agent}" -s "$base_url/youtubei/v1/$1?key=${4:-AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30}&prettyPrint=false" -H "content-type:application/json" -d "$2" -b "$(cat "$cookie")" -e "$base_url" -H "$sapisid_header"
} }
get_music_list(){ get_music_list() {
json_next="{ json_next="{
\"enablePersistentPlaylistPanel\": true, \"enablePersistentPlaylistPanel\": true,
\"tunerSettingValue\": \"AUTOMIX_SETTING_NORMAL\", \"tunerSettingValue\": \"AUTOMIX_SETTING_NORMAL\",
@@ -86,8 +85,8 @@ get_music_list(){
\"context\": $(cat "$logdir/context") \"context\": $(cat "$logdir/context")
}" }"
next_data=$(get_data "next" "$json_next" | sed 's/playlistPanelVideoRenderer/\n/g;s/hasPersistentPlaylistPanel/\n/g' | sed -nE 's|.*text":"(.*)"}.*longBylineText":\{"runs":\[\{"text":"([^"]*)","navigationEndpoint.*videoId":"([^"]*)".*|\1 - \2\t\3|p;s|.*nextRadioContinuationData":\{([^,]*).*|\1,|p') next_data=$(get_data "next" "$json_next" | sed 's/playlistPanelVideoRenderer/\n/g;s/hasPersistentPlaylistPanel/\n/g' | sed -nE 's|.*text":"(.*)"}.*longBylineText":\{"runs":\[\{"text":"([^"]*)","navigationEndpoint.*videoId":"([^"]*)".*|\1 - \2\t\3|p;s|.*nextRadioContinuationData":\{([^,]*).*|\1,|p')
printf '%s' "$next_data" | sed -e "$(cut -f2 "/tmp/yt-music/next" | sed 's|^|/|g;s|$|/d|g')" -e '/"continuation"/d' >> "$logdir/next" printf '%s' "$next_data" | sed -e "$(cut -f2 "/tmp/yt-music/next" | sed 's|^|/|g;s|$|/d|g')" -e '/"continuation"/d' >>"$logdir/next"
printf '%s' "$next_data" | sed -n '/"continuation"/p' > "$logdir/continue_token" printf '%s' "$next_data" | sed -n '/"continuation"/p' >"$logdir/continue_token"
} }
get_song_lyrics() { get_song_lyrics() {
@@ -108,7 +107,7 @@ get_song_lyrics() {
\"client\": { \"client\": {
\"clientName\": \"ANDROID_MUSIC\", \"clientName\": \"ANDROID_MUSIC\",
\"clientVersion\": \"$andy_yt_ver\", \"clientVersion\": \"$andy_yt_ver\",
\"androidSdkVersion\": $(( random_no + extra_up + 29 )), \"androidSdkVersion\": $((random_no + extra_up + 29)),
\"userAgent\": \"$droid_agent\", \"userAgent\": \"$droid_agent\",
\"hl\": \"en\", \"hl\": \"en\",
\"timeZone\": \"UTC\", \"timeZone\": \"UTC\",
@@ -117,7 +116,7 @@ get_song_lyrics() {
}, },
\"browseId\": \"$browseId\" \"browseId\": \"$browseId\"
}" }"
get_data "browse" "$json_lyrics" "$droid_agent" "AIzaSyAOghZGza2MQSZkY_zfZ370N-PUdXEo8AI" | sed 's/metadata"/\n/g' | sed -nE 's|.*lyricLine":"([^"]*)","cueRange".*"endTimeMilliseconds":"([^"]*)".*|\2\t\1|p' > "$logdir/lyrics" get_data "browse" "$json_lyrics" "$droid_agent" "AIzaSyAOghZGza2MQSZkY_zfZ370N-PUdXEo8AI" | sed 's/metadata"/\n/g' | sed -nE 's|.*lyricLine":"([^"]*)","cueRange".*"endTimeMilliseconds":"([^"]*)".*|\2\t\1|p' >"$logdir/lyrics"
fi fi
} }
@@ -125,16 +124,16 @@ loop() {
#this function does exactly what it says, it should run in the background #this function does exactly what it says, it should run in the background
#it plays next song after the current song get played completely,it does nothing until u run the search_play function then this code kicks in #it plays next song after the current song get played completely,it does nothing until u run the search_play function then this code kicks in
trap cleanup_shit INT HUP TERM trap cleanup_shit INT HUP TERM
socat - "UNIX-CONNECT:$socket" | while read -r event;do socat - "UNIX-CONNECT:$socket" | while read -r event; do
#look for eof event #look for eof event
if printf "%s" "$event" | grep -q "end-file.*eof";then if printf "%s" "$event" | grep -q "end-file.*eof"; then
i=$(cat "$logdir/counter") i=$(cat "$logdir/counter")
: $((i+=1)) : $((i += 1))
pgrep -f "$socket" >/dev/null || continue pgrep -f "$socket" >/dev/null || continue
[ -n "$(cat "$logdir/next")" ] [ -n "$(cat "$logdir/next")" ]
play "$(sed -n "$((i+=1))p" "$logdir/next")" "$1" play "$(sed -n "$((i += 1))p" "$logdir/next")" "$1"
printf '%s' "$i" > "$logdir/counter" printf '%s' "$i" >"$logdir/counter"
tail -1 "$logdir/next" | grep -q "$(cut -d'>' -f2 < "$logdir/current")" && get_music_list tail -1 "$logdir/next" | grep -q "$(cut -d'>' -f2 <"$logdir/current")" && get_music_list
fi fi
done done
cleanup_shit cleanup_shit
@@ -142,43 +141,37 @@ loop() {
#discord rich presence written in a nut-shell code #discord rich presence written in a nut-shell code
set_activity() { set_activity() {
op=0 #length of payload
handshake='{"v":1,"client_id":"'$presence_client_id'"}' len=${#1}
datalen=${#handshake} #outputs opcode in little endian encoding
for i in $(seq 0 3); do printf "\\001\\000\\000\\000"
byte=$(((op >> (i * 8)) & 255)) #loop for length to encode in little endian encoding
printf "\\$(printf "%03o" "$byte")" for i in 0 8 16 24; do
done len=$((len >> i))
for i in $(seq 0 3); do #shellcheck disable=SC2059
byte=$(((datalen >> (i * 8)) & 255)) printf "\\$(printf "%03o" "$len")"
printf "\\$(printf "%03o" "$byte")"
done
printf "%s" "$handshake"
op=1
datalen=${#1}
for i in $(seq 0 3); do
byte=$(((op >> (i * 8)) & 255))
printf "\\$(printf "%03o" "$byte")"
done
for i in $(seq 0 3); do
byte=$(((datalen >> (i * 8)) & 255))
printf "\\$(printf "%03o" "$byte")"
done done
#print the payload that need to be sent
printf "%s" "$1" printf "%s" "$1"
} }
update_rich_presence() { update_rich_presence() {
pkill -f "nc -U $discord_ipc" > /dev/null pkill -f "nc -U $discord_ipc" >/dev/null
sleep 2
title=$1 title=$1
id=$2 id=$2
dur=$3
start=$(date +%s) start=$(date +%s)
dur=$(printf '{ "command": ["get_property", "duration"] }\n' | socat - "$socket" | sed -nE 's|.*data":([^.]*).*|\1|p') payload='{"cmd": "SET_ACTIVITY", "args": {"activity": {"details": "'$(printf "%s" "$title" | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')'", "state": "'$(printf "%s" "$title" | sed 's_.* - __;s| $||')'", "timestamps": {"start": '"$start"',"end": '"$((start + dur))"'}, "assets": {"large_image": "https://i.ytimg.com/vi/'$id'/mqdefault.jpg","large_text":"Checkmate Premium Users"},"buttons": [{"label":"Listen Song", "url": "https://music.youtube.com/watch?v='$id'"}]},"pid":786}, "nonce": "1"}' #pid needs to be set and constant so discord knows which application to update
payload='{"cmd": "SET_ACTIVITY", "args": {"activity": {"details": "'$(printf "%s" "$title" | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')'", "state": "'$(printf "%s" "$title" | sed 's_.* - __;s| $||')'", "timestamps": {"start": '"$start"',"end": '"$((start + dur))"'}, "assets": {"large_image": "https://i.ytimg.com/vi/'$id'/mqdefault.jpg","large_text":"Checkmate Premium Users"}}}, "nonce": "1"}' {
#handshake
handshake='{"v":1,"client_id":"'$presence_client_id'"}'
# handshake with opcode
printf "\\000\\000\\000\\000\\$(printf "%03o" "${#handshake}")\\000\\000\\000%s" "$handshake"
#with buttons, but this MF is not working -- #wait for response which comes within 1 second(max 2 seconds)
#payload='{"cmd": "SET_ACTIVITY", "args": {"activity": {"details": "'$(printf "%s" "$title" | sed 's|[^-]*$||;s|-$||;s| $||;s|^ ||')'", "state": "'$(printf "%s" "$title" | sed 's_.* - __;s| $||')'", "timestamps": {"start": '"$(date +%s)"'}, "assets": {"large_image": "https://i.ytimg.com/vi/'$id'/mqdefault.jpg","large_text":"Checkmate Premium Users","buttons": [{"label":"Listen Here", "url": "https://www.youtube.com/watch?v='$id'"}]}}}, "nonce": "1"}' sleep 3
set_activity "$payload" | nc -U "$discord_ipc" set_activity "$payload"
} | nc -U "$discord_ipc" >"/tmp/ipclog"
} }
play() { play() {
@@ -198,7 +191,7 @@ play() {
\"client\": { \"client\": {
\"clientName\": \"ANDROID_MUSIC\", \"clientName\": \"ANDROID_MUSIC\",
\"clientVersion\": \"$andy_yt_ver\", \"clientVersion\": \"$andy_yt_ver\",
\"androidSdkVersion\": $(( random_no + extra_up + 29 )), \"androidSdkVersion\": $((random_no + extra_up + 29)),
\"userAgent\": \"$droid_agent\", \"userAgent\": \"$droid_agent\",
\"hl\": \"en\", \"hl\": \"en\",
\"timeZone\": \"UTC\", \"timeZone\": \"UTC\",
@@ -228,11 +221,14 @@ play() {
printf '{"command":["loadfile","%s","replace"]}\n' "$audio_url" | socat - "$socket" printf '{"command":["loadfile","%s","replace"]}\n' "$audio_url" | socat - "$socket"
printf "currently playing : %s >%s\n" "$title" "$id" >"$logdir/current" printf "currently playing : %s >%s\n" "$title" "$id" >"$logdir/current"
#required for discord rich presence to set end timestamp
duration=$(printf '%s' "$audio_url" | sed -nE 's|.*&dur=([^\.]*).*|\1|p')
#self explainatory #self explainatory
get_song_lyrics "$id" & get_song_lyrics "$id" &
#update the discord rich presence, requires client id #update the discord rich presence, requires client id
update_rich_presence "$title" "$id" & update_rich_presence "$title" "$id" "$duration" &
#next songs data #next songs data
[ -n "$3" ] && get_music_list & [ -n "$3" ] && get_music_list &
@@ -249,8 +245,8 @@ search_play() {
#storing context #storing context
printf '{"client":{"clientName":"WEB_REMIX","clientVersion":"1.20231010.05.00"}}' >"$logdir/context" printf '{"client":{"clientName":"WEB_REMIX","clientVersion":"1.20231010.05.00"}}' >"$logdir/context"
if ! (printf '%s' "$query" | grep -q 'https:' || printf '%s' "$query" | grep -q 'ID:');then if ! (printf '%s' "$query" | grep -q 'https:' || printf '%s' "$query" | grep -q 'ID:'); then
#json for song search #json for song search
json_search="{ json_search="{
\"context\" : $(cat "$logdir/context"), \"context\" : $(cat "$logdir/context"),
\"query\": \"$query\", \"query\": \"$query\",
@@ -267,10 +263,10 @@ search_play() {
#extracting your cookies so that the song list are according to your taste #extracting your cookies so that the song list are according to your taste
get_cookies get_cookies
printf '' > "$logdir/next" printf '' >"$logdir/next"
printf "%s\n" "$res" >> "$logdir/next" printf "%s\n" "$res" >>"$logdir/next"
printf "%s" "$res" | cut -f2 > "$logdir/start" printf "%s" "$res" | cut -f2 >"$logdir/start"
printf "0" > "$logdir/counter" printf "0" >"$logdir/counter"
rm -f "$logdir/continue_token" rm -f "$logdir/continue_token"
[ -z "$res" ] || play "$res" "verbose" "1" [ -z "$res" ] || play "$res" "verbose" "1"
} }
@@ -282,8 +278,8 @@ play_next() {
pgrep -f "$socket" || return 0 pgrep -f "$socket" || return 0
i=$(cat "$logdir/counter") i=$(cat "$logdir/counter")
if [ -z "$1" ]; then if [ -z "$1" ]; then
: $((i+=1)) : $((i += 1))
play "$(sed -n "$((i+=1))p" "$logdir/next")" "$1" play "$(sed -n "$((i += 1))p" "$logdir/next")" "$1"
else else
notify-send -h "string:x-canonical-private-synchronous:${0##*/}" -i "$logdir/default.jpg" "$(cut -d">" -f1 "$logdir/current" | tr ':' '\n')" notify-send -h "string:x-canonical-private-synchronous:${0##*/}" -i "$logdir/default.jpg" "$(cut -d">" -f1 "$logdir/current" | tr ':' '\n')"
next=$(nl -n'ln' -v0 "$logdir/next" | sed "s/^$i /& /" | menu "YT-music [play-next]: " "$i") next=$(nl -n'ln' -v0 "$logdir/next" | sed "s/^$i /& /" | menu "YT-music [play-next]: " "$i")
@@ -291,8 +287,8 @@ play_next() {
i=$(printf '%s' "$next" | sed 's///g' | cut -f1 | tr -d ' ') i=$(printf '%s' "$next" | sed 's///g' | cut -f1 | tr -d ' ')
play "$(printf '%s' "$next" | cut -f2-)" "verbose" play "$(printf '%s' "$next" | cut -f2-)" "verbose"
fi fi
printf '%s' "$i" > "$logdir/counter" printf '%s' "$i" >"$logdir/counter"
tail -1 "$logdir/next" | grep -q "$(cut -d'>' -f2 < "$logdir/current")" && get_music_list tail -1 "$logdir/next" | grep -q "$(cut -d'>' -f2 <"$logdir/current")" && get_music_list
} }
menu() { menu() {