[CLUE-Tech] more on recursive .mp3 playing

dlwillson at thegeek.nu dlwillson at thegeek.nu
Fri Aug 30 10:21:45 MDT 2002


I keep all my mp3's in the same tree, which is to-Hell-and-gone in the folder
structure and I hate typing it all out, so I added a couple lines to Dave's
script, which allows me to launch the script as "mp3play Metallica" or "mp3play
'Joe Satriani'".  The quotes around the "$mp3root$1" keeps everything in one
token, so that I can play artists like "Joe Satriani" without errors.  (took me
a few minutes to fix that one)

An unintended benefit is that all paths are absolute, so the temporary list can
go to /tmp now.

#!/bin/bash
#mpr - recursively play mp3's in a directory
mp3root="/var/www/html/music/"
find "$mp3root$1" | grep .mp3 | sort > /tmp/mpr.lst
mpg123 -C -b 1024 -@ /tmp/mpr.lst
rm /tmp/mpr.lst

I wonder if enquoting the argument to grep would fix the directories being
played problem.  I didn't try that; I don't have any folders named 'mp3'.

Quoting Dave Price <davep at kinaole.org>:

> followup...
> 
> xargs works well enough from the command line, but I wound up building
> another script.  The goal is to play all .mp3 files under a directory
> _in_order_ since some of what I want to play are talking books, random
> makes no sence, I have a different script for that.
> 
> Here is the recursive script:
> 
> [davep at dp:~]$ cat `which mpr`
> #!/bin/bash
> #mpr - recursively play mp3's in a directory
> find $1 | grep .mp3 | sort > mpr.lst
> mpg123 -C -b 1024 -@ mpr.lst
> rm mpr.lst
> 
> Notes:
> 
> The -C lets you stop and pause playback; the -b sets up a buffer to
> avoid dropouts.
> 
> I would have thought that the 'grep .mp3' pipe would eliminate directory
> names themselves, but when I use an argument like '/local/mp3/led_zeppelin'
> I wind up getting the empty directory names too; not just .mp3 files as
> expected.
> 
> I tried using /var/tmp/ as the location for the temp file (mpr.lst) but
> found that if i used 'relative paths' as arguments, mpg123 would prepend
> the /var/tmp in front of the file name. e.g. 'mpr ./led_zeppelin' would
> result in 'mpg123: /var/tmp/./led_zeppelin/xxxx file not found' ...
> building the temp file in the working directory seems to sole this
> nicely.  I can now mount a cd full of .mp3 files and 'mpr /cdrom' does
> what i would expect.
> 
> FYIW here is the 'play what match's a regex script':
> 
> [davep at dp:~]$ cat `which mpg`
> #1/bin/bash
> locate .mp3 | grep -i $1 > playlist ; mpg123 -z -@ playlist
> 
> (This one does randomize)
> 
> aloha,
> dave
> 
> _______________________________________________
> CLUE-Tech mailing list
> CLUE-Tech at clue.denver.co.us
> http://clue.denver.co.us/mailman/listinfo/clue-tech
> 




-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/



More information about the clue-tech mailing list