commit 5ce7458ead634d19db4925df7c1567cb7e71044a parent 9179802986f9c91bff628af2a56ad158ee455b0c Author: hhvn <dev@hhvn.uk> Date: Sun, 31 Oct 2021 23:14:05 +0000 .s/b/rmpv: more "human-random" random Diffstat:
M | .scripts/bin/rmpv | | | 7 | ++++--- |
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/.scripts/bin/rmpv b/.scripts/bin/rmpv @@ -14,13 +14,14 @@ [ -z "$1" ] || [ ! -z "$3" ] && echo "usage: rmpv <directory|filelist> [size]" [ -f "$1" ] && files=$(grep $grepargs -E "mp3 |opus |mkv |mp4 |flac |m4a |webm |wav " < "$1" | \ - awk -F" " '{for (i=0; i < $2; i++) print $1}' | shuf | head -n ${2:-50} | sed "s~^.~$(dirname $1)~") -[ -d "$1" ] && files=$(find "$1" -type f | grep $grepargs -E 'mp3$|opus$|mkv$|mp4$|flac$|m4a$|webm$|wav$' | shuf | head -n ${2:-50}) -echo "$files" | grep $grepargs '[[:alnum:]]' >/dev/null || { + awk -F"\t" '{for (i=0; i < $2; i++) print $1}' | shuf | head -n ${2:-2000} | sed "s~^.~$(dirname $1)~" | awk '!x[$0]++') +[ -d "$1" ] && files=$(find "$1" -type f | grep $grepargs -E 'mp3$|opus$|mkv$|mp4$|flac$|m4a$|webm$|wav$' | shuf | shuf -n ${2:-2000}) + echo "$files" | grep $grepargs '[[:alnum:]]' >/dev/null || { echo "No files found..." exit 1 } +echo "$files" echo "$1" | grep $grepargs "music" >/dev/null && { echo "$files" | tr '\n' '\0' | xargs -0 mpv --input-ipc-server=/tmp/mpv-socket --no-video -- } || {