From 4700beafdf23566373a577ac3b29bf98829bcf8a Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 6 Jun 2018 21:01:16 +0200 Subject: [PATCH] vid: play or find videos matching strings in descending order of size. --- Makefile | 4 +-- rand/rand | 2 +- vid/vid | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 3 deletions(-) create mode 100755 vid/vid diff --git a/Makefile b/Makefile index 4e03d61..acd8a63 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CMD = blink bsearch duplicate-packets em encdir field forever G \ gitnext gitundo goodpasswd histogram mtrr mirrorpdf neno off \ pdfman puniq ramusage rand rclean rina rn rrm shython \ sound-reload stdout swapout T timestamp tracefile transpose \ - upsidedown w4it-for-port-open wifi-reload wssh ytv yyyymmdd + upsidedown vid w4it-for-port-open wifi-reload wssh ytv yyyymmdd all: blink/blink.1 bsearch/bsearch.1 encdir/encdir.1 G/G.1 \ gitnext/gitnext.1 gitundo/gitundo.1 goodpasswd/goodpasswd.1 \ @@ -11,7 +11,7 @@ all: blink/blink.1 bsearch/bsearch.1 encdir/encdir.1 G/G.1 \ rina/rina.1 rn/rn.1 rrm/rrm.1 shython/shython.1 \ sound-reload/sound-reload.1 stdout/stdout.1 \ timestamp/timestamp.1 tracefile/tracefile.1 \ - transpose/transpose.1 T/T.1 upsidedown/upsidedown.1 \ + transpose/transpose.1 T/T.1 upsidedown/upsidedown.1 vid/vid.1 \ wifi-reload/wifi-reload.1 wssh/wssh.1 ytv/ytv.1 \ yyyymmdd/yyyymmdd.1 diff --git a/rand/rand b/rand/rand index 3dcf080..8022643 100755 --- a/rand/rand +++ b/rand/rand @@ -5,7 +5,7 @@ =head1 NAME -rand - Generate (pseudo-)random data +rand - generate (pseudo-)random data =head1 SYNOPSIS diff --git a/vid/vid b/vid/vid new file mode 100755 index 0000000..f8551c1 --- /dev/null +++ b/vid/vid @@ -0,0 +1,91 @@ +#!/bin/bash + +: <<=cut +=pod + +=head1 NAME + +vid - Play videos matching strings in descending order of size + + +=head1 SYNOPSIS + +B [[grep options][string]]... + + +=head1 DESCRIPTION + +B recursively searches for videos and sort them by size. It then +filters out the names matching all the B expressions. + +There can be multiple B expressions. + + +=head1 EXAMPLE + +Play videos matching B but not B: + + vid Documentary -v BBC + + +=head1 AUTHOR + +Copyright (C) 2018 Ole Tange, +http://ole.tange.dk and Free Software Foundation, Inc. + + +=head1 LICENSE + +Copyright (C) 2012 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +at your option any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + + +=head1 DEPENDENCIES + +B uses B, and B. + + +=head1 SEE ALSO + +B + + +=cut + +stdin() { + if tty -s ; then + # STDIN is terminal + find . -iregex '.*\(rm\|mov\|mpg\|mpeg\|avi\|wmv\|flv\|mp4\|3gp\)$' -type f | + # Sort by size - descending + perl -e 'print map {"$_\n"} sort { chomp $a;chomp $b; -s $b <=> -s $a } <>' + else + # STDIN redir'ed - read it + cat + fi +} + +stdout() { + if [ -t 1 ] ; then + # STDOUT = terminal + # start VLC + parallel -Xj1 vlc + else + parallel -kXj1 ls -dS + fi +} + +stdin | G "$@" | stdout + +exit $?