diff --git a/.aliases b/.aliases index bed458e..76b923b 100644 --- a/.aliases +++ b/.aliases @@ -41,7 +41,7 @@ reload() { } update-shell() { - if [[ '${platform,,}' == *'ming'* ]]; then + if [[ ${platform,,} == *'ming'* ]]; then pacman -Syu printf "\n${BOLD}${YELLOW}Close this shell, open a new one, and then run 'pacman -Su'${NORMAL}\n" fi @@ -148,6 +148,30 @@ remove_extra_spaces() { echo "$ret" } +flash_taskbar() { + if [[ ${platform,,} == *'ming'* ]]; then + powershell.exe -NoProfile -ExecutionPolicy Bypass -Command " + \$h = (Get-Process mintty -EA SilentlyContinue | ? MainWindowHandle | select -First 1).MainWindowHandle + if (-not \$h) { exit } + + Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; + public static class F { + [StructLayout(LayoutKind.Sequential)] public struct I { public uint cb; public IntPtr h; public uint f; public uint c; public uint t; } + [DllImport(\"user32.dll\")] public static extern bool FlashWindowEx(ref I i); + }' + \$i = New-Object F+I + \$i.cb = [Runtime.InteropServices.Marshal]::SizeOf(\$i) + \$i.h = [IntPtr]\$h + \$i.f = 2 -bor 12 + \$i.c = 0 + \$i.t = 0 + [F]::FlashWindowEx([ref]\$i) | Out-Null + " + else + echo "flash_taskbar not implemented for this platform" + fi +} + ################## # Building code ################## @@ -198,7 +222,7 @@ if [[ $platform == 'Darwin' ]]; then alias trash='rmtrash' alias tt='rmtrash' -elif [[ "${platform,,}" == *'ming'* ]]; then # convert to lowercase then compare with wildcard +elif [[ ${platform,,} == *'ming'* ]]; then # convert to lowercase then compare with wildcard #alias rm='echo "use trash command instead!"' #alias rmr='echo "use trash command instead!"' alias trash='remove_windows_file' @@ -226,7 +250,7 @@ mkcd() { alias aliases='vim ~/.aliases' alias al='aliases' -if [[ "${platform,,}" == *'ming'* ]]; then +if [[ ${platform,,} == *'ming'* ]]; then _checksum() { local algo="$1" local file="$2" @@ -412,6 +436,7 @@ function my_transcribe_video() { else transcribe-video "$file" "$output" $start_time $end_time tiny base fi + flash_taskbar } function my_transcribe_video_all_models() { @@ -433,6 +458,7 @@ function my_transcribe_video_all_models() { if [[ $end_time == "" ]]; then end_time="0"; fi transcribe-video "$file" "$output" $start_time $end_time tiny base small medium + flash_taskbar } @@ -509,6 +535,7 @@ download_youtube_vid() { if [[ $make_folder == "1" ]]; then cd ..; fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } @@ -555,6 +582,7 @@ download_youtube_playlist() { cd .. printf "${BOLD}Finished downloading the playlist\n${NORMAL}" + flash_taskbar } download_youtube_playlist_list() { @@ -574,6 +602,7 @@ download_youtube_playlist_list() { eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. printf "${BOLD}Finished downloading the playlist video list\n${NORMAL}" + flash_taskbar } download_youtube_uploads_list() { @@ -602,6 +631,7 @@ download_youtube_uploads_list() { eval $cmd 1>"${output_name}.txt" # Need to eval in order to preserve the quotes wrapping the filename format string. printf "${BOLD}Finished downloading the upload list\n${NORMAL}" + flash_taskbar } function download_youtube_audio() { @@ -646,6 +676,7 @@ function download_youtube_audio() { if [[ $make_folder == "1" ]]; then cd ..; fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } # Download Twitch chat transcript @@ -699,9 +730,13 @@ download_twitch_chat() { # To extract a portion of a video, you have to first download the entire file and then use the # `trim-video` or `compress-video' with a time range. # -# To download a portion of a stream: +# To download a partial stream use one of these commands. We need to reencode to remove extra frames from the start/end with a negative timeline. # -# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 5:25:38.00 -to 5:56:50.00" URL +# This reencodes during the download, slightly faster than the next option: +# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 0:7:10.00 -to 0:8:06.00" --external-downloader-args "ffmpeg_o:-c:v libx264 -c:a aac" URL +# +# Download then re-encode: +# yt-dlp -f "b" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 5:25:38.00 -to 5:56:50.00" URL -o temp.mp4 ; trim-video-cpu temp.mp4 "FINAL_NAME" 0 # download_twitch_vid() { local format="$1" @@ -812,6 +847,7 @@ download_twitch_vid() { if [[ $make_folder == "1" ]]; then cd ..; fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } # Download Vimeo videos. @@ -898,6 +934,7 @@ download_vimeo_vid() { if [[ $make_folder == "1" ]]; then cd ..; fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } # Download Twitter videos. @@ -966,9 +1003,12 @@ download_twitter_vid() { if [[ $make_folder == "1" ]]; then cd ..; fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } # Download Instagram videos. +# If the download fails because you need to be authenticated then don't use the cookies arg because IG will flag your +# account as a bot and might ban you. Instead, use the instagram download code from private dotfiles. download_instagram_vid() { local transcribe="$1" local make_folder="$2" @@ -1037,6 +1077,7 @@ download_instagram_vid() { if [[ $make_folder == "1" ]]; then cd ..; fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } # Download MP4 video. @@ -1060,6 +1101,7 @@ download_mp4() { fi mv $temp_name "$filename.mp4" + flash_taskbar } # Download a stream to mp4. Can be from an m3u8 file, an mpd, etc. Whatever the @@ -1096,6 +1138,7 @@ download_mp4_from_stream() { fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } # Same notes from above regarding cookies/headers. @@ -1117,6 +1160,7 @@ download_aac_from_stream() { fi printf "${BOLD}Finished downloading ${YELLOW}$filename${NORMAL}\n" + flash_taskbar } @@ -1293,7 +1337,7 @@ function compress_and_normalize_volume() { error "Provide a final file name and optional args for compress-video" return fi - compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" + compress-video f.mp4 ff $opts ; normalize-volume ff.mp4 "$final_name" ; flash_taskbar } alias cvn='compress_and_normalize_volume' @@ -1302,7 +1346,7 @@ alias cvn='compress_and_normalize_volume' # Git #################################################################################################### -if [[ '${platform,,}' == *'ming'* ]]; then +if [[ ${platform,,} == *'ming'* ]]; then # Fix a weird mingw 'not a valid identifierline' error. # Got the fix from https://github.com/Alexpux/MSYS2-packages/issues/735#issuecomment-328938800 alias git="PATH=/usr/bin git" diff --git a/dotfiles/bin/analyze-volume b/dotfiles/bin/analyze-volume index 11a1dcf..635674e 100644 --- a/dotfiles/bin/analyze-volume +++ b/dotfiles/bin/analyze-volume @@ -10,6 +10,8 @@ # # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -50,3 +52,4 @@ eval $cmd printf "\n${GREEN}${BOLD}Done analyzing audio in $filename\n${NORMAL}" printf "\n${YELLOW}${BOLD}Look at the reported max_volume value. If != 0 then call the change-volume script, passing it the filename, an output name and the delta to bring the volume to 0.\ne.g. if the max_volume is -5 db, then you would pass 5.${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/change-volume b/dotfiles/bin/change-volume index 28077ae..4d30269 100644 --- a/dotfiles/bin/change-volume +++ b/dotfiles/bin/change-volume @@ -7,6 +7,8 @@ # # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -57,3 +59,4 @@ eval $cmd printf "\n${GREEN}${BOLD}Done modifying volume in $filename.$extension | output: $output | delta: $delta_db${NORMAL}\n" +flash_taskbar diff --git a/dotfiles/bin/compress-video b/dotfiles/bin/compress-video index e5ca7dc..da1c480 100644 --- a/dotfiles/bin/compress-video +++ b/dotfiles/bin/compress-video @@ -2,6 +2,8 @@ # Bigger crf values == bigger compression. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -49,3 +51,5 @@ fi compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu $4 $5 +flash_taskbar + diff --git a/dotfiles/bin/compress-video-with-crf b/dotfiles/bin/compress-video-with-crf index 61958ec..2fdd8bc 100644 --- a/dotfiles/bin/compress-video-with-crf +++ b/dotfiles/bin/compress-video-with-crf @@ -2,6 +2,8 @@ # Bigger crf values == bigger compression. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -95,3 +97,5 @@ else encode $crf done fi + +flash_taskbar diff --git a/dotfiles/bin/convert-video-to-mp4 b/dotfiles/bin/convert-video-to-mp4 index e3dc354..2307722 100644 --- a/dotfiles/bin/convert-video-to-mp4 +++ b/dotfiles/bin/convert-video-to-mp4 @@ -3,6 +3,8 @@ # This is for reencoding a non-mp4 video to mp4 using an mpeg4 encoder. # Can optionally compress the video. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -94,3 +96,5 @@ else fi printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n" + +flash_taskbar diff --git a/dotfiles/bin/join-video b/dotfiles/bin/join-video index 0b74ae4..e97a906 100644 --- a/dotfiles/bin/join-video +++ b/dotfiles/bin/join-video @@ -3,6 +3,8 @@ # Re-encodes the video to get a more accurate timeline. Same settings as trim-video-vbr. # If you want fast video joining at the expense of accuracy then use join-video-fast. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -64,3 +66,4 @@ time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/join-video-fast b/dotfiles/bin/join-video-fast index bbfc24c..373e98a 100644 --- a/dotfiles/bin/join-video-fast +++ b/dotfiles/bin/join-video-fast @@ -5,6 +5,8 @@ # playback time might oscillate a bit. Use join-video for accurate joining at # the cost of a much slower processing time. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -44,3 +46,4 @@ ffmpeg -y -stats -loglevel level+error -f concat -safe 0 -i "$filename" -c copy printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/normalize-volume b/dotfiles/bin/normalize-volume index c61b6ce..0a89ce0 100644 --- a/dotfiles/bin/normalize-volume +++ b/dotfiles/bin/normalize-volume @@ -10,6 +10,8 @@ # # Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885 +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -78,3 +80,4 @@ eval "$cmd" printf "\n${GREEN}${BOLD}Done normalizing volume in $filename.$extension | output: $output${NORMAL}\n" rm $temp_file +flash_taskbar diff --git a/dotfiles/bin/trim-audio b/dotfiles/bin/trim-audio index 3723a75..9a87d76 100644 --- a/dotfiles/bin/trim-audio +++ b/dotfiles/bin/trim-audio @@ -2,6 +2,8 @@ # Re-encodes the audio to get a more accurate seek time. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -58,3 +60,4 @@ ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/trim-video-cpu b/dotfiles/bin/trim-video-cpu index 7bad89d..9e66367 100644 --- a/dotfiles/bin/trim-video-cpu +++ b/dotfiles/bin/trim-video-cpu @@ -2,6 +2,8 @@ # Re-encodes the video to get a more accurate seek time. If you want fast trimming at the expense of accuracy then use trim-video-fast. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -62,3 +64,4 @@ ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -async 1 -i " printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/trim-video-cpu-fast b/dotfiles/bin/trim-video-cpu-fast index 2d0f416..df899f0 100644 --- a/dotfiles/bin/trim-video-cpu-fast +++ b/dotfiles/bin/trim-video-cpu-fast @@ -5,6 +5,8 @@ # time might oscillate a bit. Use trim-video for accurate trimming at the cost # of a much slower processing time. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -64,3 +66,4 @@ ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/trim-video-target-rate b/dotfiles/bin/trim-video-target-rate index 4f44016..d2d1597 100644 --- a/dotfiles/bin/trim-video-target-rate +++ b/dotfiles/bin/trim-video-target-rate @@ -3,6 +3,8 @@ # Re-encodes the video using a constrained bitrate/output size. If you want to # control the visual quality with a variable bitrate then use trim-video-vbr +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -90,3 +92,4 @@ ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format cuda printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" +flash_taskbar diff --git a/dotfiles/bin/trim-video-vbr b/dotfiles/bin/trim-video-vbr index a7cfed1..3d550af 100644 --- a/dotfiles/bin/trim-video-vbr +++ b/dotfiles/bin/trim-video-vbr @@ -7,6 +7,8 @@ # # The higher the CRF value, the higher the compression. +source "$HOME/dotfiles/script_helpers/windows.sh" + if which tput >/dev/null 2>&1; then ncolors=$(tput colors) fi @@ -124,3 +126,4 @@ time ffmpeg -y -stats -loglevel level+error -hwaccel cuda -hwaccel_output_format printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n" +flash_taskbar