]>
git.sthu.org Git - shutils.git/blob - mp-play
5 player
="/usr/bin/mplayer"
6 if [ -x "/usr/bin/mplayer2" ]; then
7 player
="/usr/bin/mplayer2"
9 if [ -x "/usr/bin/mpv" ]; then
14 $player -af help |
grep -q bs2b
&& playeropts
="${playeropts} -af-add bs2b"
29 echo "Usage: $0 [-h|--help]"
30 echo " $0 [OPTIONS] [--] [DESTINATIONS]"
33 echo " -a, --recursive recursively find files to play"
34 echo " -h, --help show this message"
35 echo " -q, --quiet do not produce output when playing"
36 echo " -r, --repeat repeat playing infintely"
37 echo " -R, --random randomize files"
38 echo " --remove ask to remove played files after playing"
39 echo " --reverse reverse playing order"
40 echo " --time sort by age of file"
41 echo " -v, --verbose produce more output"
44 if ! options
=$
(getopt
-u -o hRravq
-l time,random
,repeat
,recursive
,reverse
,remove
,quiet
,verbose
-- "$@")
55 -h|
--help) showHelp
; exit 0 ;;
56 -R|
--random) optRandom
="-shuffle" ;;
57 -r|
--repeat) optRepeat
="-loop 0" ;;
58 -a|
--recursive) optRecursive
=1 ;;
59 -v|
--verbose) optVerbose
=1 ;;
60 -q|
--quiet) optQuiet
="-quiet" ;;
61 --remove) optRemove
=1 ;;
62 --reverse) optReverse
=1 ;;
63 --time) optSorttime
=1 ;;
65 -*) echo "Unrecognized option $1" >&2; showHelp
>&2; exit 1 ;;
73 if [ "$optRecursive" == "1" ]; then
81 find "$@" -maxdepth $maxlevel -type f \
82 -iname "*.mp3" -or -iname "*.avi" -or -iname "*.flv" -or -iname "*.flac" \
83 -or -iname "*.mp4" -or -iname "*.ogg" -or -iname "*.m4a" \
86 [ "$optSorttime" == "1" ] && cat "$playlist" |
xargs ls --sort=time | sponge
"$playlist"
87 [ "$optReverse" == "1" ] && cat "$playlist" |
tac | sponge
"$playlist"
90 cntfiles
=`wc -l $playlist | cut -d " " -f 1`
93 if [ "$cntfiles" == "0" ]
95 echo "No files found."
101 echo "Playing $cntfiles files..."
104 # Print playlist, if we ask for removing files later
105 if [ "$optRemove" == "1" -o "$optVerbose" == "1" ]; then
111 $player $playeropts $optQuiet $optRandom $optRepeat -playlist "$playlist"
114 # Remove the files in the playlist
115 if [ "$optRemove" == "1" ]; then
117 echo -n "Removing played files? (y/a/N) "
119 if [ x
"y" == x
"$isdel" ]; then
120 rm -v `cat $playlist`
121 elif [ x
"a" == x
"$isdel" ]; then
122 rm -v -i `cat $playlist`
126 #Remove the playlist itself