maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Multimedia (https://talk.maemo.org/forumdisplay.php?f=32)
-   -   Script to create M3U playlists for each folder in MyDocs/.sounds (https://talk.maemo.org/showthread.php?t=59508)

dave1010 2010-07-31 07:27

Script to create M3U playlists for each folder in MyDocs/.sounds
 
I've created this script that makes a playlist for each folder in your music. This lets you play a folder at a time with the default media player.

Code:

cd ~/MyDocs/.sounds
for i in *; do
  echo Processing $i
  if [ -d "$i" ]; then
    find "$i/" -type f -iname "*.mp3" > "$i.m3u"
  fi
done

This script (and others) can be found on my N900 scripts GitHub project page.

Incidently, git source control is a great way to manage projects on the N900 as you can easily sync to your PC or github.com. You can install git on the N900 with a simple
Code:

apt-get install git
Update: to search for OGG and WMA files as well as MP3s, change the line starting find to (all 1 line):
Code:

find "$i/" -type f  -regex ".*\([mM][pP]3\|[wW][mM][aA]|[oO][oO][gG]\)" > "$i.m3u"

MSHAH 2010-07-31 07:53

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
thanks dave1010, is there any way to expand the recently added playlist from 30 songs, or possibly to sort the songs in order of date added?

ossipena 2010-07-31 08:00

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
now just pretty UI around it and people will love you instantly :)

phedders 2010-07-31 10:41

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
yep all my n900 stuff is in a github project too :)

Git rocks.

kl2010 2010-07-31 12:27

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
great stuff. tried it and it work fine. my questions is does it automatically make a playlist of any folder i add to the music folder from now on or do i have to run the code everytime i add new music/song/folder to the folder??

thanks. alot.

soeiro 2010-07-31 12:34

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by kl2010 (Post 771327)
my questions is does it automatically make a playlist of any folder i add to the music folder from now on or do i have to run the code everytime i add new music/song/folder to the folder??

You must run it again when you make changes. However, you could also create a desktop shortcut to make it easier to start.

dave1010 2010-07-31 13:04

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by MSHAH (Post 771142)
is there any way to expand the recently added playlist from 30 songs, or possibly to sort the songs in order of date added?

Not very easily. I'm using find, which doesn't have any sorting options. You can get all the files modified with a certain number of days:

Code:

cd ~/MyDocs/.sounds
find -mtime -2 -iname "*.mp3" > today.m3u
find -mtime -8 -iname "*.mp3" > this-week.m3u
find -mtime -31 -iname "*.mp3" > this-month.m3u

The busybox find that comes with the N900 seems quite limited. You could install GNU find, which has a few extra options (but still no sorting).

Quote:

Originally Posted by ossipena (Post 771148)
now just pretty UI around it and people will love you instantly

That's a good plan. I don't really know any C/Qt or much Python yet. I'll have to do some learning. Anyone want to help out? :)

Quote:

Originally Posted by kl2010 (Post 771327)
does it automatically make a playlist of any folder i add to the music folder from now on or do i have to run the code everytime

Unfortunately you have to run it each time you add any new music.

When I have some time I'll look into getting it to run automatically when the Media Player loads and/or a nice GUI. Alternatively, you could save it as a script and make it into a Queen BeeCon Widget quite easily.

leojab 2010-07-31 13:35

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
What to do when I have those scripts in memory card? this script runs only for the internal memory rite

leojab 2010-07-31 13:41

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
What to do when I have those scripts in memory card? this script runs only for the internal memory rite

dave1010 2010-07-31 14:21

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by leojab (Post 771377)
What to do when I have those scripts in memory card? this script runs only for the internal memory rite

That's right. Music is kept in /home/user/MyDocs/.sounds on the 32GB internal flash. (~/ is a shortcut for /home/user/). To do the same on the memory card, change the first line line of the script to:
Code:

cd /media/mmc1
This will scan the whole external memory card for MP3s. If you have a music folder on an external memory card, you could do:
Code:

cd /media/mmc1/music
I haven't tried putting music or playlists on the external memory card, but I guess it works fine.

leojab 2010-07-31 20:20

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
All my music is on my 16 Gb SD card and it plays fine from there on my N900.
Question, all my songs are in m4a format so does m3u support this format.. thanks. I do not want to use mp3 going forward as well.

j.s 2010-07-31 21:11

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by dave1010 (Post 771126)
I've created this script that makes a playlist for each folder in your music. This lets you play a folder at a time with the default media player.

Code:

cd ~/MyDocs/.sounds
for i in *; do
  echo Processing $i
  if [ -d "$i" ]; then
    find "$i/" -type f -iname "*.mp3" > "$i.m3u"
  fi
done


The following also addresses date ordering.

If the playlist is in the same directory as the audio files, no path information is needed in the playlist. This also makes it easy to move directories around on a device or between devices.

Code:

cd  $1
for i in *; do
  echo Processing $i
  if [ -d "$i" ]; then
    cd $i
    ls "*.mp3" "*.ogg" "*.wma" > "$i.m3u"
    cd ..
  fi
done

To sort by date:

Code:

cd  $1
for i in *; do
  echo Processing $i
  if [ -d "$i" ]; then
    cd $i
    ls -rt "*.mp3" "*.ogg" "*.wma" > "$i.m3u"
    cd ..
  fi
done


dave1010 2010-07-31 21:50

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by leojab (Post 771635)
Question, all my songs are in m4a format so does m3u support this format.

M3U playlists should support any file - I think even videos. Just change the find line to:
Code:

find "$i/" -type f -iname "*.m4a" > "$i.m3u"

dave1010 2010-07-31 21:57

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
j.s, that's a great idea using ls instead of find. I keep most of my music in an Arist/Album/Track structure so it woudn't work so well some of the time. I'm experimenting with ls -R (recursive) but it's not getting the whole path.

kl2010 2010-07-31 22:47

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by soeiro (Post 771329)
You must run it again when you make changes. However, you could also create a desktop shortcut to make it easier to start.

pls how do i make it as a desktop shortcut? thanks.

dave1010 2010-08-01 17:24

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Quote:

Originally Posted by kl2010 (Post 771703)
pls how do i make it as a desktop shortcut? thanks.

  1. Save the script at the top of this thread as a file as /home/user/make-playlists.sh
  2. Install Queen Beecon Widget
  3. Add the Queen Beecon widget to your desktop
  4. Configure it and add /home/user/make-playlists.sh as a customnew command

karblast 2010-08-20 11:34

Re: Script to create M3U playlists for each folder in MyDocs/.sounds
 
Hi.. M sure my question might sound lame! but m not aware of how one is supposed to use scripts!! Pls guide me on how i am supposed to install this script in my fone to be able to play my tracks by folders!! Thanks in advance!!


All times are GMT. The time now is 00:02.

vBulletin® Version 3.8.8