diff options
author | Aleksei <alex3kov@zoho.com> | 2024-11-15 20:01:06 +0300 |
---|---|---|
committer | Aleksei <alex3kov@zoho.com> | 2024-11-15 20:01:06 +0300 |
commit | a59b724f118313bdd7c03ab7acf15d5f63df94d2 (patch) | |
tree | 161a6b7bf205e8a466ac7fe45d55a77e34277ed1 /shellconfig_functions.sh | |
parent | 72d6d16224fcfd282c74c6654ff17193251e9b1e (diff) |
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 |