diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2020-02-12 07:05:41 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2020-02-12 07:05:41 +0530 |
commit | 3532d6c3ab7174b922356ae1c9534b19b29ff557 (patch) | |
tree | d80e403f4e5a05a9e1b119306ddd7a217653073d /plugins | |
parent | fb2793354b38abb8a55eeaa9d77f631493483837 (diff) | |
download | nnn-3532d6c3ab7174b922356ae1c9534b19b29ff557.tar.gz |
Play known video file types by extension
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/nuke | 102 |
1 files changed, 52 insertions, 50 deletions
diff --git a/plugins/nuke b/plugins/nuke index e1c1a22..38f3e4c 100755 --- a/plugins/nuke +++ b/plugins/nuke @@ -43,6 +43,7 @@ # 7-zip: list with 7z # pdf: zathura (GUI), pdftotext, mutool, exiftool # audio: mocplay (nnn plugin using MOC), mpv, mediainfo, exiftool +# avi|dat|mkv|mp4: smplayer, mpv (GUI), ffmpegthumbnailer, mediainfo, exiftool # torrent: rtorrent, transmission-show # odt|ods|odp|sxw: odt2txt # md: glow (https://github.com/charmbracelet/glow) @@ -96,6 +97,44 @@ handle_pdf() { fi } +handle_audio() { + if which mocp >/dev/null 2>&1; then + mocplay "${FPATH}" >/dev/null 2>&1 + exit 0 + elif which mpv >/dev/null 2>&1; then + mpv "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif which mediainfo >/dev/null 2>&1; then + mediainfo "${FPATH}" | less -R + exit 0 + elif which exiftool >/dev/null 2>&1; then + exiftool "${FPATH}"| less -R + exit 0 + fi +} + +handle_video() { + if [ $GUI -ne 0 ] && which smplayer >/dev/null 2>&1; then + smplayer "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif [ $GUI -ne 0 ] && which mpv >/dev/null 2>&1; then + mpv "${FPATH}" >/dev/null 2>&1 & + exit 0 + elif which ffmpegthumbnailer >/dev/null 2>&1; then + # Thumbnail + [ -d "${IMAGE_CACHE_PATH}" ] || mkdir "${IMAGE_CACHE_PATH}" + ffmpegthumbnailer -i "${FPATH}" -o "${IMAGE_CACHE_PATH}/${FNAME}.jpg" -s 0 + viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | less -R + exit 0 + elif which mediainfo >/dev/null 2>&1; then + mediainfo "${FPATH}" | less -R + exit 0 + elif which exiftool >/dev/null 2>&1; then + exiftool "${FPATH}"| less -R + exit 0 + fi +} + # handle this extension and exit handle_extension() { case "${ext}" in @@ -131,19 +170,12 @@ handle_extension() { ## Audio aac|flac|m4a|mid|midi|mpa|mp2|mp3|ogg|wav|wma) - if which mocp >/dev/null 2>&1; then - mocplay "${FPATH}" >/dev/null 2>&1 - exit 0 - elif which mpv >/dev/null 2>&1; then - mpv "${FPATH}" >/dev/null 2>&1 & - exit 0 - elif which mediainfo >/dev/null 2>&1; then - mediainfo "${FPATH}" | less -R - exit 0 - elif which exiftool >/dev/null 2>&1; then - exiftool "${FPATH}"| less -R - exit 0 - fi + handle_audio + exit 1;; + + ## Video + avi|dat|mkv|mp4) + handle_video exit 1;; ## BitTorrent @@ -249,49 +281,19 @@ handle_multimedia() { ## as above), but might fail for unsupported types. exit 7;; - ## Video - video/*) - if [ $GUI -ne 0 ] && which smplayer >/dev/null 2>&1; then - smplayer "${FPATH}" >/dev/null 2>&1 & - exit 0 - elif [ $GUI -ne 0 ] && which mpv >/dev/null 2>&1; then - mpv "${FPATH}" >/dev/null 2>&1 & - exit 0 - elif which ffmpegthumbnailer >/dev/null 2>&1; then - # Thumbnail - [ -d "${IMAGE_CACHE_PATH}" ] || mkdir "${IMAGE_CACHE_PATH}" - ffmpegthumbnailer -i "${FPATH}" -o "${IMAGE_CACHE_PATH}/${FNAME}.jpg" -s 0 - viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | less -R - exit 0 - elif which mediainfo >/dev/null 2>&1; then - mediainfo "${FPATH}" | less -R - exit 0 - elif which exiftool >/dev/null 2>&1; then - exiftool "${FPATH}"| less -R - exit 0 - fi + ## PDF + application/pdf) + handle_pdf exit 1;; ## Audio audio/*) - if which mocp >/dev/null 2>&1; then - mocplay "${FPATH}" >/dev/null 2>&1 - exit 0 - elif which mpv >/dev/null 2>&1; then - mpv "${FPATH}" >/dev/null 2>&1 & - exit 0 - elif which mediainfo >/dev/null 2>&1; then - mediainfo "${FPATH}" | less -R - exit 0 - elif which exiftool >/dev/null 2>&1; then - exiftool "${FPATH}"| less -R - exit 0 - fi + handle_audio exit 1;; - ## PDF - application/pdf) - handle_pdf + ## Video + video/*) + handle_video exit 1;; # pdftoppm -f 1 -l 1 \ |