I did it for the lulz!

This commit is contained in:
coolnsx
2022-11-29 18:19:25 +05:30
parent ef63c0ca38
commit ea45f42b48
5 changed files with 95 additions and 28 deletions

View File

@@ -3,9 +3,9 @@
down () { down () {
notify-send "$3 links fetched.." -r $tmp notify-send "$3 links fetched.." -r $tmp
choice=$(printf "download\nwatch\nnext mirror" | bemenu --fn 'Roboto 15' -p "??" -i -c -W 0.6 -B 3 -l 10) choice=$(printf "download\nwatch\nnext mirror" | bemenu --fn 'Roboto 15' -p "??" -i -c -W 0.6 -B 3 -l 10)
[ "$choice" = "watch" ] && setsid -f mpv --referrer="$1" "$2" --force-media-title="$url" && notify-send "opening $url in mpv" -r $tmp && exit 0 [ "$choice" = "watch" ] && setsid -f mpv --referrer="$1" "$2" --force-media-title="$url" && notify-send -i "$icon_dir/apps/mpv.svg" "opening $url" -r $tmp && exit 0
[ "$choice" = "next mirror" ] && return 0 [ "$choice" = "next mirror" ] && return 0
notify-send "Downloading $url" -r $tmp notify-send -i "$icon_dir/panel/jdownloader-indicator.svg" "Downloading $url" -r $tmp
case $2 in case $2 in
*m3u*) *m3u*)
foot -e ffmpeg -loglevel error -stats -referer "$1" -user_agent "$agent" -i "$2" -c copy "$url.mp4" && notify-send "Episode Downloaded $url" -r $tmp || (notify-send -u "critical" "Downloading failed $url" -r $tmp && exit 0);; foot -e ffmpeg -loglevel error -stats -referer "$1" -user_agent "$agent" -i "$2" -c copy "$url.mp4" && notify-send "Episode Downloaded $url" -r $tmp || (notify-send -u "critical" "Downloading failed $url" -r $tmp && exit 0);;
@@ -20,6 +20,7 @@ run () {
curl -s "$base_url?page=2" -A "$agent" | sed -nE 's_.*<a href="/videos/([^"]*)">_\1_p' & curl -s "$base_url?page=2" -A "$agent" | sed -nE 's_.*<a href="/videos/([^"]*)">_\1_p' &
} }
icon_dir="/usr/share/icons/Papirus/16x16"
base_url="https://gogohd.net" base_url="https://gogohd.net"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36"
trap "exit 0" INT HUP trap "exit 0" INT HUP

8
bkmark
View File

@@ -2,12 +2,12 @@
#script for bookmarking selected items and later using it.. #script for bookmarking selected items and later using it..
data="$(xclip -o | tr '\n' '\`')" data="$(wl-paste -p | tr '\n' '\`')"
file="$HOME/.cache/bookmarks" file="$HOME/.cache/bookmarks"
if [ "$*" = "add" ];then if [ "$*" = "add" ];then
if [ "$data" = "Error: target STRING not available" ];then if [ -z "$data" ];then
notify-send "Please select anything to bookmark" notify-send "Please select anything to bookmark"
elif grep -q "${data}" "$file";then elif grep -q "${data}" "$file";then
notify-send "Already bookmarked" notify-send "Already bookmarked"
@@ -18,10 +18,10 @@ if [ "$*" = "add" ];then
elif [ "$*" = "rm" ];then elif [ "$*" = "rm" ];then
data="$(cat "$file" | sed '/^$/d' | nl -n'ln')" data="$(cat "$file" | sed '/^$/d' | nl -n'ln')"
[ -z "$data" ] && notify-send "Bookmark is empty" && exit 0 [ -z "$data" ] && notify-send "Bookmark is empty" && exit 0
del=$(printf "%s" "$data" | dmenu -p "delete-bookmark :" | cut -f1) del=$(printf "%s" "$data" | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "delete-bookmark :" | cut -f1)
[ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send "Bookmarked deleted") [ -z "$del" ] || (sed -i "${del}d" "$file" && notify-send "Bookmarked deleted")
else else
xdotool type "$(cat "$file" | sed '/^$/d' | dmenu -p "Put-bookmark :" | tr '\`' '\n')" doas ydotool type "$(cat "$file" | sed '/^$/d' | bemenu --fn 'Roboto 15' -i -c -W 0.6 -B 3 -l 30 -p "Put-bookmark :" | tr '\`' '\n')"
fi fi
sed -i '/^$/d' "$file" sed -i '/^$/d' "$file"

View File

@@ -9,11 +9,11 @@ c_reset="\033[0m"
down(){ down(){
tput reset tput reset
notify-send "Torrent: Downloading" notify-send "Torrent: Downloading"
aria2c -d movies --select-file=$2 --seed-time=0 $1 && notify-send "Torrent: Download complete" && rm -f $file || notify-send -u critical "Torrent: Error!!" aria2c -d Downloads --select-file=$2 --seed-time=0 $1 && notify-send "Torrent: Download complete" && rm -f $file || notify-send -u critical "Torrent: Error!!"
} }
trap "rm -f $HOME/.cache/*.torrent;exit 0" INT HUP trap "rm -f $HOME/.cache/*.torrent;exit 0" INT HUP
[ -z "$*" ] && magnet="$(xclip -out clipboard)" || magnet="$*" [ -z "$*" ] && magnet="$(wl-paste)" || magnet="$*"
echo "$magnet" echo "$magnet"
printf "${c_yellow}Download>>\n${c_green}[f]ull torrent\n${c_cyan}[p]artial torrent \n${c_red}[q]uit" printf "${c_yellow}Download>>\n${c_green}[f]ull torrent\n${c_cyan}[p]artial torrent \n${c_red}[q]uit"
printf "${c_reset}\n\tenter choice:" printf "${c_reset}\n\tenter choice:"

View File

@@ -31,7 +31,7 @@ part(){
} }
#program starts from here.. #program starts from here..
x=$(xclip -out clipboard) x=$(wl-paste)
printf "${c_blue}Youtube link :${c_magenta}$x\n" printf "${c_blue}Youtube link :${c_magenta}$x\n"
printf "${c_yellow}Download>>\n${c_blue}[a]udio only\n${c_magenta}[f]part of Audio only\n${c_green}[v]ideo\n${c_cyan}[p]art of video\n${c_red}[q]uit" printf "${c_yellow}Download>>\n${c_blue}[a]udio only\n${c_magenta}[f]part of Audio only\n${c_green}[v]ideo\n${c_cyan}[p]art of video\n${c_red}[q]uit"
printf "\n${c_reset}Enter choice:${c_green}" printf "\n${c_reset}Enter choice:${c_green}"

View File

@@ -1,14 +1,80 @@
#!/bin/sh #!/bin/sh
# download/stream high quality mp3 music from youtube using ytmp3.com site
#this script give link which can be used to download or stream music
[ -z "$*" ] && id=$(printf "" | dmenu -p "Paste yt-link(ctrl + y):") || id=$* loop(){
id=$(printf "$id" | cut -d"=" -f2 | cut -d"/" -f4) while true;do
printf "\033[1;34mFetching page" sleep 4
token=$(curl -s "https://ytmp3x.com/$id" | sed -nE 's/.*token":"(.*)","adg.*/\1/p') pos=$(echo '{ "command": ["get_property", "time-remaining"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^\.]*).*_\1_p')
printf "\33[2K\r\033[1;35mFetching tokens" while [ -n "$pos" ];do
[ -z "$token" ] || token2=$(curl -s -X POST -H "X-Requested-With:XMLHttpRequest" 'https://ytmp3x.com/ajax' -d "purpose=audio&token=$token" | sed -nE 's/.*audio":"(.*)"\}/\1/p') pos=$(echo '{ "command": ["get_property", "time-remaining"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^\.]*).*_\1_p')
printf "\33[2K\r\033[1;36mFetching mp3 link" [ -z "$1" ] || printf "\033[2K\r$pos"
[ -z "$token2" ] || url=$(curl -s -X POST -H "X-Requested-With:XMLHttpRequest" "https://ytmp3x.com/ajax" -d "purpose=download&token=$token2&b=320&r=https://ytmp3x.com/$id" | tr -d '\\' | sed -nE 's/.*mp3url":"(.*)"\}/\1/p') sleep 2
[ -z "$url" ] && printf "\33[2K\r\033[1;31m unable to fetch mp3 link\033[0m" && exit 0 done
printf "\32[2K\r\033[0m %s\n" "$url" pos=$(echo '{ "command": ["get_property", "time-remaining"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^\.]*).*_\1_p')
[ -z "$pos" ] && pgrep mpv > /dev/null && play "$(cat "$logdir/next" | sed -n 2p | cut -f2)"
done
}
play(){
id=$(printf "$1" | cut -d"=" -f2 | cut -d"/" -f4 | cut -d'&' -f1)
[ -z "$id" ] && printf "[ youtube ] Invalid link\n" && exit 1
json="{
\"context\": {
\"client\": {
\"clientName\": \"ANDROID\",
\"clientVersion\": \"17.31.35\",
\"androidSdkVersion\": 30,
\"userAgent\": \"$agent\",
\"hl\": \"en\",
\"timeZone\": \"UTC\",
\"utcOffsetMinutes\": 0
}
},
\"videoId\": \"$id\",
\"playbackContext\": {
\"contentPlaybackContext\": {
\"html5Preference\": \"HTML5_PREF_WANTS\"
}
},
\"contentCheckOk\": true,
\"racyCheckOk\": true
}"
#main logic
curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.115 Safari/537.36" -s "https://www.youtube.com/watch?v=$id&bpctr=9999999999&has_verified=1" -c "$cookie" | sed 's/compactVideoRenderer/\n/g' | sed -nE 's_.*videoId":"([^"]*)".*label":"([^"]*)".*_\2\t\1_p' | sed "/$id/d" > "$next_data"
data=$(curl -X POST -A "$agent" -s "https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false" -H "content-type:application/json" -H "x-youtube-client-name:21" -H "x-youtube-client-version:17.31.35" -d "$json" -b "$cookie" | sed -nE 's_.*itag":[0-9]*,"url":"([^"]*)".*"title":"([^"]*)".*_\1\n\2_p')
title=$(printf "%s" "$data" | tail -1)
audio_url=$(printf "%s" "$data" | head -1)
printf "Name >> %s\n" "$title"
printf "referer >> %s\n" "$*"
printf "Audio URL >> %s\n" "$audio_url"
curl -s "https://i.ytimg.com/vi/$id/default.jpg" -o "$logdir/default.jpg" && notify-send -i "$logdir/default.jpg" "Now Playing" "$title" -t 5000
pgrep mpv > /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 "currently playing : $title" > "$logdir/current"
}
search(){
context=$(curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.115 Safari/537.36" -s "https://www.youtube.com/" -c "$cookie" | sed -nE 's|.*INNERTUBE_CONTEXT":(.*),"INNERTUBE_CONTEXT_CLIENT_NAME.*|\1|p')
json_search="{
\"context\" : $context,
\"query\": \"$1\",
\"params\": \"EgWKAQIIAWoKEAMQBBAJEAoQBQ%3D%3D\"
}"
curl -X POST -A "$agent" -s "https://www.youtube.com/youtubei/v1/search?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false" -H "content-type:application/json" -H "x-youtube-client-name:21" -H "x-youtube-client-version:17.31.35" -d "$json_search" -b "$cookies" | sed 's/videoRenderer/\n/g' | sed -nE 's_.*videoId":"([^"]*)".*\],"accessibility":\{"accessibilityData":\{"label":"([^"]*)".*_\2\t\1_p' | bemenu --fn 'Roboto 15' -i -c -W 0.5 -B 3 -p "Play: " -l 30 | cut -f2
}
search_play(){
res=$(search "$1")
play "$res"
}
logdir="${XDG_CACHE_HOME:-$HOME/.cache/yt-music}"
[ -d "$logdir" ] || mkdir "$logdir"
cookie="$logdir/cookies"
next_data="$logdir/next"
agent="com.google.android.apps.youtube.music/5.16.51 (Linux; U; Android 1$(head /dev/urandom | tr -dc '0-3' | cut -c1)) gzip"
$1 "$2"