]>
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"
10 playeropts
="-af-add bs2b"
24 echo "Plays mp3 files in all subdirectories."
25 echo "Usage: ./mp-play.sh [-h|--help] [-R|--random] [-r|--repeat] "
26 echo " [-a|-recursive] [--reverse] [--time]"
27 echo " [--remove] [-q|--quiet] [-v|--verbose] [DESTINATION]"
30 echo " --time sort by age of file"
31 echo " -R, --random randomize files"
32 echo " -r, --repeat repeat playing infintely"
33 echo " -a, --recursive recursively find files to play"
34 echo " --reverse reverse playing order"
35 echo " --remove ask to remove played files after playing"
36 echo " -q, --quiet do not produce output when playing"
37 echo " -v, --versbose produce more output"
44 -h|
--help) showHelp
; exit 0 ;;
45 -R|
--random) optRandom
="-shuffle" ;;
46 -r|
--repeat) optRepeat
="-loop 0" ;;
47 -a|
--recursive) optRecursive
=1 ;;
48 -v|
--verbose) optVerbose
=1 ;;
49 -q|
--quiet) optQuiet
="-quiet" ;;
50 --remove) optRemove
=1 ;;
51 --reverse) optReverse
=1 ;;
52 --time) optSorttime
=1 ;;
60 if [ "$optRecursive" == "1" ]; then
68 find "$@" -maxdepth $maxlevel -type f \
69 -iname "*.mp3" -or -iname "*.avi" -or -iname "*.flv" \
70 -or -iname "*.mp4" -or -iname "*.ogg" \
73 [ "$optSorttime" == "1" ] && cat "$playlist" |
xargs ls --sort=time | sponge
"$playlist"
74 [ "$optReverse" == "1" ] && cat "$playlist" |
tac | sponge
"$playlist"
77 cntfiles
=`wc -l $playlist | cut -d " " -f 1`
80 if [ "$cntfiles" == "0" ]
82 echo "No files found."
88 echo "Playing $cntfiles files..."
91 # Print playlist, if we ask for removing files later
92 if [ "$optRemove" == "1" -o "$optVerbose" == "1" ]; then
98 $player $playeropts $optQuiet $optRandom $optRepeat -playlist "$playlist"
101 # Remove the files in the playlist
102 if [ "$optRemove" == "1" ]; then
104 echo -n "Removing played files? (y/a/N) "
106 if [ x
"y" == x
"$isdel" ]; then
107 rm -v `cat $playlist`
108 elif [ x
"a" == x
"$isdel" ]; then
109 rm -v -i `cat $playlist`
113 #Remove the playlist itself