2009-10-17, 02:39
This is my first time using python / scripting for xbmc to please be gentle.
To give you some background I have set up a personal website for myself to stream media when I am traveling. This means that I have no need for URL scrubbing when I can just feed it a complete index of the direct paths to all of my media. I have not gotten to this point yet so lets start from the beginning.
I have set up a simple script that simply has some hard coded links
This works on xbmc for windows, but when i port it over to the xbox xbmc it plays the video for about a second then hangs on buffering infinitely.
I tried adjusting the cache which had no effect.
additionally I would like to create directories and add specific links to those directories. I cannot however figure out how to do this. Here is step two.
This successfully creates the directories and the links, I am just wondering how I get these links into the directories.
Thank you in advance for the help.
To give you some background I have set up a personal website for myself to stream media when I am traveling. This means that I have no need for URL scrubbing when I can just feed it a complete index of the direct paths to all of my media. I have not gotten to this point yet so lets start from the beginning.
I have set up a simple script that simply has some hard coded links
Code:
import urllib,urllib2,re,xbmcplugin,xbmcgui
def addLink(name,url,iconimage):
ok=True
liz=xbmcgui.ListItem(name, "", "DefaultVideo.png", iconimage)
liz.setInfo( "Video", { "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
return ok
addLink("Video1","http://mywebsite.com/mediastore/somemovie.mp4","")
addLink("Video2","http://mywebsite.com/mediastore/somemovie2.mp4","")
xbmcplugin.endOfDirectory(int(sys.argv[1]))
This works on xbmc for windows, but when i port it over to the xbox xbmc it plays the video for about a second then hangs on buffering infinitely.
I tried adjusting the cache which had no effect.
additionally I would like to create directories and add specific links to those directories. I cannot however figure out how to do this. Here is step two.
Code:
import urllib,urllib2,re,xbmcplugin,xbmcgui
def CATS():
addDir("Movies","http://mysite.com/movies/",1,"")
addDir("Televison","http://mysite.com/tv/",1,"")
def addLink(name,url,iconimage):
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
return ok
def addDir(name,url,mode,iconimage):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
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=u,listitem=liz,isFolder=True)
return ok
########################################
CATS()
addLink("Video1","http://mywebsite.com/mediastore/somemovie.mp4","")
addLink("Video2","http://mywebsite.com/mediastore/somemovie2.mp4","")
xbmcplugin.endOfDirectory(int(sys.argv[1]))
This successfully creates the directories and the links, I am just wondering how I get these links into the directories.
Thank you in advance for the help.