2006-06-04, 20:22
iam using the script video on startup. this script makes a playlist of local media from a local dir on the xbox and plays a random media file. i tried to modify the script so it makes a playlist from a smb dir but i cant seem to get it to work. this is the script iam using:
i want it to make a play list of the current dir smb://myip/musicvideo/
i tried to add the dir 'smb://myip//musicvideo//' but that didnt work.
it seems when u want to acces a smb file u have to use backslash '\\' instead of '//'. i found this out by making this small test script
but i still cant figure it out how to make the script read all the movie files from a smb dir and places them in a playlist.
Quote:''' vim: ts=8 sw=4 noexpandtab
by: antibiotek ver: 0.1
original script by rune hammersland ver: 0.3
this script is for those of you who love to turn on your xbox and watch music
vidoes in the morning. it will take a playlist or a music video directory,
randomize all the videos, and play them. be sure to modify your autoexec.py
to start it up!
'''
import xbmc
import os
# ---------------------------------------- #
# "configuration"
# ---------------------------------------- #
# change this to your playlist(s).
# written like this: ['path\\to\\plist1', 'to\\plist2', 'plist\\3']
playlist_files= ['e:\\media\\music\\playlist.m3u']
# dirs(s) to traverse if playlist does not exist. nb: no trailing slash.
# written like this: ['path\\to\\dir1', 'to\\dir2', 'dir\\3']
musicvideos_dirs = ['e:\\temp']
# shuffle playlist if this var equals 1.
shuffle_files = 1
# ---------------------------------------- #
# code
# ---------------------------------------- #
# function for adding files to playlist
def add_files(pl, dirname, names):
for filename in names:
if (os.path.isfile(dirname + "\\" + filename)):
add = 0
# check extension of file.
if (filename[-4:] == ".avi"): add = 1
if (filename[-4:] == ".mpg"): add = 1
if (filename[-4:] == ".wmv"): add = 1
if (filename[-4:] == ".asf"): add = 1
if (filename[-4:] == ".m2v"): add = 1
# if file is to be added, do it.
if (add == 1): pl.add(dirname + "\\" + filename)
elif (os.path.isdir(dirname + "\\" + filename)):
os.path.walk(dirname + "\\" + filename, add_files, pl)
# get music playlist from xbmc
plist = xbmc.playlist(0)
plist.clear()
# load playlist if it exists
for playlist_file in playlist_files:
if (os.path.isfile(playlist_file)):
plist.load(playlist_file)
# else, find all available music videos
else:
for musicvideos_dir in musicvideos_dirs:
os.path.walk(musicvideos_dir, add_files, plist)
# do the shuffle!
if (shuffle_files == 1): plist.shuffle()
xbmc.player().play(plist)
i want it to make a play list of the current dir smb://myip/musicvideo/
i tried to add the dir 'smb://myip//musicvideo//' but that didnt work.
it seems when u want to acces a smb file u have to use backslash '\\' instead of '//'. i found this out by making this small test script
Quote:import xbmc
file = 'smb://myip//musicvideo//test.avi'
plist.add(file)
xbmc.player().play(plist)
xbmc.executebuiltin('xbmc.activatewindow(0)')
but i still cant figure it out how to make the script read all the movie files from a smb dir and places them in a playlist.