addDirectoryItem - how to show content of a network folder?
#1
Hello,

assuming i use the following code:

Code:
def addDir(name,url,iconimage):
        ok=True
        liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
        liz.setInfo( type="Video", infoLabels={ "Title": name } )
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz,isFolder=True)
        return ok
and i call it with
Code:
addDir('The Matrix', 'smb://192.168.0.1/Movies/IMDB top 30/30 - The Matrix/', '')

it adds the folder, but when i open it, it is empty.. how can i show within this created folder the content of the folder of the network path?

thanks in advance,
zakmes
Reply
#2
what the goal ?
you're confusing virtual and real directory structure.
Reply
#3
well, the goal is to parse xml from a local network share search engine and list the results.

i have everything working, except this.

what i want is: create a virtual folder ('The Matrix') which links to the real folder ('smb://192.168.0.1/Movies/IMDB top 30/30 - The Matrix/'). i also would like to browse this folder then, if it has subfolders and list all the files in this folder + any subfolders.

like i am used to it from the normal video component of xbmc, where i also can add some smb shares and browse them.
Reply
#4
so you have to define a path
see os.path, you should have all you need there.
Reply
#5
ok, thanks for your hint.

i used this code, but unfortunately it does not work with samba shares:

Quote:15:41:31 T:4488 M:1013493760 NOTICE: folderContents = os.listdir(path)
15:41:31 T:4488 M:1013493760 NOTICE: WindowsError
15:41:31 T:4488 M:1013493760 NOTICE: :
15:41:31 T:4488 M:1013493760 NOTICE: [Errno 123] The filename, directory name, or volume label syntax is incorrect: u'smb://192.168.0.1/public/Video/Movies/Matrix/*.*'

well, i found this: http://forum.xbmc.org/showthread.php?tid=20310 but an code snippet would help a lot.. 2006 is 4 yrs ago, is there anything new accessing samba shares from python?

last question for comprehension:
is the url parameter of the addDirectoryItem function used for the virtual file system?
Reply
#6
you have access to it via xbmc vfs, strange for your problem, but can you try this:
Code:
os.listdir(path.strip("u'"))
Reply
#7
mh, the error does not change that much:

Quote:17:15:25 T:6900 M:1077940224 NOTICE: folderContents = os.listdir(path.strip("u'"))
17:15:25 T:6900 M:1077940224 NOTICE: WindowsError
17:15:25 T:6900 M:1077940224 NOTICE: :
17:15:25 T:6900 M:1077940224 NOTICE: [Errno 123] The filename, directory name, or volume label syntax is incorrect: 'smb://192.168.0.1/public/Video/Movies/Matrix/*.*'
17:15:25 T:6900 M:1077940224 ERROR: Scriptresult: Error
17:15:27 T:7496 M:1078665216 ERROR: DIRECTORY::CDirectory::GetDirectory - Error getting plugin://programs/CampusSearch/
17:15:27 T:7496 M:1078665216 ERROR: CGUIMediaWindow::GetDirectory(plugin://programs/CampusSearch/) failed
Sad

anyway: i think i can solve it using httpapi, but my main problem stays: i want to add a file as a link and play it by clicking on it, how?
Reply
#8
ho my bad !!!
can you try without "*.*" in your path?

step by step please, let's resolve that then see the rest Wink
Reply
#9
well, the thing is that i my path string does not contain "*.*", i think it is added by the os.listdir function...

i solved that with httpapi:

Code:
response = xbmc.executehttpapi("GetDirectory(" + path + ")")
# remove <li> tags
response = response.replace("<li>", "")
# we only want the directories and files, so remove the absolute network path
response = response.replace(path, "")
# also "dir/" has to be just "dir"
response = response.replace("/", "")
# first token is a newline, we do not want that
response = response.replace("\n", "", 1)
# we split at each newline, so that we have a list of dirs & files
folderContents = response.split('\n')

and now, i can browse through all network directories, so that works.. now i just want the file to be played when i click on it and i am done Big Grin
Reply
#10
for that, if you want to have some stuff and information on what you wanna play, you need to pass a listitem to xbmc.Player().play (or something around that)

playableVideoItem = xbmcgui.ListItem( name , path = trailer)
xbmc.Player().play(trailer, playableVideoItem, False)

this will only show name when pressing "i" when playing the video.

see the xbmc python documentation for more informations.
Reply
#11
okay, but how do i get the player to play the item, as soon as i click on it?
Reply
#12
change "isFolder=True" to "isFolder=False"
Reply
#13
thanks.

when i run this on the xbox (newest xbmc4xbox build from today) i get the following error:

Code:
10:01:13 M: 30380032   ERROR: programdatabase: error finding active trainer for 0 (select * from trainers where idTitle=0 and Active=1)
10:01:14 M: 30380032   ERROR: Unable to run xbe : smb://192.168.0.1/movies/The Matrix Reloaded (Part 1).avi

any idea?
Reply
#14
you're trying to run it as a program plugin. the program window can only handle... programs. it's a video plugin.
Reply
#15
and that does the trick, not it works!

thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
addDirectoryItem - how to show content of a network folder?0