From 2344bd7dfb428ce1f0cd8b083ae8e3e59dc854f4 Mon Sep 17 00:00:00 2001 From: coolnsx Date: Fri, 20 Feb 2026 19:56:52 +0530 Subject: [PATCH] s/ / /g --- .functions | 2 +- ani-new | 2 +- download | 29 ++++++++++++++++++++++++++--- yt-music | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.functions b/.functions index 2e3f732..7fcb7e0 100644 --- a/.functions +++ b/.functions @@ -49,5 +49,5 @@ player_droid() { } player_linux() { - setsid -f mpv "$1" --force-media-title="$2" $@ + setsid -f mpv "$1" --force-media-title="$2" $3 } diff --git a/ani-new b/ani-new index 74f8bd1..3f7100e 100755 --- a/ani-new +++ b/ani-new @@ -76,7 +76,7 @@ printf "%s\n" "$url" | while read -r id title; do subs_flag= [ -n "$subtitle" ] && subs_flag="--sub-file=$subtitle" # shellcheck disable=SC2086 - player_$os "$provider_video" "$title" --referrer="https://$domain" $subs_flag + player_$os "$provider_video" "$title" "--referrer=https://$domain $subs_flag" break ;; cast) diff --git a/download b/download index 37f3470..c581b67 100755 --- a/download +++ b/download @@ -13,7 +13,26 @@ notify_droid() { notify_linux() { info "$1" - notify-send -e "$1" -h "string:x-canonical-private-synchronous:${0##*/}" + notify-send -e -i "$3" -h "string:x-canonical-private-synchronous:${0##*/}" -t "${2:-5000}" "$1" "$4" +} + +compress() { + duration=$(ffprobe -hide_banner -i "$1" 2>&1 | sed -nE 's|.*Duration: ([^,]*).*|\1|p') + target_size_mb="${2:-10}" + i=20 + + while :; do + ffmpeg -loglevel error -i "$1" -c:v libx264 -c:a copy -crf "$i" "$process_file" -y -progress - | while read -r line; do + complete=$(printf "%s\n" "$line" | sed -nE 's|out_time=(.*)|\1|p') + size=$(du -m "$process_file" | cut -f1) + [ -n "$complete" ] && notify_$os "Compressing File under $target_size_mb MB Using Quality Preset : $i.." "700" "ffmpeg" "$complete / $duration ($size MB)" + [ "$size" -gt "$target_size_mb" ] && killall -s KILL ffmpeg && break + done + [ "$(du -m "$process_file" | cut -f1)" -lt "$target_size_mb" ] && break + : $((i += 1)) + done + notify_$os "File Successfully compressed with Quality Preset : $i" "1000" "ffmpeg" + [ -f "$process_file" ] && filepath=$process_file } send_matrix_msg() { @@ -74,9 +93,10 @@ info "Downloading Video.." 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" +yt-dlp -S "filesize:10M" -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) +process_file="${TMPDIR:-/tmp}/processed.mp4" #shellcheck disable=SC1091 . "$HOME"/.config/.env @@ -84,6 +104,9 @@ filepath=$(sed -nE "s|.*($download_dir.*\.mp4).*|\1|p" "$yt_dlp_logs" | head -1) # load matrix creds matrix_creds +# compresses the video file under 10 MB +compress "$filepath" + send_matrix_msg "$filepath" # unload matrix creds @@ -91,5 +114,5 @@ matrix_creds "unload" notify_$os "Video Sent to Matrix" -rm -f "$filepath" +rm -f "$filepath" "$process_file" exit 0 diff --git a/yt-music b/yt-music index dd8e9d0..59bd365 100755 --- a/yt-music +++ b/yt-music @@ -65,7 +65,7 @@ get_cookies() { # the user has firefox installed if [ ! -f "$HOME/.config/google-chrome/Default/Cookies" ]; then cp "$(find "$HOME/.mozilla" -type f -iname 'cookies.sqlite' | head -1)" "$logdir/cookies.sqlite" - sqlite3 "$logdir/cookies.sqlite" "SELECT name, value FROM moz_cookies WHERE host='.youtube.com' and name NOT like 'ST-%' and name NOT like 'VISITOR%' and name NOT like 'PREF%';" | tr '|\n' '=;' >"$cookie" + sqlite3 "$logdir/cookies.sqlite" "SELECT name, value FROM moz_cookies WHERE host='.youtube.com' and name NOT like 'ST-%' and name NOT like 'VISITOR%' and name NOT like 'PREF%' and name NOT like '%Secure-%';" | tr '|\n' '=;' >"$cookie" rm "$logdir/cookies.sqlite" return 0 fi