I don't know why. Just move on.

This commit is contained in:
coolnsx
2024-05-14 16:45:28 +05:30
parent 19a2f9f1e7
commit 95b3b0b284
7 changed files with 43 additions and 51 deletions

View File

@@ -32,7 +32,7 @@ info_droid() {
}
info_linux() {
notify-send "$1" -r '10' -i "$2" $3
notify-send -e "$1" -r '10' -i "$2" $3
}
error_droid() {
@@ -40,7 +40,7 @@ error_droid() {
}
error_linux() {
notify-send -u "critical" "$1" -r '10'
notify-send -e -u "critical" "$1" -r '10'
}
player_droid() {

28
ani-new
View File

@@ -1,28 +1,19 @@
#!/bin/sh
allanime_curl() {
curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode "$1" --data-urlencode "$2"
}
domain="allanime.day"
run_file="${TMPDIR:-/tmp}/${0##*/}_run"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '0-3' | cut -c1).0.0.0 Safari/537.36"
debug=$2
\cat << EOF > $run_file
search() {
curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode '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}}}' --data-urlencode 'variables={"search":{"sortBy":"Recent","allowAdult":true,"allowUnknown":true,"query":"'"\$1"'"},"limit":40,"page":1,"translationType":"sub","countryOrigin":"ALL"}' | sed 's|Show|\n|g' | sed 's|__typename|\n|g' | sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":\{"episodeString":"([^"]*)".*|\1\t\2 Episode \3|p'
}
[ -n "\$2" ] && search "\$1"
\cat << EOF > "$run_file"
search() { curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode '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}}}' --data-urlencode 'variables={"search":{"sortBy":"Recent","allowAdult":true,"allowUnknown":true,"query":"'"\$1"'"},"limit":40,"page":1,"translationType":"sub","countryOrigin":"ALL"}' | sed 's|Show|\n|g' | sed 's|__typename|\n|g' | sed -nE 's|.*_id":"([^"]*)","name":"([^"]*)".*sub":\{"episodeString":"([^"]*)".*|\1\t\2 Episode \3|p'; }; [ -n "\$2" ] && search "\$1"
EOF
chmod +x "$run_file"
# shellcheck source=/tmp/ani-new_run
. "$run_file"
case $(uname -o) in
*ndroid*)
os="droid"
@@ -39,12 +30,13 @@ esac
# shellcheck source=./.functions
. "$script_dir/.functions"
. "$run_file"
trap "exit 0" INT HUP
info_$os "Parsing $domain.. Please wait..."
#shellcheck disable=SC2016
[ -z "$1" ] && url=$(search | fzf --bind="change:reload:$run_file {q} 1" --prompt="Select Anime: " --with-nth 2.. -m | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/bangumi/([^/]*)/([^/]*)/p-([^-]*)-sub|\1\t\2 Episode \3|p')
[ -z "$1" ] && url=$(search | (
[ "$os" != "linux" ] && fzf --bind="change:reload:$run_file {q} 1" --prompt="Select Anime: " --with-nth 2.. -m || menu_$os "Select Anime: "
) | tr ':' ' ' | tr -s ' ') || url=$(printf "%s" "$1" | sed -nE 's|.*/bangumi/([^/]*)/([^/]*)/p-([^-]*)-sub|\1\t\2 Episode \3|p')
[ -z "$url" ] && error_$os "No anime selected" && exit 0
@@ -55,7 +47,7 @@ printf "%s\n" "$url" | while read -r id title; do
[ -n "$debug" ] && printf "\n\033[1;36m title\033[0m : %s\n" "$title"
#shellcheck disable=SC2016
data=$(allanime_curl "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" 'query=query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}' | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
data=$(curl -e "https://allanime.to" -sL -G "https://api.${domain}/api" -A "$agent" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"sub\",\"countryOrigin\":\"ALL\",\"episodeString\":\"$ep_no\"}" --data-urlencode 'query=query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}' | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')
info_$os "Fetching Embed links"
printf 'dropbox\tSak\nwetransfer\tKir\nsharepoint\tS-mp4\ngogoplay\tLuf-mp4\n' | while read -r provider_name provider_regex; do

View File

@@ -15,7 +15,7 @@ notify_droid() {
}
notify_linux() {
notify-send "$1" -h "string:x-canonical-private-synchronous:${0##*/}"
notify-send -e "$1" -h "string:x-canonical-private-synchronous:${0##*/}"
}
conv_to_octal(){

View File

@@ -58,7 +58,7 @@ case $app in
youtube)
arch="universal"
[ -z "$2" ] && version=$(curl -s "https://api.revanced.app/v2/patches/latest" | sed -nE 's|.*youtube","versions":\[[0-9\.",]*,"([^\}]*)"\].*|\1|p') || version=$2
exclude_patch_list="always-repeat,disable-auto-captions,disable-zoom-haptics,enable-debugging,downloads,hide-autoplay-button,hide-captions-button,hide-cast-button,hide-floating-microphone-button,hide-layout-components,hide-'load-more'-button,hide-player-buttons,custom-player-overlay-opacity,hide-seekbar,hide-timestamp,hide-video-action-buttons,navigation-buttons,player-flyout-menu,remove-player-controls-background,spoof-app-version,swipe-controls"
exclude_patch_list="always-repeat,disable-auto-captions,disable-zoom-haptics,enable-debugging,downloads,hide-autoplay-button,hide-captions-button,hide-cast-button,hide-floating-microphone-button,hide-layout-components,hide-player-buttons,custom-player-overlay-opacity,hide-seekbar,hide-timestamp,hide-video-action-buttons,navigation-buttons,player-flyout-menu,remove-player-controls-background,spoof-app-version,swipe-controls"
out="yt-revanced-$version.apk"
;;
youtube-music)

29
screen
View File

@@ -4,7 +4,7 @@
# ability to record both mic and speaker at same time is coming soon
info() {
notify-send -h "string:x-canonical-private-synchronous:${0##*/}" -i "$1" -t "${2:-5000}" "$3" "$4"
notify-send -e -h "string:x-canonical-private-synchronous:${0##*/}" -i "$1" -t "${2:-5000}" "$3" "$4"
}
menu() {
@@ -63,39 +63,32 @@ stop() {
*nextcloud)
#shellcheck disable=SC1091
. "$HOME"/.secrets
#load nextcloud creds only
load_nextcloud_creds
. "$HOME"/.config/.env
cloudname="screenrecord-$(date +"%F_%H-%M-%S").mp4"
#upload to nextcloud instance, universal code
info "nextcloud" "10000" "Uploading to NextCloud"
curl "$NC_HOST/remote.php/dav/files/${NC_USER}${NC_FOLDER_PATH}/$cloudname" -b "$NC_COOKIES" -H "Requesttoken: $NC_TOKEN" -T "$tmp_file" || (info "" "2000" "Unable to upload to Nextcloud,moved the file from temp to your home folder as $cloudname" && mv "$tmp_file" "$HOME/$cloudname" && return 1)
curl -u "$NC_USER:$NC_TOKEN" -s "$NC_URL/remote.php/dav/files/${NC_USER}${NC_SHARE_PATH}/$cloudname" -T "$tmp_file" || (info "" "2000" "Unable to upload to Nextcloud,moved the file from temp to your home folder as $cloudname" && mv "$tmp_file" "$HOME/$cloudname" && return 1)
info "nextcloud" "" "Getting File Id"
file_id=$(curl -s "$NC_HOST/remote.php/dav/files/${NC_USER}${NC_FOLDER_PATH}" -X 'PROPFIND' -b "$NC_COOKIES" -H "Requesttoken: $NC_TOKEN" --data-raw '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns"><d:prop><oc:fileid /><nc:system-tags /></d:prop></d:propfind>' | sed 's|d:response|\n|g' | sed -nE "s|.*<d:href>.*$cloudname.*<oc:fileid>([^<]*).*|\1|p" | head -1)
[ "$file_id" = "$NC_FOLDER_ID" ] && file_id=""
info "nextcloud" "10000" "Setting Retention Policy & Generating Share Link"
curl -sX PUT "$NC_HOST/remote.php/dav/systemtags-relations/files/$file_id/1" -b "$NC_COOKIES" -H "Requesttoken: $NC_TOKEN" -: -s -b "$NC_COOKIES" -H "Requesttoken: $NC_TOKEN" "$NC_HOST/ocs/v2.php/apps/files_sharing/api/v1/shares" -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -H 'OCS-APIRequest: true' --data-raw "{\"path\":\"${NC_FOLDER_PATH}/$cloudname\",\"shareType\":3,\"attributes\":\"[]\"}" | sed -nE 's|.*"url":"([^"]*)".*|\1|p' | sed 's/\\//g' | wl-copy && info "com.github.davidmhewitt.clipped" "2000" "Share Link Created and copied to clipboard"
file_id=$(curl -u "$NC_USER:$NC_TOKEN" -s "$NC_URL/remote.php/dav/files/${NC_USER}${NC_SHARE_PATH}/$cloudname" -X 'PROPFIND' -b "$NC_COOKIES" -H "Requesttoken: $NC_TOKEN" --data-raw '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns"><d:prop><oc:fileid /><nc:system-tags /></d:prop></d:propfind>' | sed 's|d:response|\n|g' | sed -nE "s|.*<d:href>.*$cloudname.*<oc:fileid>([^<]*).*|\1|p" | head -1)
[ -z "$file_id" ] && info "" "2000" "File not uploaded correctly,moved the file from temp to your home folder as $cloudname" && mv "$tmp_file" "$HOME/$cloudname" && return 1
info "nextcloud" "10000" "Generating Share Link"
expire_date=$(date -d "+ 1 month" +"%Y-%m-%d") # link won't available after 1 month
curl -u "$NC_USER:$NC_TOKEN" -s "$NC_URL/ocs/v2.php/apps/files_sharing/api/v1/shares" -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -H 'OCS-APIRequest: true' --data-raw '{"path":"'"${NC_SHARE_PATH}/$cloudname"'","shareType":3,"expireDate":"'"$expire_date"'"}' | sed -nE 's|.*"url":"([^"]*)".*|\1|p' | sed 's/\\//g' | wl-copy && info "com.github.davidmhewitt.clipped" "2000" "Share Link Created and copied to clipboard"
;;
*discord)
#shellcheck disable=SC1091
. "$HOME"/.secrets
. "$HOME"/.config/.env
#load discord creds only
load_discord_creds
base_url="https://discord.com/api/v10"
channel=$(curl -s "$base_url/guilds/$SERVER_ID/channels" -H "Authorization: $TOKEN" | tr '{}' '\n' | sed -nE 's|.*"id":"([^"]*)".*last_message_id.*"name":"([^"]*)".*|\1\t\2|p' | menu "Select Channel: ")
channel=$(curl -s "$DISCORD_URL/guilds/$DISCORD_SERVER_ID/channels" -H "Authorization: $DISCORD_TOKEN" | tr '{}' '\n' | sed -nE 's|.*"id":"([^"]*)".*last_message_id.*"name":"([^"]*)".*|\1\t\2|p' | menu "Select Channel: ")
channel_name=$(printf "%s" "$channel" | cut -f2)
channel_id=$(printf "%s" "$channel" | cut -f1)
[ "$(du -m "$tmp_file" | cut -f1)" -gt 25 ] && compress #compressing file if greater than 25 MB
info "discord" "" "Uploading to Discord in $channel_name"
content="${tmp_file##*/} ($(du -h "$tmp_file" | cut -f1)) uploaded by coolans"
curl -s "$base_url/channels/$channel_id/messages" -H "Authorization: $TOKEN" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -X POST -F "file=@$tmp_file" -F 'payload_json={"content":"'"${content}"'"}' && info "" "2000" "Uploaded $tmp_file ($(du -h "$tmp_file" | cut -f1)) to $channel_name in Discord" && return 0
curl -s "$DISCORD_URL/channels/$channel_id/messages" -H "Authorization: $DISCORD_TOKEN" -H "Accept: application/json" -H "Content-Type: multipart/form-data" -X POST -F "file=@$tmp_file" -F 'payload_json={"content":"'"${content}"'"}' && info "" "2000" "Uploaded $tmp_file ($(du -h "$tmp_file" | cut -f1)) to $channel_name in Discord" && return 0
filename="screenrecord-$(date +"%F_%H-%M-%S").mp4"
mv "$tmp_file" "$HOME/$filename" && info "" "2000" "Unable to upload to Discord,file moved to your home folder as $filename"
;;

View File

@@ -26,11 +26,11 @@ esac
. $script_dir/.functions
[ -z "$*" ] && search_$os "Search Torrent: " || query=$*
[ -z "$query" ] && exit 0
[ "$os" = "linux" ] && tmp=$(notify-send "Searching query" -p)
[ "$os" = "linux" ] && tmp=$(notify-send -e "Searching query" -p)
query=$(printf "%s" "$query" | tr " " "+")
data=$(curl -s "https://apibay.org/q.php?q=$query" | tee data | sed 's/},/}\n/g' | tr -d "[]")
[ "$os" = "linux" ] && notify-send "tidying up data" -r $tmp
[ "$os" = "linux" ] && notify-send -e "tidying up data" -r $tmp
size=$(printf "%s" "$data" | sed -nE 's/.*name.*size":"(.*)",.*user.*/\1/p')
name_seed=$(printf "%s" "$data" | sed -nE 's/.*name":"(.*)","info_hash.*seeders":"(.*)",.*num.*/\2] \1/p')
sel=$(display "$size" "$name_seed" | menu_$os "Select Torrent: " | cut -d" " -f3-)

View File

@@ -93,7 +93,8 @@ get_music_list() {
\"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')
printf '%s' "$next_data" | sed -e "$(cut -f2 "/tmp/yt-music/next" | sed 's|^|/|g;s|$|/d|g')" -e '/"continuation"/d' >>"$logdir/next"
#shellcheck disable=SC1091,SC2094
printf '%s' "$next_data" | sed -e "$(cut -f2 "$logdir/next" | sed 's|^|/|g;s|$|/d|g')" -e '/"continuation"/d' >>"$logdir/next"
printf '%s' "$next_data" | sed -n '/"continuation"/p' >"$logdir/continue_token"
}
@@ -141,7 +142,10 @@ loop() {
[ -n "$(cat "$logdir/next")" ]
play "$(sed -n "$((i += 1))p" "$logdir/next")" "$1"
printf '%s' "$i" >"$logdir/counter"
tail -1 "$logdir/next" | grep -q "$(cut -d'>' -f2 <"$logdir/current")" && get_music_list
# shellcheck source=/tmp/yt-music/current
# shellcheck disable=SC1091
. "$logdir/current"
tail -1 "$logdir/next" | grep -q "$ID" && get_music_list
fi
done
cleanup_shit
@@ -194,7 +198,7 @@ play() {
#get song's audio url
random_no=$(head /dev/urandom | tr -dc '0-4' | cut -c1)
andy_yt_ver="6.26.50"
andy_yt_ver="6.50.53"
extra_up=$((random_no > 1))
droid_agent="com.google.android.apps.youtube.music/$andy_yt_ver (Linux; U; Android 1$random_no) gzip"
json="{
@@ -227,10 +231,10 @@ play() {
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 -h "string:x-canonical-private-synchronous:${0##*/}" -i "$logdir/default.jpg" "Now Playing" "$title" -t 5000
curl -s "https://i.ytimg.com/vi/$id/hqdefault.jpg" -o - | convert - -crop 270x270+105+45 "$logdir/default.jpg" && notify-send -e -h "string:x-canonical-private-synchronous:${0##*/}" -i "$logdir/default.jpg" "Now Playing" "$title" -t 5000
pgrep -f "$socket" >/dev/null || (setsid -f mpv --really-quiet --input-ipc-server="$socket" --idle --quiet >/dev/null && sleep 1)
printf '{"command":["loadfile","%s","replace"]}\n' "$audio_url" | socat - "$socket"
printf "currently playing : %s >%s\n" "$title" "$id" >"$logdir/current"
printf "SONG='%s'\nARTIST='%s'\nID='%s'" "$(printf '%s' "$title" | sed 's|[^-]*$||g;s|-$||g;s| $||g;s|^ ||g')" "$(printf '%s' "$title" | sed 's_.* - __;s| $||')" "$id" >"$logdir/current"
#required for discord rich presence to set end timestamp
duration=$(printf '%s' "$audio_url" | sed -nE 's|.*&dur=([^\.]*).*|\1|p')
@@ -254,10 +258,10 @@ search_play() {
#run this if u r starting the script first time like this
#call this by "script-name" "search_play" [ search_query | youtube_id by prefixing with ID:<youtube_id> | youtube url ]
[ -z "$1" ] && query=$(: | menu "Yt-music [Search]:" "" "60") || query="$1"
[ -z "$query" ] && notify-send "Err.. Search query empty" -u critical -h "string:x-canonical-private-synchronous:${0##*/}" && exit 1
[ -z "$query" ] && notify-send -e "Err.. Search query empty" -u critical -h "string:x-canonical-private-synchronous:${0##*/}" && exit 1
#storing context
printf '{"client":{"clientName":"WEB_REMIX","clientVersion":"1.20240226.01.00"}}' >"$logdir/context"
printf '{"client":{"clientName":"WEB_REMIX","clientVersion":"1.20240501.01.00"}}' >"$logdir/context"
#extracting your cookies so that the song list are according to your taste
get_cookies
@@ -294,7 +298,10 @@ play_next() {
: $((i += 1))
play "$(sed -n "$((i += 1))p" "$logdir/next")" "$1"
else
notify-send -h "string:x-canonical-private-synchronous:${0##*/}" -i "$logdir/default.jpg" "$(cut -d">" -f1 "$logdir/current" | tr ':' '\n')"
#shellcheck source=/tmp/yt-music/current
#shellcheck disable=SC1091
[ -f "$logdir/current" ] && . "$logdir/current"
notify-send -e -h "string:x-canonical-private-synchronous:${0##*/}" -i "$logdir/default.jpg" "Listening @ $(basename "$0")" "$SONG - $ARTIST"
next=$(nl -n'ln' -v0 "$logdir/next" | sed "s/^$i /& /" | menu "YT-music [play-next]: " "$i")
[ -z "$next" ] && return 0
i=$(printf '%s' "$next" | sed 's///g' | cut -f1 | tr -d ' ')
@@ -322,7 +329,7 @@ base_url="https://music.youtube.com"
[ -d "$logdir" ] || mkdir "$logdir"
[ -p "$presence" ] || mkfifo "$presence"
cookie="$logdir/cookies"
agent="Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0"
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
#call this script by script-name "function_name" "query"
[ -z "$1" ] && help "$@"