This commit is contained in:
coolnsx
2026-02-20 19:56:52 +05:30
parent cf4b2095eb
commit 2344bd7dfb
4 changed files with 29 additions and 6 deletions

View File

@@ -49,5 +49,5 @@ player_droid() {
} }
player_linux() { player_linux() {
setsid -f mpv "$1" --force-media-title="$2" $@ setsid -f mpv "$1" --force-media-title="$2" $3
} }

View File

@@ -76,7 +76,7 @@ printf "%s\n" "$url" | while read -r id title; do
subs_flag= subs_flag=
[ -n "$subtitle" ] && subs_flag="--sub-file=$subtitle" [ -n "$subtitle" ] && subs_flag="--sub-file=$subtitle"
# shellcheck disable=SC2086 # shellcheck disable=SC2086
player_$os "$provider_video" "$title" --referrer="https://$domain" $subs_flag player_$os "$provider_video" "$title" "--referrer=https://$domain $subs_flag"
break break
;; ;;
cast) cast)

View File

@@ -13,7 +13,26 @@ notify_droid() {
notify_linux() { notify_linux() {
info "$1" 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() { send_matrix_msg() {
@@ -74,9 +93,10 @@ info "Downloading Video.."
truncate -s0 "$yt_dlp_logs" # truncate file if exists, creates if doesn't exists 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) filepath=$(sed -nE "s|.*($download_dir.*\.mp4).*|\1|p" "$yt_dlp_logs" | head -1)
process_file="${TMPDIR:-/tmp}/processed.mp4"
#shellcheck disable=SC1091 #shellcheck disable=SC1091
. "$HOME"/.config/.env . "$HOME"/.config/.env
@@ -84,6 +104,9 @@ filepath=$(sed -nE "s|.*($download_dir.*\.mp4).*|\1|p" "$yt_dlp_logs" | head -1)
# load matrix creds # load matrix creds
matrix_creds matrix_creds
# compresses the video file under 10 MB
compress "$filepath"
send_matrix_msg "$filepath" send_matrix_msg "$filepath"
# unload matrix creds # unload matrix creds
@@ -91,5 +114,5 @@ matrix_creds "unload"
notify_$os "Video Sent to Matrix" notify_$os "Video Sent to Matrix"
rm -f "$filepath" rm -f "$filepath" "$process_file"
exit 0 exit 0

View File

@@ -65,7 +65,7 @@ get_cookies() {
# the user has firefox installed # the user has firefox installed
if [ ! -f "$HOME/.config/google-chrome/Default/Cookies" ]; then if [ ! -f "$HOME/.config/google-chrome/Default/Cookies" ]; then
cp "$(find "$HOME/.mozilla" -type f -iname 'cookies.sqlite' | head -1)" "$logdir/cookies.sqlite" 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" rm "$logdir/cookies.sqlite"
return 0 return 0
fi fi