Random Songs from Playlist upon Startup of XBMC
#1
Hi guys,

I've been fooling around with this autoexec.py script I found that is supposed to evoke a random song from my playlists when XBMC starts. I'm not sure if the code is correct or not. I'm very lost, I have no idea what methods are available to use. I took a bit of Java in university, but it's been ages since so I'm trying to get my feet wet with this little script.

So here is the autoexec.py --> It supposed to automate the action at the start up of xbmc...or so I'm told.

----------------------------------------------------------------------------------
# auto execute scripts when xbmc starts, place this file in xbmchome\scripts\
#
# note: - do not execute more than one script at a time which asks for user input!

import xbmc

xbmc.executescript('Q:\\scripts\\RandomPlay1.py')
------------------------------------------------------------------------------------

This is the script for the random song that is supposed to look in my playlists and pick a song.

import os.path, string
import glob, random
import xbmc, xbmcgui

filename = []
Repertoire ='Q:\\UserData\\playlists\\music'

def listRep ( args, dirname, filenames ):
global filename
filename[:0] = glob.glob(dirname + '\*.m3u')

os.path.walk(Repertoire, listRep, None )
a = len(filename)
if a > 0:
nb = random.randint(0,a-1)
pls = xbmc.PlayList(0)
pls.load(filename[nb])
pls.shuffle()
xbmc.Player().play(pls)
else:
dialog = xbmcgui.Dialog()
dialog.ok(" Error", " no list found")
--------------------------------------------------------------------------------------

And finally in my xbmx/UserData/playlist/music
XboxMix.pls

[playlist]

File1=/Users/MyName/Shared/Don't Let Me Down.mp3

Title1=No Doubt - Don't Let Me Down

Length1=280

File2=/Users/MyName/Shared/Aerosmith - Cryin.mp3

Title2=Aerosmith - Cryin

Length2=215

File3=/Users/MyName/Shared/Another Sunday.mp3

Title3=I Mother Earth - Another Sunday

Length3=215

NumberOfEntries=3

Version=2
------------------------------------------------------------------------
Does this make any sense? Can anyone shed light on this? I'm guessing this script is dated and somewhere there isn't a connection.
Reply

Logout Mark Read Team Forum Stats Members Help
Random Songs from Playlist upon Startup of XBMC0