How to scramble a playlist ?

2009-01-20 Thread Lothar Behrens

Hi,

I have seen two applications that could scramble text files.

http://www.vanheusden.com/unsort/

and

http://ch.tudelft.nl/~arthur/rl/

Is anyone on a similar solution to port it onto OpenMoko ?

Or are there shellscript solutions ?

Thanks

Lothar

-- | Rapid Prototyping | XSLT Codegeneration | http://www.lollisoft.de
Lothar Behrens
Heinrich-Scheufelen-Platz 2
73252 Lenningen








___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: How to scramble a playlist ?

2009-01-20 Thread The Digital Pioneer
Shouldn't be too hard to write one... I can think of a few very inefficient
implementations, but I'm sure others can think of better ones. :P

-- 
Thanks,

The Digital Pioneer
___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: How to scramble a playlist ?

2009-01-20 Thread eric
Here's a way to do it in python:

#!/usr/bin/env python
import sys, random
filename = sys.argv[1]
a = open(filename).read().strip().split(\n)
random.shuffle(a)
for i in a:
 print i


If you're not famililar with shell stuff:

Save that to a file like scramble and then do:
python scramble myfile

You can just type scramble myfile after you've done
chmod +x scramble

Probably you want to redirect the list into a file:
python scramble myplaylist.txt  /tmp/shuffledplaylist.txt
or you can add python code to accept another argument for an  
outfilename and write the file -- with a check to make sure you're not  
overwriting an existing file (don't want you to overwrite your  
playlist on accident :)

Eric

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: How to scramble a playlist ?

2009-01-20 Thread Lothar Behrens

Great,

that works. Now I have a random jukebox with just one click (with a  
desktop file).


Lothar

Here is my script to get it working onto my bluetooth device:

#!/bin/sh
killall -SIGQUIT mplayer
/home/root/setup-bluetooth-audio.sh
rm playlist-sorted.m3u
rm playlist.m3u
find /media/card/Musik -name *.mp3  /home/root/playlist-sorted.m3u
/home/root/scramble.py /home/root/playlist-sorted.m3u  /home/root/ 
playlist.m3u

mplayer -ao alsa:device=bluetooth -playlist /home/root/playlist.m3u 
#mplayer -ao alsa:device=bluetooth 
http://yp.shoutcast.com/sbin/tunein-station.pls?id=2408
sleep 3
renice -19 `ps ax | grep mplayer | grep -Ev grep|Unknown | awk --  
'BEGIN {}{ print $1;}'`



setup-bluetooth-audio.sh:

#!/bin/sh
# Your device
export DEVICE=XX:XX:XX:XX:XX:XX

/etc/init.d/bluetooth stop
/etc/init.d/bluetooth start

sleep 1
passkey-agent --default  

sleep 1
echo Create bonding
dbus-send --system --type=method_call --print-reply --dest=org.bluez / 
org/bluez/hci0 org.bluez.Adapter.CreateBonding string


sleep 1
echo Activating service audio
dbus-send --system --print-reply --dest=org.bluez /org/bluez  
org.bluez.Manager.ActivateService string:audio


sleep 1
echo Creating device
dbus-send --system --type=method_call --print-reply --dest=org.bluez / 
org/bluez/audio org.bluez.audio.Manager.CreateDevice


sleep 1
echo Connecting sink
dbus-send --system --type=method_call --print-reply --dest=org.bluez / 
org/bluez/audio/device0 org.bluez.audio.Sink.Connec




Am 20.01.2009 um 22:09 schrieb e...@ericanddebbie.com:


Here's a way to do it in python:

#!/usr/bin/env python
import sys, random
filename = sys.argv[1]
a = open(filename).read().strip().split(\n)
random.shuffle(a)
for i in a:
print i


If you're not famililar with shell stuff:

Save that to a file like scramble and then do:
python scramble myfile

You can just type scramble myfile after you've done
   chmod +x scramble

Probably you want to redirect the list into a file:
python scramble myplaylist.txt  /tmp/shuffledplaylist.txt
or you can add python code to accept another argument for an
outfilename and write the file -- with a check to make sure you're not
overwriting an existing file (don't want you to overwrite your
playlist on accident :)

Eric

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community



-- | Rapid Prototyping | XSLT Codegeneration | http://www.lollisoft.de
Lothar Behrens
Heinrich-Scheufelen-Platz 2
73252 Lenningen








___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community