]>
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"
11 $player -af help |
grep -q bs2b
&& playeropts
="${playeropts} -af-add bs2b"
26 echo "Plays mp3 files in all subdirectories."
27 echo "Usage: ./mp-play.sh [-h|--help] [-R|--random] [-r|--repeat] "
28 echo " [-a|-recursive] [--reverse] [--time]"
29 echo " [--remove] [-q|--quiet] [-v|--verbose] [DESTINATION]"
32 echo " --time sort by age of file"
33 echo " -R, --random randomize files"
34 echo " -r, --repeat repeat playing infintely"
35 echo " -a, --recursive recursively find files to play"
36 echo " --reverse reverse playing order"
37 echo " --remove ask to remove played files after playing"
38 echo " -q, --quiet do not produce output when playing"
39 echo " -v, --versbose produce more output"
46 -h|
--help) showHelp
; exit 0 ;;
47 -R|
--random) optRandom
="-shuffle" ;;
48 -r|
--repeat) optRepeat
="-loop 0" ;;
49 -a|
--recursive) optRecursive
=1 ;;
50 -v|
--verbose) optVerbose
=1 ;;
51 -q|
--quiet) optQuiet
="-quiet" ;;
52 --remove) optRemove
=1 ;;
53 --reverse) optReverse
=1 ;;
54 --time) optSorttime
=1 ;;
62 if [ "$optRecursive" == "1" ]; then
70 find "$@" -maxdepth $maxlevel -type f \
71 -iname "*.mp3" -or -iname "*.avi" -or -iname "*.flv" \
72 -or -iname "*.mp4" -or -iname "*.ogg" \
75 [ "$optSorttime" == "1" ] && cat "$playlist" |
xargs ls --sort=time | sponge
"$playlist"
76 [ "$optReverse" == "1" ] && cat "$playlist" |
tac | sponge
"$playlist"
79 cntfiles
=`wc -l $playlist | cut -d " " -f 1`
82 if [ "$cntfiles" == "0" ]
84 echo "No files found."
90 echo "Playing $cntfiles files..."
93 # Print playlist, if we ask for removing files later
94 if [ "$optRemove" == "1" -o "$optVerbose" == "1" ]; then
100 $player $playeropts $optQuiet $optRandom $optRepeat -playlist "$playlist"
103 # Remove the files in the playlist
104 if [ "$optRemove" == "1" ]; then
106 echo -n "Removing played files? (y/a/N) "
108 if [ x
"y" == x
"$isdel" ]; then
109 rm -v `cat $playlist`
110 elif [ x
"a" == x
"$isdel" ]; then
111 rm -v -i `cat $playlist`
115 #Remove the playlist itself