Reply To: Almost there

#11360
rpedde
Participant

@davesanti wrote:

Well, looks like I may have made the breakthrough.. I edited the playlist to change the path to the song to:

/share/flash/data/public/My Music/Metallica/Ride the Lightning/04 Fade to Black.mp3

And it worked.

Here is the log:

Rescanning database
2007-06-25 13:59:53 (00000400): Starting playlist scan
2007-06-25 13:59:53 (00000400): Scanning /share/flash/data/public/My Music/Metallica.m3u
2007-06-25 13:59:53 (00000400): Processing static playlist: /share/flash/data/public/My Music/Metallica.m3u
2007-06-25 13:59:54 (00000400): Added playlist as id 2
2007-06-25 13:59:54 (00000400): Done processing playlist
2007-06-25 13:59:54 (00000400): Done Scanning /share/flash/data/public/My Music/Metallica.m3u
2007-06-25 14:00:03 (00000400): Updating playlists
2007-06-25 14:00:03 (00000400): Scanned 3220 songs (was 3220) in 73 seconds

So I guess the question is now how do I create playlists without going through the hassle of editing itline by line….

Are there any good programs for creating playlists that get it right.

Dave

Okay, paths that look like this:

Y:My MusicMetallicaRide the Lightning4 Fade to Black.mp3

Are absolute paths, not relative paths. So the playlist editor you are using apparently *says* it’s doing relative paths, but it’s actually saving them as absolute paths. That’s the real problem.

You have the playlist in /share/flash/data/public/My Music, right, so the path to the metallica song relative to that directory is:

Metallica/Ride the Lightning/04 Fade to Black.mp3

If you wanted to keep it absolute, it would be

/share/flash/data/public/My Music/Metallica/Ride the Lightning/04 Fade to Black.m3p, like you noted.

So if you could either get rid of the initial “Y:My Music” or replace the “Y:” with “/share/flash/data/public/”, then you would be golden.

You can do that with sed. The first is probably easiest. Sed can do search/replace on a file or stream. A sed command like this would do it:

s/Y:\My Music\//

Would cut out the Y:My Music from the front of all the file entries. The actual sed command is:

s///

In this case you are searching for Y:My Music, and replacing it with nothing (//). The reason that the ‘s are double \ed, is because the backslash is used for special match terms (like w for a whole word, or s for spaces and tabs), so it must be escaped itself (\) to tell sed you are looking for a literal backslash.

That’s probably pretty iffy but maybe you at least get the gist of it. To replace the absolute path the *real* absolute path, something like:

s/Y:\//share/flash/data/public//

would do it. (again, the /’s get escaped to tell sed that it’s a literal forward slash you want to replace it with, and not the forward slash that signals the end of the search and replace command).

Kind of gibberish, but there you go.

To use it, you would do something like:

cat metallica.m3u | sed ‘s/Y:\My Music\//’

and it would print the replaced playlist on the screen. Try it.

But you want to actually edit the playlist itself, in place. That’s what the -i argument to sed is:

sed -i ‘s/Y:\My Music\//’ metallica.m3u

Run that, and you should see the metallica playlist changed. If you try to rescan, it should pick up the playlist right.

If you are sure you have it right, you can use a shell script to fix up all the m3us:

for d in *m3u; do sed -i ‘s/Y:\My Music\//’ $d; done

This will find all the m3u files in the current directory and run the sed command above on them.

You could also do that with xargs, which takes a list of files and runs commands on all of them (basically). Something like:

ls *m3u | xargs -n1 sed -i ‘s/Y:\My Music\//’

Would probably do it. But I’d stick with the bash one. You’ll probably have to ipkg install bash, and be running the bash shell (/opt/bin/bash) to make the do-everything script work, though (the “for d…” one).

— Ron