diff options
Diffstat (limited to 'shellconfig_functions.sh')
-rw-r--r-- | shellconfig_functions.sh | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/shellconfig_functions.sh b/shellconfig_functions.sh index 2b45780..f722093 100644 --- a/shellconfig_functions.sh +++ b/shellconfig_functions.sh @@ -43,18 +43,32 @@ wgettor() { export ALL_PROXY="socks5h://127.0.0.1:9050" wget "$@" } +seconds_to_htime() { + dur=$1 + hours=$(expr $1 / 3600) + minutes=$(expr \( $1 - \( $hours \* 3600 \) \) / 60) + seconds=$(expr $1 % 60) + printf "%02u:%02u:%02u" $hours $minutes $seconds +} mediaduration() { durtotal=0 for f in "$@"; do [ -f "$f" ] && { + if [ "$(file -b --mime-type $f)" = "inode/x-empty" ] ; then + continue + fi durcur=$(ffprobe -print_format json -show_entries format=duration \ -v quiet "$f" | jq -r '.format.duration|tonumber|round') [ -z "$durcur" ] && durcur=0 durtotal=$(expr $durtotal + $durcur) - printf "%s: %s\n" "${f##*/}" "$(date -u -d @${durcur} +'%T')" + printf "%s: " "${f##*/}" + seconds_to_htime $durcur + printf "\n" } done - printf "Total: %s\n" "$(date -u -d @${durtotal} +'%T')" + printf "Total: " + seconds_to_htime $durtotal # "$(date -u -d @${durtotal} +'%T')" + printf "\n" } lftpsrv() { lftp -u alarm,$(pass alarm@srv.homelan|head -n1) srv.homelan @@ -222,6 +236,14 @@ ytdlpchoose_format() { yt-dlp -f $fmt "$u" done } +renamemedia_file_to_title() { + fname=$1 + ext=${fname##*.} + title=$(mediainfo --Output=JSON "$fname"| + jq -Mr '.media.track[]|select(.["@type"]=="General").Title') + mv -v "$fname" "${title}.$ext" + detox "${title}.$ext" +} getquicknotesandroidphone() { addr=$(awk '/^# hostname androi.*/ {name=$3 ; next} name!="" {print substr($0,9) ; exit}' /etc/systemd/network/00-vswitch.network) sftp -q -P 1234 $addr:quicknote.md /tmp @@ -244,12 +266,21 @@ sshsftplan() { name=${name_ip% *} ip=${name_ip#* } case $name in - *android*) sftp -P 1234 $ip ; return ;; + *android*) lftp -p 1234 sftp://$ip ; return ;; *) ;; esac - tool=$(printf "ssh\nsftp"|fzy) - [ -z $tool ] && return - $tool me@$ip + tool=$(printf "ssh\nlftp"|fzy) + case $tool in + lftp) + $tool sftp://$ip + ;; + ssh) + $tool $ip + ;; + '') + return + ;; + esac } mpvchapters() { for fname in "$@"; do |