Direct Streaming of mp4 files

[Solved]





Hi, I’m trying to create a plugin and getting along fine with it so far. The only thing I couldn’t figure out yet is how to actually play a mp4 video. I had success with adding Directory items and wanted to try if I actually can play the files before finishing all structures (with paths, thumbs etc.), therefore the hardcoded path. This is an excerpt frome the code:



<br />
def ItemPage(sender, pageUrl):<br />
    dir = MediaContainer(mediaType='items')<br />
    name="testdatei"<br />
    path="http://podfiles.zdf.de/podcast/zdf_podcasts/110314_h19_p.mp4"<br />
    dir.Append(VideoItem(path,name,"title","lord who knows",200000))<br />
    #dir.Append(Function(VideoItem(path,name,"title","lord who knows",200000))) doesn't work neither<br />
    return dir <br />
######################<br />





If i comment the dir.Append part everything works as intended. Uncommented the plugin won't start anymore and the console says:<br />
16.03.11 20:08:41	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	Traceback (most recent call last):<br />
16.03.11 20:08:41	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	  File "/Users/felix/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/1/Python/bootstrap.py", line 48, in <module><br />
16.03.11 20:08:41	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	    if len(sys.argv) >= 2: PMS.Plugin.__run(sys.argv[-1])



When I use the dir.Append(Function... command these lines appear additionally:

16.03.11 20:15:44	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	  File "/Users/felix/Library/Application Support/Plex Media Server/Plug-ins/Framework.bundle/Contents/Resources/Versions/1/Python/PMS/Plugin.py", line 313, in __run<br />
16.03.11 20:15:44	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	    import Code as _plugin<br />
16.03.11 20:15:44	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	  File "/Users/felix/Library/Application Support/Plex Media Server/Plug-ins/Mediatheken.bundle/Contents/Code/__init__.py", line 102<br />
16.03.11 20:15:44	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	    Log(titles) <br />
16.03.11 20:15:44	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	    ^<br />
16.03.11 20:15:44	[0x0-0x77a77a].com.plexapp.plexmediaserver[20227]	IndentationError: unexpected indent



Please tell me, what am I doing wrong?
Thanks


The first thing I notice is that the indentation is off. That may just be an issue with copying and pasting into the forum post, but the above code should look something like...

<br />
def ItemPage(sender, pageUrl):<br />
    dir = MediaContainer(mediaType='items')<br />
<br />
<br />
    name="testdatei"<br />
    path="http://podfiles.zdf.de/podcast/zdf_podcasts/110314_h19_p.mp4"<br />
    dir.Append(VideoItem(path,name,"title","lord who knows",200000))<br />
    return dir <br />
######################<br />




Remember that whitespace and indentation are important in python. Check the code to make sure that it's not tripping on indentations.

Thank you, but you're right, the indentation was messed up because of the copy, paste and delete process :) An old siteconfig (from the original plugin) still exists, might this be the source of error?

Strange..Strange, somehow I got it working with this:

def ItemPage(sender, pageUrl):<br />
#def ItemPage(sender):<br />
    Log("Success!")<br />
    pageUrl= pageUrl<br />
    dir = MediaContainer(mediaType='items')<br />
    content = XML.ElementFromURL(pageUrl, True)<br />
   <br />
    titles = content.xpath('//div[@class="title"]/a/text() | //div[@class="title titlelong"]/a/text()')<br />
    freeornots = content.xpath('//div[@class="buy"]/a/text()')<br />
    <br />
    #thumb = content.xpath('//div[@class="contentleft_bottom"]/div/div/div[@class="m03img"]')<br />
    #titleUrl = content.xpath('//div[@class="contentleft_bottom"]/div/div/div[@class="m03link"]/a')<br />
    #summary = content.xpath('//div[@class="contentleft_bottom"]/div/div/div[@class="m03text"]') <br />
    #Log(title)<br />
    #Log(titleUrl.text)<br />
    Log(titles) <br />
    atleastoneentry=0<br />
    dir.Append(VideoItem("http://podfiles.zdf.de/podcast/zdf_podcasts/110314_h19_p.mp4", "test"))<br />
    for i in range(len(titles)):<br />
      title=titles*<br />
      if freeornots* == "kostenlos":<br />
      	freeornot=1<br />
      	atleastoneentry = 1<br />
      elif freeornots* != "kostenlos":<br />
      	freeornot=0<br />
      test="test"<br />
      Log(title)<br />
      Log(freeornot)<br />
      if freeornot == 1:<br />
      	dir.Append(Function(DirectoryItem(ItemPage, title), test))<br />
    if atleastoneentry == 0:<br />
		dir.Append(Function(DirectoryItem(ItemPage, "nur kostenpflichtige Sendungen"), test))<br />
    return dir<br />


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.