mirror of
https://github.com/CoolnsX/repos_scripts.git
synced 2025-12-20 07:15:20 +05:30
Compare commits
9 Commits
39fdebbc99
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf4b2095eb | ||
|
|
5f5d065c18 | ||
|
|
870fb04c8e | ||
|
|
0338c5c80c | ||
|
|
b4e63b41ab | ||
|
|
e431d829ac | ||
|
|
5272006282 | ||
|
|
672adfdd12 | ||
|
|
f71f117880 |
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
#shellcheck disable=SC2086
|
||||
#shellcheck disable=SC2086,SC2068
|
||||
|
||||
menu_droid() {
|
||||
fzf --prompt="$1" $2
|
||||
@@ -20,11 +20,11 @@ search_linux() {
|
||||
}
|
||||
|
||||
torrent_linux() {
|
||||
setsid -f "$TERMINAL" -e "$(dirname "$0")/torrent" "$1"
|
||||
setsid -f "$TERMINAL" -e "${0%/*}/torrent" $@
|
||||
}
|
||||
|
||||
torrent_droid() {
|
||||
"$(dirname "$0")/torrent" "$1"
|
||||
"${0%/*}/torrent" $@
|
||||
}
|
||||
|
||||
info_droid() {
|
||||
|
||||
5
ani-new
5
ani-new
@@ -73,7 +73,10 @@ printf "%s\n" "$url" | while read -r id title; do
|
||||
case $choice in
|
||||
stream)
|
||||
info_$os "opening $title" "mpv"
|
||||
player_$os "$provider_video" "$title" --referrer="https://$domain" --sub-file="$subtitle"
|
||||
subs_flag=
|
||||
[ -n "$subtitle" ] && subs_flag="--sub-file=$subtitle"
|
||||
# shellcheck disable=SC2086
|
||||
player_$os "$provider_video" "$title" --referrer="https://$domain" $subs_flag
|
||||
break
|
||||
;;
|
||||
cast)
|
||||
|
||||
71
download
71
download
@@ -1,25 +1,59 @@
|
||||
#!/bin/sh
|
||||
# script for downloading videos/audios from sites...
|
||||
#shellcheck disable=SC2317
|
||||
#shellcheck disable=SC2317,SC2329
|
||||
|
||||
info() {
|
||||
printf "\033[1;36m[ %s ] [ %s ] %s\033[0m\n" "$2" "$3" "$1"
|
||||
}
|
||||
|
||||
error() {
|
||||
printf "\033[1;31m[ %s ] [ %s ] %s\033[0m\n" "$2" "$3" "$1"
|
||||
printf "\033[1;36m%s\033[0m\n" "$2" "$3" "$1"
|
||||
}
|
||||
|
||||
notify_droid() {
|
||||
info "$1"
|
||||
termux-notification -c "$1"
|
||||
}
|
||||
|
||||
notify_linux() {
|
||||
info "$1"
|
||||
notify-send -e "$1" -h "string:x-canonical-private-synchronous:${0##*/}"
|
||||
}
|
||||
|
||||
send_matrix_msg() {
|
||||
# file existance
|
||||
[ -f "$1" ] || return 1
|
||||
|
||||
# upload file and get URI
|
||||
file_uri=$(curl "$MX_URL/_matrix/media/v3/upload?filename=$filename" -sX POST -H 'Content-Type: application/octet-stream' -H "Authorization: Bearer $MX_TOKEN" -T "$1" | sed -nE 's|.*"content_uri":"([^"]*)".*|\1|p')
|
||||
|
||||
#extract specific data from metadata
|
||||
filename="${1##*/}"
|
||||
metadata=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,height -show_format "$1")
|
||||
width=$(printf '%s' "$metadata" | sed -nE 's|^width=([^$]*)|\1|p')
|
||||
height=$(printf '%s' "$metadata" | sed -nE 's|^height=([^$]*)|\1|p')
|
||||
duration=$(printf '%s' "$metadata" | sed -nE 's|^duration=([^$]*)|\1|p' | tr -d '.' | sed 's/...$//')
|
||||
durationMSec=$(printf '%d' "$duration")
|
||||
size=$(printf '%s' "$metadata" | sed -nE 's|^size=([^$]*)|\1|p')
|
||||
|
||||
# generate unique key for message
|
||||
uuid=$(uuidgen)
|
||||
json='{
|
||||
"msgtype": "m.video",
|
||||
"body": "'"$filename"'",
|
||||
"info": {
|
||||
"size": "'"$size"'",
|
||||
"mimetype": "video/mp4",
|
||||
"duration": "'"$durationMSec"'",
|
||||
"w": "'"$width"'",
|
||||
"h": "'"$height"'"
|
||||
},
|
||||
"url": "'"$file_uri"'"
|
||||
}'
|
||||
|
||||
# send a message with media URI
|
||||
curl -sX PUT "$MX_URL/_matrix/client/v3/rooms/${2:-$MX_ROOM}/send/m.room.message/$uuid" -H 'Content-Type: application/json' -H 'Accept: application/json' -H "Authorization: Bearer $MX_TOKEN" -d "$json"
|
||||
}
|
||||
|
||||
#main
|
||||
link="$1"
|
||||
yt_dlp_logs="${TMPDIR:-/tmp}/${0##*/}-logs"
|
||||
|
||||
case $(uname -o) in
|
||||
*ndroid*)
|
||||
@@ -34,9 +68,28 @@ case $(uname -o) in
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "\033[1;34m Video link :\033[0m %s\n" "$link"
|
||||
printf "\033[1;34m Video link :\033[0m %s" "$link"
|
||||
|
||||
yt-dlp --no-skip-unavailable-fragments --fragment-retries infinite -N 16 -t mp4 "$link" -o "$download_dir/%(title)s.%(ext)s"
|
||||
info "Downloading Video.."
|
||||
|
||||
notify_$os "Video Downloaded"
|
||||
truncate -s0 "$yt_dlp_logs" # truncate file if exists, creates if doesn't exists
|
||||
|
||||
yt-dlp --no-skip-unavailable-fragments --fragment-retries infinite -N 16 -t mp4 "$link" -o "$download_dir/%(title)s.%(ext)s" | tee "$yt_dlp_logs"
|
||||
|
||||
filepath=$(sed -nE "s|.*($download_dir.*\.mp4).*|\1|p" "$yt_dlp_logs" | head -1)
|
||||
|
||||
#shellcheck disable=SC1091
|
||||
. "$HOME"/.config/.env
|
||||
|
||||
# load matrix creds
|
||||
matrix_creds
|
||||
|
||||
send_matrix_msg "$filepath"
|
||||
|
||||
# unload matrix creds
|
||||
matrix_creds "unload"
|
||||
|
||||
notify_$os "Video Sent to Matrix"
|
||||
|
||||
rm -f "$filepath"
|
||||
exit 0
|
||||
|
||||
51
esphome
Executable file
51
esphome
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
#shellcheck disable=SC2162
|
||||
|
||||
##########
|
||||
# Config #
|
||||
##########
|
||||
url="<ip_of_ur_esphome_server>:6052"
|
||||
fifo_file="${TMPDIR:-/tmp}/${0##*/}-fifo"
|
||||
|
||||
info() {
|
||||
#shellcheck disable=SC2059
|
||||
printf "\033[2K\r\033[1;${2:-36}m${1}\033[0m"
|
||||
}
|
||||
|
||||
err() {
|
||||
info "$1\n" "31"
|
||||
}
|
||||
|
||||
menu() {
|
||||
fzf --prompt="[Esphome] $1" --layout=reverse --border -d'\t' --with-nth=1
|
||||
}
|
||||
|
||||
run_command() {
|
||||
# this is done to make sure the file doesn't have anything stale left
|
||||
rm -f "$fifo_file" && mkfifo "$fifo_file"
|
||||
printf "%s\n" "$2" >"$fifo_file" &
|
||||
tail -f "$fifo_file" | websocat "ws://$url/$1" | while read line; do
|
||||
printf "%b\n" "$line" | sed -nE 's|.*"data": "(.*)n"}|\1|p' &
|
||||
# exit this loop if we receive exit from response
|
||||
printf "%b\n" "$line" | grep -q '"exit"' && pkill -P $$ tail &
|
||||
done
|
||||
rm -f "$fifo_file"
|
||||
}
|
||||
|
||||
what_to_do=$(printf "logs\nupdate-all\nupdate" | menu "What to Do? >")
|
||||
[ -z "$what_to_do" ] && err "Please Select Choice!!" && exit 1
|
||||
|
||||
if [ "$what_to_do" = "update-all" ]; then
|
||||
data='{"type":"spawn"}'
|
||||
else
|
||||
device=$(curl -s "http://$url/devices" | tr '{}' '\n' | sed -nE 's|.*"friendly_name": "([^"]*)",.*"configuration": "([^"]*)".*|\1\t\2|p' | menu "Select Device >")
|
||||
[ -z "$device" ] && err "Please Select a Device!!" && exit 1
|
||||
dev_name=$(printf "%s" "$device" | cut -f1)
|
||||
dev_config=$(printf "%s" "$device" | cut -f2)
|
||||
info "Running $what_to_do for $dev_name...\n"
|
||||
[ "$what_to_do" = 'update' ] && what_to_do="run"
|
||||
data='{"type":"spawn","configuration":"'"$dev_config"'","port":"OTA"}'
|
||||
fi
|
||||
|
||||
run_command "$what_to_do" "$data"
|
||||
40
jellyfin
40
jellyfin
@@ -95,25 +95,52 @@ mpv_jellyfin() {
|
||||
|
||||
success "Playing $2 on mpv"
|
||||
url="$JF_URL/Items/$1/Download?api_key=$JF_TOKEN"
|
||||
sub="$JF_URL/Videos/$(printf '%s' "$1" | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')/$1/Subtitles/0/0/Stream.ass?api_key=$JF_TOKEN"
|
||||
sub="$JF_URL/Videos/$1/$1/Subtitles/0/0/Stream.ass?api_key=$JF_TOKEN"
|
||||
! curl -s "$sub" | grep -q "Error processing request" && sub_arg="--sub-file=$sub"
|
||||
if uname -o | grep -q 'ndroid'; then
|
||||
text="Title: $2\nURL: $url"
|
||||
[ -n "$sub_arg" ] && text="$text\nSub URL: $sub"
|
||||
#shellcheck disable=SC2059
|
||||
printf "\n$text"
|
||||
#shellcheck disable=SC2059
|
||||
printf "$text" | termux-clipboard-set
|
||||
return 0
|
||||
fi
|
||||
#shellcheck disable=SC2086
|
||||
nohup mpv --input-ipc-server="$socket" --start="$((playbackPositionTicks / 10000000))" --force-media-title="$2" "$url" $sub_arg >/dev/null 2>&1 &
|
||||
track_progress "$(printf '%s' "$1" | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/')"
|
||||
skipPositions=$(curl -s "$JF_URL/Episode/$1/IntroSkipperSegments" -H 'Authorization: MediaBrowser Token="'"$JF_TOKEN"'"' -H "Accept: application/json" | sed 's|}|\n|g' | sed -nE 's|.*"Introduction".*"IntroStart":([^\.,]*).*,"IntroEnd":([^\.,]*).*|op_start=\1\nop_end=\2|p;s|.*"Credits".*"IntroStart":([^\.,]*).*"IntroEnd":([^\.,]*).*|ed_start=\1\ned_end=\2|p')
|
||||
track_progress "$1"
|
||||
}
|
||||
|
||||
track_progress() {
|
||||
ITEM_ID=$1
|
||||
\cat <<EOF >"$progress_track_file"
|
||||
#!/bin/sh
|
||||
|
||||
skipPos(){
|
||||
[ -z "\$3" ] && printf 1 && return 0
|
||||
[ -z "\$4" ] && printf 1 && return 0
|
||||
if [ "\$2" -ge "\$3" ] && [ "\$2" -lt "\$4" ]; then
|
||||
echo '{"command" :["seek" ,"'"\$4"'","absolute"]}' | socat - "$socket" >/dev/null
|
||||
echo '{"command": ["show-text", "'"\$5"'", 3000]}' | socat - "$socket" >/dev/null
|
||||
printf 1
|
||||
return 0
|
||||
fi
|
||||
printf 0
|
||||
}
|
||||
|
||||
positionTicks=$playbackPositionTicks
|
||||
$skipPositions
|
||||
introSkipped=0
|
||||
outroSkipped=0
|
||||
while sleep 5;do
|
||||
position=\$(echo '{"command" :["get_property","playback-time"]}' | socat - "$socket" 2>/dev/null | sed -nE 's_.*data":([^,]*).*_\1_p' | tr -d '.' | sed 's|$|0|g')
|
||||
[ -z "\$position" ] && break
|
||||
positionTicks=\$position
|
||||
positionSec=\${position::-7}
|
||||
[ "\$introSkipped" -eq 0 ] && introSkipped=\$(skipPos "\$introSkipped" "\$positionSec" "\$op_start" "\$op_end" "Intro Skipped")
|
||||
[ "\$outroSkipped" -eq 0 ] && outroSkipped=\$(skipPos "\$outroSkipped" "\$positionSec" "\$ed_start" "\$ed_end" "Outro Skipped")
|
||||
done
|
||||
[ -n "\$positionTicks" ] && curl -s "$JF_URL/Users/$JF_USER_ID/PlayingItems/$ITEM_ID?positionTicks=\$positionTicks" -X DELETE -H 'Authorization: MediaBrowser Token="'"$JF_TOKEN"'"' -H 'Content-Type: application/json'
|
||||
[ -n "\$positionTicks" ] && curl -s "$JF_URL/Users/$JF_USER_ID/PlayingItems/${1}?positionTicks=\$positionTicks" -X DELETE -H 'Authorization: MediaBrowser Token="$JF_TOKEN"' -H 'Content-Type: application/json'
|
||||
rm "$socket"
|
||||
rm "\$0"
|
||||
EOF
|
||||
@@ -147,7 +174,10 @@ collection() {
|
||||
collection_id=$(printf '%s' "$collection" | cut -f1)
|
||||
collection_title=$(printf '%s' "$collection" | cut -f3 | sed 's|.$||g')
|
||||
|
||||
data=$(get_data "Items?IncludeItemTypes=$collection_title&Recursive=false&ParentId=$collection_id" "Select $collection_title >")
|
||||
recursive="false"
|
||||
[ "$collection_title" = "Movie" ] && recursive="true"
|
||||
|
||||
data=$(get_data "Items?IncludeItemTypes=$collection_title&Recursive=$recursive&ParentId=$collection_id" "Select $collection_title >")
|
||||
[ -z "$data" ] && exit 1
|
||||
id=$(printf "%s" "$data" | cut -f1)
|
||||
title=$(printf "%s" "$data" | cut -f3)
|
||||
|
||||
2
rss
2
rss
@@ -15,4 +15,4 @@ name=$(printf "%s" "$data" | sed -nE 's_^.*Please\] (.*)</title>.*size>(.*)</sub
|
||||
[ -z "$name" ] && exit 0
|
||||
id=$(printf "%s" "$name" | sed -nE 's/.*\[(.*)\].*/\1/p')
|
||||
magnet=$(printf "%s" "$data" | sed -nE "s_.*<link>(.*$id.*)</link>.*_\1_p" | sed 's/amp;//g')
|
||||
torrent_$os "$magnet"
|
||||
torrent_$os "$magnet" "f"
|
||||
|
||||
8
screen
8
screen
@@ -31,11 +31,7 @@ compress() {
|
||||
|
||||
record() {
|
||||
rm -f "$tmp_file" "$process_file"
|
||||
#shellcheck disable=SC2034
|
||||
mic="alsa_input.pci-0000_04_00.6.analog-stereo" #It is called in eval on line 9
|
||||
#shellcheck disable=SC2034
|
||||
speaker="alsa_output.pci-0000_04_00.6.analog-stereo.monitor" #It is called in eval on line 9
|
||||
source=$(printf "screen only\n%s" "$(pactl -f json list sources | sed 's|"index":|\n|g' | sed -nE 's|.*,"name":"([^"]*)","description":"([^"]*)".*|\2\t\1|p')" | menu "Audio Source:" "3")
|
||||
source=$(printf "screen only\n%s" "$(pactl -f json list sources | sed 's|"index":|\n|g' | sed -nE 's|.*,"name":"([^"]*)","description":"([^"]*)".*|\2\t\1|p')" | menu "Audio Source:" "3" | cut -f2)
|
||||
|
||||
[ -z "$source" ] && info "" "2000" "No option Selected" && return 0
|
||||
|
||||
@@ -43,7 +39,7 @@ record() {
|
||||
|
||||
[ -z "$monitor" ] && info "" "2000" "No option Selected" && return 0
|
||||
|
||||
[ "$source" != "screen only" ] && pactl set-default-source "$(eval "printf \$$source")" && arg=-a
|
||||
[ "$source" != "screen only" ] && pactl set-default-source "$source" && arg=-a
|
||||
#shellcheck disable=SC2086
|
||||
info "simplescreenrecorder" "1000" "Select Region" "Tap/Click to select full" && setsid -f wf-recorder -x yuv420p -f /tmp/screenrecord.mp4 --output "$monitor" $arg -g "$(slurp)" >/dev/null 2>&1
|
||||
info "simplescreenrecorder" "700" "Recording Started" "Capturing $monitor($source)"
|
||||
|
||||
9
torrent
9
torrent
@@ -15,7 +15,7 @@ down() {
|
||||
error_$os "Torrent: Error!!"
|
||||
}
|
||||
|
||||
magnet="$*"
|
||||
magnet="$1"
|
||||
if [ "$(uname -o)" = "Android" ]; then
|
||||
os="droid"
|
||||
script_dir="$HOME/.shortcuts"
|
||||
@@ -28,7 +28,10 @@ else
|
||||
[ -z "$magnet" ] && magnet="$(wl-paste)"
|
||||
terminal="${TERMINAL:-foot}"
|
||||
prefix="setsid -f $terminal -e"
|
||||
pgrep -af "$0" | grep -q "$terminal" || { $prefix "$0" "$magnet"; exit 0; }
|
||||
pgrep -af "$0" | grep -q "$terminal" || {
|
||||
$prefix "$0" "$magnet"
|
||||
exit 0
|
||||
}
|
||||
fi
|
||||
|
||||
#import generic functions
|
||||
@@ -49,7 +52,7 @@ fi
|
||||
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_reset}\n\tenter choice:"
|
||||
read -r ch
|
||||
[ -z "$2" ] && read -r ch || ch=$2
|
||||
case $ch in
|
||||
f)
|
||||
down "$magnet"
|
||||
|
||||
1
yt-music
1
yt-music
@@ -291,7 +291,6 @@ yt_agent="com.google.android.youtube/$yt_ver (Linux; U; Android 1$random_no) gzi
|
||||
yt_music_ver="8.23.51"
|
||||
yt_music_agent="com.google.android.apps.youtube.music/$yt_music_ver (Linux; U; Android 1$random_no) gzip"
|
||||
|
||||
|
||||
#call this script by script-name "function_name" "query"
|
||||
[ -z "$1" ] && help "$@"
|
||||
$1 "$2" "$3"
|
||||
|
||||
Reference in New Issue
Block a user