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,6 +1,5 @@
#!/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"
} }
@@ -73,6 +72,7 @@ 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

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"

View File

@@ -63,8 +63,7 @@ cleanup_shit(){
} }
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"
} }
@@ -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() {
@@ -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 &