vid: play or find videos matching strings in descending order of size.

This commit is contained in:
Ole Tange 2018-06-06 21:01:16 +02:00
parent 8e5ad183f6
commit 4700beafdf
3 changed files with 94 additions and 3 deletions

View file

@ -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

View file

@ -5,7 +5,7 @@
=head1 NAME
rand - Generate (pseudo-)random data
rand - generate (pseudo-)random data
=head1 SYNOPSIS

91
vid/vid Executable file
View file

@ -0,0 +1,91 @@
#!/bin/bash
: <<=cut
=pod
=head1 NAME
vid - Play videos matching strings in descending order of size
=head1 SYNOPSIS
B<vid> [[grep options][string]]...
=head1 DESCRIPTION
B<vid> recursively searches for videos and sort them by size. It then
filters out the names matching all the B<grep> expressions.
There can be multiple B<grep> expressions.
=head1 EXAMPLE
Play videos matching B<Documentary> but not B<BBC>:
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 <http://www.gnu.org/licenses/>.
=head1 DEPENDENCIES
B<vid> uses B<G>, and B<vlc>.
=head1 SEE ALSO
B<G>
=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 $?