rerouted: resourcing to music.youtube

This commit is contained in:
CoolnsX
2022-12-03 00:54:51 +05:30
parent 92cc433041
commit 1e470d2247

View File

@@ -81,18 +81,8 @@ play(){
id=$(printf "$1" | cut -d"=" -f2 | cut -d"/" -f4 | cut -d'&' -f1) id=$(printf "$1" | cut -d"=" -f2 | cut -d"/" -f4 | cut -d'&' -f1)
[ -z "$id" ] && printf "[ youtube ] Invalid link\n" && exit 1 [ -z "$id" ] && printf "[ youtube ] Invalid link\n" && exit 1
#next songs data
json_next="{
\"enablePersistentPlaylistPanel\": true,
\"tunerSettingValue\": \"AUTOMIX_SETTING_NORMAL\",
\"playlistId\": \"RD$id\",
\"isAudioOnly\": true,
\"context\": $(cat $logdir/context)
}"
get_data "next" "$json_next" | sed 's/playlistPanelVideoRenderer/\n/g' | sed -nE 's_.*text":"(.*)"}.*longBylineText":\{"runs":\[\{"text":"([^"]*)","navigationEndpoint.*videoId":"([^"]*)".*_\1 - \2\t\3_p' > "$next_data"
droid_agent="com.google.android.youtube/17.31.35 (Linux; U; Android 1$(head /dev/urandom | tr -dc '0-3' | cut -c1)) gzip"
#get song's audio url #get song's audio url
droid_agent="com.google.android.youtube/17.31.35 (Linux; U; Android 1$(head /dev/urandom | tr -dc '0-3' | cut -c1)) gzip"
json="{ json="{
\"context\": { \"context\": {
\"client\": { \"client\": {
@@ -128,6 +118,16 @@ play(){
pgrep -f "mpvsocket" > /dev/null || (setsid -f mpv --really-quiet --input-ipc-server=/tmp/mpvsocket --idle --quiet >/dev/null && sleep 3) pgrep -f "mpvsocket" > /dev/null || (setsid -f mpv --really-quiet --input-ipc-server=/tmp/mpvsocket --idle --quiet >/dev/null && sleep 3)
echo "{ \"command\": [\"loadfile\", \"$audio_url\", \"replace\"] }" | socat - /tmp/mpvsocket echo "{ \"command\": [\"loadfile\", \"$audio_url\", \"replace\"] }" | socat - /tmp/mpvsocket
echo "currently playing : $title" > "$logdir/current" echo "currently playing : $title" > "$logdir/current"
#next songs data
json_next="{
\"enablePersistentPlaylistPanel\": true,
\"tunerSettingValue\": \"AUTOMIX_SETTING_NORMAL\",
\"playlistId\": \"RD$id\",
\"isAudioOnly\": true,
\"context\": $(cat $logdir/context)
}"
get_data "next" "$json_next" | sed 's/playlistPanelVideoRenderer/\n/g' | sed -nE 's_.*text":"(.*)"}.*longBylineText":\{"runs":\[\{"text":"([^"]*)","navigationEndpoint.*videoId":"([^"]*)".*_\1 - \2\t\3_p' > "$next_data"
} }
search_play(){ search_play(){
@@ -149,7 +149,7 @@ play_next(){
#call this by script-name "play_next" for playing next song immediately #call this by script-name "play_next" for playing next song immediately
#or add "menu" after "play_next" to show menu for selecting and playing next song immediately #or add "menu" after "play_next" to show menu for selecting and playing next song immediately
#like this script-namr "play_next" "menu" #like this script-namr "play_next" "menu"
[ -z "$1" ] && play "$(cat "$logdir/next" | sed -n 2p | cut -f2)" "verbose" || play "$(cat $logdir/{current,next} | bemenu --fn 'Roboto 15' -i -c -W 0.5 -B 3 -p "play: " -l 30 | cut -f2)" "verbose" [ -z "$1" ] && play "$(cat "$logdir/next" | head -1 | cut -f2)" "verbose" || play "$(cat $logdir/{current,next} | bemenu --fn 'Roboto 15' -i -c -W 0.5 -B 3 -p "play: " -l 30 | cut -f2)" "verbose"
} }
logdir="${XDG_CACHE_HOME:-$HOME/.cache/yt-music}" logdir="${XDG_CACHE_HOME:-$HOME/.cache/yt-music}"