video on startup help
#1
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:

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.
Reply
#2
in the last python implementation, we did not have access to smb trough pure python code. i expect that is the error in this case. to get it working, you will have to make a walkaround using httpapi or smbmodule(has limit on windows).
check out http://2ndmind.net/xnetload/ script,
the author said that he implanted a httapi workaround in that script.
Reply
#3
well the only thing i need is the filenames of all the files in a smb dir. something like a function that returns the filename(string). because when i have the filenames i can write the pathname+filename to a playlist file and then the script will work.

i tried this but it didnt work:

lf = open('q:\\scripts\\test.log', 'a')
lstdirlist = os.listdir("smb://myip//musicvideo//")
for strfiledir in lstdirlist:
lf.write(strfiledir + '\n')
lf.close()
Reply
#4
as i said you cannot access smb trough native python like you just did.

a walkaround is to use httpapi or a smb module like pysmb.
using httpapi you can use:
http://xbox/xbmccmd....ter=smb

but you will have to parse result info.
using httpapi from python is done like this:
http://home.no.net/thor918/xbmc/stuff/py...xbmcapi.py



Reply

Logout Mark Read Team Forum Stats Members Help
video on startup help0