Playing files from HTML server

Hi,

 

I've been reading into developing a simple plugin for plex and I can't really get started.

The few examples and tutorials I've found didn't really help me much.

 

What I want is a plugin which reads a HTML directory and can play all the files (all are mp4 coded) found there. Could someone please point me to a simple example where I can see how this would be done?

 

Getting metadata information, menu hierachy and such can be done later. For now I just want to play files from a html server.

 

 

As I understand do I need to define a URLService in the Info.plist.

I don't really see where this service is used in the __init__.py.

 

In the __init__.py all magic happens: the menus get created and filled with the links to the video files.

Is that correct? I'd be glad for any help and am sorry if I missed somethign curcial in the documentation.

 

If all the files are presented on one page, then an url service is not the best approach. If the files are contained within separate sub-directories, then an url service could prove quite useful. Probably best if you include some sample HTML, either real or made-up but representative.

Update:

The problem is now that the URL service is not found.

DEBUG (services:602) - No service found for URL [...]
DEBUG (services:617) - No matching services found for [...]

here's what I have so far:

Files:

/Contents/info.plist; DefaultPrefs.json

   /Code/__init__.py

   /URL Services/30C3/ServiceCode.pys

   /Resources/art-default.jpg; icon-default.jpg

Code:

see files, here just the url service stuff.

Info.plist

[...]
PlexURLServices

   30C3
   
      URLPattern
      http://(.*)/congress/2013/mp4/
      Identifier
      com.plexapp.plugins.30c3-mp4
      TestURLs
      
        http://cdn.media.ccc.de/congress/2013/mp4/30c3-5185-en-FPGA_101_h264-hq.mp4
        http://141.70.0.13/congress/2013/mp4/30c3-5290-en-Console_Hacking_2013_h264-hq.mp4
     
   

[...]

ServiceCode.pys

def MetadataObjectForURL(url):
 
   page = HTML.ElementFromURL(url)
 
   return VideoClipObject(
      title = 'title',
      summary = 'description'
   )
 
def MediaObjectsForURL(url):
   return [
      MediaObject(
         video_codec = VideoCodec.H264,
         audio_codec = AudioCodec.AAC,
         video_resolution = '720',
         audio_channels = 2,
         container = 'mp4',
      )
   ]

any hints are greatly appreciated

The files do lie in a flat directory. how could this be done without an url service?

in future i might want to add other directories of that server. would it be helpful to use url services for that?

You have to create a ServiceInfo.plist that tells it to look for the URL Service named 30C3 and give it the pattern of the URLs that will be passed to it. 

You are using the Info.plist but that should just be for the basics about your channel and the clients it supports. The Framework Documentation is out of date in this area. It is noted here in the this pinned Missing From Framework document - https://forums.plex.tv/topic/87324-missing-from-the-official-plugin-documentation/ (click the link to see the full document)

Here is a template for the ServiceInfo.plist - https://forums.plex.tv/topic/62610-channel-development-templates/?p=393464. That page also has an Info.plist with all the current options for it as well.

The file folder structure is a little off too. Instead of URLService, it should be called Services and contain a folder called URL that contains the ServiceInfo.plist and the folder called 30C3.

Here is link to an example of a channel that still has a URL service directly connected to it. It may not be that similar to your particular projec, but it does show you the file folder structure and the basic structure of the files themselves.

https://github.com/meriko/LinkTV.bundle

thanks a lot .. i'll look into it

i've fixed the folder structure and this should be correct now.

also did i create a ServiceInfo.plist but i still get the "No service found for URL" error.

could it be that my example is just too basic and the i miss to set some reference or the like?

Usually if it says it cannot find a URL service once you have all the files and folders in place, then either you haven't rebooted Plex so it will recognize your plugin properly or the regex you used for your URL pattern is not correct, so Plex is unable to find a Service with a pattern that matches the URL you are trying to process.

it was indeed the regex. my guess was that i only needed to specify the domain, but the entire link is needed.

now i'm on to the next error ;)

"Error when attempting to normalize URL 'http://141.70.0.13/congress/2013/mp4/30c3-5185-en-FPGA_101_h264-hq.mp4' (most recent call last):"

with

def NormalizeURL(url):
    return url

(yes, it doesn't do anything. but it should work, shouldn't it)

i'll try to figure sth out

A URL Service is used to transform a non-video URL into a metadata object and a media object.

IN:                                                          OUT:
http://www.example.com/unique_url.html ---> URL Service ---> [metadata] title/summary/thumbnail/etc.
                                                        ---> [media]    container/video codec/audio codec/resolution/etc.

A URL Service cannot work with a list of videos all on one page (because the input URL is not unique for 1 video). But a channel/plugin can work without a URL Service. Attached to this post is an example of how this CCC channel could work.

Edit: There's a bug in the Plex for Home Theater client where the details screen (the screen you see before you play a video) is blank if we're not using a URL Service.

wooo ... i'm flashed .. copy, past, works. great! thanks!

now i'll start parsing metadata and organising that stuff.

so i don't need services after all. the documentation seem a little confusing to me :/

thanks for the edit.

i'll target the webclient / xml output right now. but it's good to know.

would u care if i put your code with my changes/additions into a public git?

thanks for the edit.

i'll target the webclient / xml output right now. but it's good to know.

would u care if i put your code with my changes/additions into a public git?

Hi! No problem, go ahead :)

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