Nothing to see here, move along

This commit is contained in:
coolnsx
2023-07-02 18:06:47 +05:30
parent aaf6e3346b
commit 6b377d7856
9 changed files with 293 additions and 287 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/sh
menu_droid () {
fzf --prompt="$1" "$2"
fzf --prompt="$1" $2
}
menu_linux () {

22
ani-new
View File

@@ -1,6 +1,6 @@
#!/bin/sh
down () {
down() {
info_$os "$3 links fetched.."
choice=$(printf "stream\ndownload\ncast\nnext mirror" | menu_$os "??")
[ -z "$choice" ] && exit 0
@@ -17,20 +17,16 @@ down () {
}
decrypt_allanime() {
for result in $(printf '%s' "$1" | xxd -r -p | od -An -v -t u1)
do
for char in $(printf "%s" "1234567890123456789" | grep -o .)
do
decimal_char="$(printf "%02d" "'$char'")"
: $((result ^= decimal_char))
done
for hex in $(printf '%s' "$1" | sed 's/../&\n/g'); do
dec=$(printf '%d' "0x$hex")
xor=$((dec ^ 48))
oct=$(printf "%03o" "$xor")
#shellcheck disable=SC2059
printf "\\$(printf "%03o" "$result")"
printf "\\$oct"
done
}
provider_run(){
provider_run() {
info_$os "Fetching $1 links"
provider_id="$(decrypt_allanime "$(printf "%s" "$data" | sed -n "$2" | head -1 | cut -d':' -f2)" | sed "s/\/clock/\/clock\.json/")"
[ -z "$provider_id" ] && return 0
@@ -38,7 +34,6 @@ provider_run(){
[ -z "$provider_video" ] && return 0
[ -n "$3" ] && printf "%s : %s\n" "$1" "$provider_video" && return 0
case $provider_video in
*crunchyroll*) down "$base_url" "$(curl -s "$provider_video" -A "$agent" | sed -n '/x1080/{n;p;}')" "$1" ;;
*repackager.wixmp.com*) down "$base_url" "$(printf %s "$provider_video" | cut -d',' -f1,2 | tr -d ',' | sed 's|repackager.wixmp.com/||g')/mp4/file.mp4" "$1" ;;
*) down "$base_url" "$provider_video" "$1" ;;
esac
@@ -66,7 +61,6 @@ esac
trap "exit 0" INT HUP
info_$os "Parsing $base_url.. Please wait..."
query="query( \$search: SearchInput \$limit: Int \$page: Int \$translationType: VaildTranslationTypeEnumType \$countryOrigin: VaildCountryOriginEnumType ) { shows( search: \$search limit: \$limit page: \$page translationType: \$translationType countryOrigin: \$countryOrigin ) { edges { _id name lastEpisodeInfo __typename } }}"
[ -z "$1" ] && url=$(curl -e 'https://allanime.to' -s --cipher 'AES256-SHA256' -G "${base_url}/api" -d "variables=%7B%22search%22%3A%7B%22sortBy%22%3A%22Recent%22%2C%22allowAdult%22%3Atrue%2C%22allowUnknown%22%3Atrue%7D%2C%22limit%22%3A40%2C%22page%22%3A1%2C%22translationType%22%3A%22sub%22%2C%22countryOrigin%22%3A%22JP%22%7D" --data-urlencode "query=$query" -A "$agent" | sed 's|Show|\n|g' | sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":\{"episodeString":"([^"]*)".*|\1\t\2 Episode \3|p' | menu_$os "Select Anime: " '--with-nth 2..' | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/watch/(.*)-sub|\1|p')
@@ -77,7 +71,7 @@ ep_no=$(printf "%s" "$url" | sed 's/.*Episode //g')
info_$os "Loading Episode $title.."
episode_embed_gql="query (\$showId: String!, \$translationType: VaildTranslationTypeEnumType!, \$episodeString: String!) { episode( showId: \$showId translationType: \$translationType episodeString: \$episodeString ) { episodeString sourceUrls }}"
data=$( curl -e https://allanime.to -sL --cipher AES256-SHA256 -G "{$base_url}/api" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" --data-urlencode "query=$episode_embed_gql" -A 'Mozilla/5.0 (Windows NT 6.1; Win64; rv:109.0) Gecko/20100101 Firefox/109.0' | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"#?([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
data=$(curl -e https://allanime.to -sL --cipher AES256-SHA256 -G "{$base_url}/api" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" --data-urlencode "query=$episode_embed_gql" -A 'Mozilla/5.0 (Windows NT 6.1; Win64; rv:109.0) Gecko/20100101 Firefox/109.0' | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"##([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
info_$os "Fetching Embed links"
#dropbox links

50
fap-cli
View File

@@ -8,7 +8,7 @@ c_magenta="\033[1;35m"
c_cyan="\033[1;36m"
c_reset="\033[0m"
help_text () {
help_text() {
while IFS= read -r line; do
printf "%s\n" "$line"
done <<-EOF
@@ -25,11 +25,11 @@ help_text () {
EOF
}
err () {
err() {
printf "$c_red%s$c_reset\n" "$*" >&2
}
get_query () {
get_query() {
[ -z "$*" ] && printf "${c_green}Search>${c_reset} " && read -r query || query=$*
query=$(printf "%s" "$query" | tr " " "+")
}
@@ -37,7 +37,7 @@ get_query () {
input() {
printf "$c_yellow Episode??(1-%s)>$c_reset " "$1"
read -r x
while [ -z "$x" ] || ! [ "$x" -eq "$x" ] 2>/dev/null || [ "$x" -lt "1" ] 2>/dev/null || [ "$x" -gt "$1" ] 2>/dev/null ;do
while [ -z "$x" ] || ! [ "$x" -eq "$x" ] 2>/dev/null || [ "$x" -lt "1" ] 2>/dev/null || [ "$x" -gt "$1" ] 2>/dev/null; do
err "Invalid choice"
printf "$c_yellow Episode??(1-%s)>$c_reset " "$1"
read -r x
@@ -46,22 +46,26 @@ input() {
unset x
}
stream () {
stream() {
case $player_fn in
vlc)
uname -a | grep -qE "[Aa]ndroid" && am start --user 0 -a android.intent.action.VIEW -d "$1" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "$2" > /dev/null 2>&1 || setsid -f "$player_fn" --http-referrer="$base_url" "$1" > /dev/null 2>&1;;
uname -a | grep -qE "[Aa]ndroid" && am start --user 0 -a android.intent.action.VIEW -d "$1" -n org.videolan.vlc/org.videolan.vlc.gui.video.VideoPlayerActivity -e "title" "$2" >/dev/null 2>&1 || setsid -f "$player_fn" --http-referrer="$base_url" "$1" >/dev/null 2>&1
;;
mpv)
uname -a | grep -qE "[Aa]ndroid" && am start --user 0 -a android.intent.action.VIEW -d "$1" -n is.xyz.mpv/.MPVActivity > /dev/null 2>&1 || setsid -f "$player_fn" "$1" --referrer="$base_url" --force-media-title="$2" > /dev/null 2>&1;;
uname -a | grep -qE "[Aa]ndroid" && am start --user 0 -a android.intent.action.VIEW -d "$1" -n is.xyz.mpv/.MPVActivity >/dev/null 2>&1 || setsid -f "$player_fn" "$1" --referrer="$base_url" --force-media-title="$2" >/dev/null 2>&1
;;
esac
}
download () {
download() {
printf "${c_blue}Downloading %s${c_reset}\n" "$2"
case $1 in
*m3u8)
ffmpeg -loglevel error -stats -referer "$base_url" -i "$1" -c copy "$download_dir/$u2.mp4";;
hls -n 300 -ro "$download_dir/$2" "$1"
;;
*)
aria2c --summary-interval=0 -x 16 -s 16 --referer="$base_url" "$1" --dir=$download_dir -o "$2.mp4" --download-result=hide;;
aria2c --summary-interval=0 -x 16 -s 16 --referer="$base_url" "$1" --dir=$download_dir -o "$2.mp4" --download-result=hide
;;
esac
}
@@ -80,7 +84,7 @@ get_show() {
get_ep_link
}
get_ep_link(){
get_ep_link() {
tput clear
printf "${c_blue}Loading Episode $ep_no"
ep_id=$(printf "%s" "$ep_list" | sed -n "${ep_no}p")
@@ -94,12 +98,12 @@ play_link() {
data="$(curl -s "$(curl -s "$base_url/wp-admin/admin-ajax.php" -d "action=get_player_contents&a=$id" -H "X-Requested-With:XMLHttpRequest" | tr -d '\\' | sed -nE 's/.*src="(.*)" width.*,.*/\1/p')")"
video_link="$(printf "%s" "$data" | sed -nE 's/[[:space:]]*<source src="(.*)" typ.*/\1/p')"
[ -z "$video_link" ] && video_link="$(printf "%s" "$data" | sed -nE 's/[[:space:]]*file: "(.*)".$/\1/p')"
if [ -z "$video_link" ];then
if [ -z "$video_link" ]; then
printf "\33[2K\r${c_red}Video Url not found${c_reset}\n"
else
printf "\33[2K\r${c_green}Video link fetched${c_reset}\n"
printf "\n%s\n" "$video_link"
if [ "$is_download" -eq "0" ];then
if [ "$is_download" -eq "0" ]; then
stream "$video_link" "$display"
else
download "$video_link" "$display"
@@ -125,7 +129,7 @@ while getopts 'dhp:v' OPT; do
v)
player_fn="vlc"
;;
*|h)
* | h)
help_text
exit 0
;;
@@ -147,19 +151,25 @@ while :; do
read choice
case $choice in
d)
download "$video_link" "$display";;
download "$video_link" "$display"
;;
n)
ep_no=$((ep_no + 1))
[ "$ep_no" -gt "$noofeps" ] && err "Episode out of range" && ep_no=$((ep_no-1)) || get_ep_link;;
[ "$ep_no" -gt "$noofeps" ] && err "Episode out of range" && ep_no=$((ep_no - 1)) || get_ep_link
;;
p)
ep_no=$((ep_no - 1))
[ "$ep_no" -lt "1" ] && err "Episode out of range" && ep_no=$((ep_no+1)) || get_ep_link;;
[ "$ep_no" -lt "1" ] && err "Episode out of range" && ep_no=$((ep_no + 1)) || get_ep_link
;;
e)
input "$noofeps"
get_ep_link;;
get_ep_link
;;
q)
break;;
break
;;
*)
err "invalid choice";;
err "invalid choice"
;;
esac
done

1
rss
View File

@@ -1,6 +1,5 @@
#!/bin/sh
if [ "$(uname -o)" = "Android" ]; then
os="droid"
script_dir="$HOME"

View File

@@ -2,12 +2,13 @@
#this script uses the piratesbay api to search for torrents
cal_size() {
printf "%.03f\n" "$(($1/1000))e-6"
printf "%.03f\n" "$(($1 / 1000))e-6"
}
display() {
for i in $(seq $(printf "%s\nlol" "$2" | wc -l));do
printf "[%s GB;S:%s\n" "$(cal_size "$(printf "%s" "$1" | sed -n "${i}p")")" "$(printf "%s" "$2" | sed -n "${i}p")" & done
for i in $(seq $(printf "%s\nlol" "$2" | wc -l)); do
printf "[%s GB;S:%s\n" "$(cal_size "$(printf "%s" "$1" | sed -n "${i}p")")" "$(printf "%s" "$2" | sed -n "${i}p")" &
done
wait
}

11
torrent
View File

@@ -6,7 +6,7 @@ c_yellow="\033[1;33m"
c_cyan="\033[1;36m"
c_reset="\033[0m"
down(){
down() {
tput reset
info_$os "Torrent: Downloading"
aria2c -d Downloads --select-file=$2 --seed-time=0 $1 && info_$os "Torrent: Download complete" && rm -f $file || error_$os "Torrent: Error!!"
@@ -29,7 +29,8 @@ printf "${c_reset}\n\tenter choice:"
read -r ch
case $ch in
f)
down "$magnet";;
down "$magnet"
;;
p)
aria2c --dir=$HOME/.cache --bt-metadata-only=true --bt-save-metadata=true "$magnet"
tput reset
@@ -37,7 +38,9 @@ case $ch in
printf "Enter file idx(default=all):"
read -r ind
down "$HOME/.cache/*.torrent" "$ind"
rm -f $HOME/.cache/*.torrent;;
rm -f $HOME/.cache/*.torrent
;;
q)
exit 0;;
exit 0
;;
esac

14
youtube
View File

@@ -1,5 +1,3 @@
#!/bin/sh
# script for downloading videos/audios from sites...
# defining shell colors for distinction
@@ -11,7 +9,7 @@ c_magenta="\033[1;35m"
c_cyan="\033[1;36m"
c_reset="\033[0m"
part(){
part() {
printf "${c_magenta}Enter Starting Point(hh:mm:ss)or(mm:ss)${c_reset}:"
read start
printf "${c_yellow}Enter Upto Seconds:${c_cyan}"
@@ -27,9 +25,9 @@ printf "${c_yellow}Download>>\n${c_blue}[a]Audio only\n${c_magenta}[f]part of Au
printf "\n${c_reset}Enter choice:${c_green}"
read choice
case $choice in
a) yt-dlp -f 'ba' -x --audio-format mp3 "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "audio downloaded";;
f) part "$x" "mp3" "ba" && termux-notification -c "audio downloaded";;
v) yt-dlp "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "video downloaded";;
p) part "$x" "mp4" "b" && termux-notification -c "video downloaded";;
q) exit 0;;
a) yt-dlp -f 'ba' -x --audio-format mp3 "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "audio downloaded" ;;
f) part "$x" "mp3" "ba" && termux-notification -c "audio downloaded" ;;
v) yt-dlp "$x" -o "/sdcard/%(title)s.%(ext)s" && termux-notification -c "video downloaded" ;;
p) part "$x" "mp4" "b" && termux-notification -c "video downloaded" ;;
q) exit 0 ;;
esac

View File

@@ -1,6 +1,6 @@
#!/bin/sh
help(){
help() {
case $1 in
search*)
name="search_play"
@@ -39,6 +39,7 @@ help(){
tip:
type ${0##*/} help <function_name> to get individual help
"
;;
esac
while read -r line; do
printf "%s\n" "$line"
@@ -53,20 +54,20 @@ help(){
exit 0
}
get_data(){
get_data() {
curl -X POST -A "$agent" -s "$base_url/youtubei/v1/$1?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30&prettyPrint=false" -H "content-type:application/json" -H "x-youtube-client-name:67" -H "x-youtube-client-version:1.20221128.01.00" -d "$2" -b "$cookie" -e "$base_url/$3" -c "$cookie"
}
loop(){
loop() {
#this function does exactly what it says, it should run in the background, u can even put this in startup
#it plays next song after the current song get played completely,it does nothing until u run the search_play function then this script kicks in
#call it by script-name "loop" "print" for printing the remaining time in terminal
#call it by script-name "loop" for anonymously
trap "rm -f $logdir/next;exit" INT HUP TERM
while true;do
while true; do
sleep 4
pos=$(echo '{ "command": ["get_property", "time-remaining"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^\.]*).*_\1_p')
while [ -n "$pos" ];do
while [ -n "$pos" ]; do
pos=$(echo '{ "command": ["get_property", "time-remaining"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^\.]*).*_\1_p')
[ -z "$1" ] || printf "\033[2K\rnext music in $pos second(s)%s" "$(echo '{ "command": ["get_property", "pause"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^,]*).*_\1_p' | sh && printf " (paused)")"
[ -z "$pos" ] && printf "\033[2K\r\n"
@@ -74,11 +75,11 @@ loop(){
done
pos=$(echo '{ "command": ["get_property", "time-remaining"]}' | socat - /tmp/mpvsocket | sed -nE 's_.*data":([^\.]*).*_\1_p')
pgrep -f "mpvsocket" >/dev/null || exit 0
[ -z "$pos" ] && pgrep -f "mpvsocket" > /dev/null && [ -n "$(cat "$logdir/next")" ] && play "$(shuf -n1 "$logdir/next")" "$1"
[ -z "$pos" ] && pgrep -f "mpvsocket" >/dev/null && [ -n "$(cat "$logdir/next")" ] && play "$(shuf -n1 "$logdir/next")" "$1"
done
}
play(){
play() {
#this function does all the heavy lifting of extracting url from given videoId
#it's also callable, u can use this function to play ur custom youtube URLs
#call it by script-name "play" "valid_youtube_id_or_url"
@@ -113,18 +114,18 @@ play(){
}"
audio_url=$(curl -X POST -A "$droid_agent" -s "https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false" -H "content-type:application/json" -d "$json" -b "$cookie" | sed -nE 's_.*itag":251,"url":"([^"]*)".*_\1_p')
if [ -n "$2" ];then
if [ -n "$2" ]; then
printf "Name >> %s\n" "$title"
printf "videoID >> %s\n" "$id"
printf "Audio URL >> %s\n" "$audio_url"
fi
curl -s "https://i.ytimg.com/vi/$id/hqdefault.jpg" -o - | convert - -crop 270x270+105+45 "$logdir/default.jpg" && notify-send -r 5 -i "$logdir/default.jpg" "Now Playing" "$title" -t 5000
pgrep -f "mpvsocket" > /dev/null || (setsid -f mpv --really-quiet --input-ipc-server=/tmp/mpvsocket --idle --quiet >/dev/null && sleep 1)
pgrep -f "mpvsocket" >/dev/null || (setsid -f mpv --really-quiet --input-ipc-server=/tmp/mpvsocket --idle --quiet >/dev/null && sleep 1)
echo "{ \"command\": [\"loadfile\", \"$audio_url\", \"replace\"] }" | socat - /tmp/mpvsocket
cut -d':' -f2 "$logdir/current" > "$logdir/prev"
cut -d':' -f2 "$logdir/current" >"$logdir/prev"
prev_id=$(cut -d'>' -f2 "$logdir/prev")
printf "currently playing : %s >%s\n" "$title" "$id" > "$logdir/current"
printf "currently playing : %s >%s\n" "$title" "$id" >"$logdir/current"
#next songs data
json_next="{
@@ -134,16 +135,16 @@ play(){
\"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' | sed "/$id/d;/$prev_id/d" > "$next_data" &
get_data "next" "$json_next" | sed 's/playlistPanelVideoRenderer/\n/g' | sed -nE 's_.*text":"(.*)"}.*longBylineText":\{"runs":\[\{"text":"([^"]*)","navigationEndpoint.*videoId":"([^"]*)".*_\1 - \2\t\3_p' | sed "/$id/d;/$prev_id/d" >"$next_data" &
pgrep -f "yt-music loop" || setsid -f $HOME/repos_scripts/yt-music loop
}
search_play(){
search_play() {
#run this if u r starting the script first time like this
#call this by "script-name" "search_play" "search_query"
[ -z "$1" ] && query=$(:| menu "Yt-music [Search]:") || query="$1"
[ -z "$1" ] && query=$(: | menu "Yt-music [Search]:") || query="$1"
[ -z "$query" ] && notify-send "Err.. Search query empty" -u critical -r 5 && exit 1
curl -A "$agent" -s "$base_url/" -c "$cookie" | sed -nE 's|.*INNERTUBE_CONTEXT":(.*),"INNERTUBE_CONTEXT_CLIENT_NAME.*|\1|p' > "$logdir/context"
curl -A "$agent" -s "$base_url/" -c "$cookie" | sed -nE 's|.*INNERTUBE_CONTEXT":(.*),"INNERTUBE_CONTEXT_CLIENT_NAME.*|\1|p' >"$logdir/context"
json_search="{
\"context\" : $(cat "$logdir/context"),
@@ -154,14 +155,14 @@ search_play(){
[ -z "$res" ] || play "$res" "verbose"
}
play_next(){
play_next() {
#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
#like this script-name "play_next" "menu"
[ -z "$1" ] && play "$(shuf -n1 "$logdir/next")" "verbose" || (pgrep -f "mpvsocket" && notify-send -r 5 -i "$logdir/default.jpg" "$(cut -d">" -f1 "$logdir/current" | tr ':' '\n')" && play "$(menu "YT-music [play-next]: " < "$logdir/next")" "verbose")
[ -z "$1" ] && play "$(shuf -n1 "$logdir/next")" "verbose" || (pgrep -f "mpvsocket" && notify-send -r 5 -i "$logdir/default.jpg" "$(cut -d">" -f1 "$logdir/current" | tr ':' '\n')" && play "$(menu "YT-music [play-next]: " <"$logdir/next")" "verbose")
}
menu(){
menu() {
bemenu --fn 'IBM Plex Sans 15' -i -c -W 0.5 -B 3 -p "$1" -l 26
}