queue random songs onto mpd
Saturday, February 2nd, 20081 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/bin/env python # mpdrandom.py import os, random dbfile = '/home/foo/.mpd/mpd.db' num_of_songs_to_add = 50 songs = [] dbfile = open(dbfile) for line in dbfile.readlines(): if line.startswith('file: '): songs.append( line.split('file:')[1].strip() ) dbfile.close() random.shuffle(songs) for i in range(num_of_songs_to_add): os.system("mpc add " + '"' + songs[i] + '"') |
you need mpd and mpc for this script. all it does is goes to the database of songs that mpd created and parses out the filenames then shuffles them and adds n number of songs from the beginning of the array to the mpc playlist.

