Simple Plugin for Personal streaming site
#1
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

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.
Reply
#2
Hi there and welcome to the forums!

The trick with plugins is that XBMC re-calls your plugin when you fetch a new folder. The new folder's URL is appended to the normal URL.

Thus, in your main routine, you should first parse the URL, grab out which folder XBMC wants (it could be the root folder, or it could be a subfolder) then add the items that you need under that folder.

As for the playback issue on xbox, try playing with the dvdplayer rather than mplayer.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
First, thank you very much for the reply it was quite helpful

I managed to get the directories all set up and working how I want. I am still however having and issue with Xbox playback. It works fine on OSX and windows. I have a bit of log info that maybe someone can give me some insite on.

Code:
12:01:57 M: 39460864 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
12:01:57 M: 38936576  NOTICE: Creating InputStream
12:01:58 M: 37441536  NOTICE: Creating Demuxer
12:02:04 M: 19001344   ERROR: CFileCurl::CReadState::Open, didn't get any data from stream.
12:02:04 M: 19103744   ERROR: XFILE::CFileCache::Process, error 10035 seeking. seek returned -1
12:02:04 M: 18915328  NOTICE: Opening video stream: 0 source: 256
12:02:04 M: 18984960  NOTICE: Creating video codec with codec id: 28
12:02:04 M: 18915328  NOTICE: CDVDVideoCodecFFmpeg::Open() Using codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
12:02:04 M: 18739200  NOTICE: Creating video thread
12:02:04 M: 18210816  NOTICE: Opening audio stream: 1 source: 256
12:02:04 M: 18210816  NOTICE: Finding audio codec for: 86018
12:02:04 M: 18210816  NOTICE: running thread: video_thread
12:02:04 M: 17989632  NOTICE: Creating audio thread
12:02:04 M: 17465344  NOTICE: running thread: CDVDPlayerAudio::Process()
12:02:11 M: 13996032  NOTICE: Creating audio device with codec id: 86018, channels: 2, sample rate: 48000, no pass-through
12:02:11 M: 12738560  NOTICE:  fps: 23.976025, pwidth: 628, pheight: 334, dwidth: 628, dheight: 334
12:02:11 M: 12668928  NOTICE: Display resolution AUTO : NTSC 16:9 (5)
12:02:11 M: 11538432 WARNING: CDVDVideoCodecFFmpeg::Decode - avcodec_decode_video didn't consume the full packet. size: 18, consumed: 0
12:02:11 M: 11538432 WARNING: CDVDVideoCodecFFmpeg::Decode - avcodec_decode_video didn't consume the full packet. size: 18, consumed: 0
12:02:11 M: 11538432 WARNING: CDVDVideoCodecFFmpeg::Decode - avcodec_decode_video didn't consume the full packet. size: 18, consumed: 0
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Unexpected fill element with SBR data
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11231232   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11218944   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11198464   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11210752   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11235328   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected fill element with SBR data
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected fill element with SBR data
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11243520   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11235328   ERROR: CDVDAudioCodecLibFaad() : Maximum number of scalefactor bands exceeded
12:02:13 M: 11227136   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11235328   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11223040   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11223040   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11223040   ERROR: CDVDAudioCodecLibFaad() : Gain control not yet implemented
12:02:13 M: 11223040   ERROR: CDVDAudioCodecLibFaad() : Negative scalefactor found, should be impossible
12:02:13 M: 11223040   ERROR: CDVDAudioCodecLibFaad() : Channel coupling not yet implemented
12:02:13 M: 11202560   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11214848   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11214848   ERROR: CDVDAudioCodecLibFaad() : Unexpected channel configuration change
12:02:13 M: 11214848   ERROR: CDVDAudioCodecLibFaad() : Invalid number of channels
12:02:13 M: 11214848   ERROR: CDVDAudioCodecLibFaad() : Array index out of range

Thanks again for all the help
Reply

Logout Mark Read Team Forum Stats Members Help
Simple Plugin for Personal streaming site0