NBCSports.com Channel Feedback and Help

Hi everyone, longtime developer but new to Plex and new to Python. Been fumbling my way through the docs, forums and github trying to piece something together.

 

I’ve developed a channel for nbcsports.com/video but have a few questions. If you’re interested you can see the code here: https://github.com/datvance/NBCSports.bundle

 

The channel works for me on Roku and Plex/web but not PHT on OSX. Even though it works, the videos (especially longer ones) buffer quite a bit and not sure if that’s something I’m doing/not doing. I grab a SMIL file, but not the one with all the different bitrates, etc. Depending on the query string parameters you pass to the SMIL URL you can get different files. Right now I just use a basic one and grab the direct .mp4 link to the video.

 

So it doesn’t use a URL Service, and instead uses the method described here:

https://forums.plexapp.com/index.php/topic/78852-can-i-directly-play-an-url-without-having-a-service-file/

 

There’s a Services branch in the repo with my attempt at a service. Not sure why it’s not working though.

 

I guess my questions are these:

 

1. Why shouldn’t it work on PHT? It’s just a direct link to an .mp4.

 

2. Are the docs up to date? For instance, on the URL Service page it says all you have to do to define a service is add a block to the Info.plist, but all the examples in the Services.bundle on github and the forums use a ServiceInfo.plist file.

http://dev.plexapp.com/docs/channels/services/url.html

https://forums.plexapp.com/index.php/topic/62610-channel-development-templates/

 

3. Because of the way nbcsports.com is structured, I don’t see how I can implement a URL Service that would work with e.g. PlexIt. The video is loaded in an iframe through ajax, so just doing a request on the page URL wouldn’t return any useful data about the current video being played e.g. http://nbcsports.com/video could be showing any video (loaded in the iframe though ajax). Any ideas? The iframe player URL is the useful URL, but I can’t expect the user to find that and plexit.

 

4. It can be quite slow (and time out) when parsing the html. Any tips for speed-up?

 

Thanks.



Hi everyone, longtime developer but new to Plex and new to Python. Been fumbling my way through the docs, forums and github trying to piece something together.

Hi and welcome to the world of Plex channel developement.

I guess my questions are these:

 

1. Why shouldn’t it work on PHT? It’s just a direct link to an .mp4.

Off the top of my head, I can't think of a good reason why PHT would fail. I would suggest checking the "Plex Home Theater.log" for errors related to the playback attempt. It's possible that NBC's servers are rejecting the user-agent header that PHT sends for the request. That's just a guess. Concrete errors will be much more helpful in debugging.

2. Are the docs up to date? For instance, on the URL Service page it says all you have to do to define a service is add a block to the Info.plist, but all the examples in the Services.bundle on github and the forums use a ServiceInfo.plist file.

Sadly, they are not. There's now a sticky post at the top of this forum with a link to some known short-comings in the documentation. The proper formatting for Services within channel bundles should probably be added to that list. In the mean time, take a look at how the NHL channel is set up. It uses an URL Service contained within the channel bundle, in a "Services" folder within the main "Contents" folder. The ServiceInfo.plist file is where the URL Service is defined.

 

 

3. Because of the way nbcsports.com is structured, I don’t see how I can implement a URL Service that would work with e.g. PlexIt. The video is loaded in an iframe through ajax, so just doing a request on the page URL wouldn’t return any useful data about the current video being played e.g. http://nbcsports.com/video could be showing any video (loaded in the iframe though ajax). Any ideas? The iframe player URL is the useful URL, but I can’t expect the user to find that and plexit.

PlexIt is definitely the most visible use of URL Services. I would tend to agree that your scenario does not lend itself to the sort of use case for which the bookmarklet is designed.  There are other less obvious ways in which URL Services are used but TBH, I'm not really sure whether your scenario fits with those either. In any event, if you've got it (mostly) working without a URL Service, you can always go back and do some restructuring to add a URL Service later on.

 

 

4. It can be quite slow (and time out) when parsing the html. Any tips for speed-up?

Looks like you're making an HTTP request for the SMIL for each video in the directory as the directory loads. That will definitely slow things down. Ideally, you shouldn't need to make any extra requests when building the directory. If it's possible to parse the summary and duration data from the main list I would recommend that. If not, you're better off leaving that metadata out of the initial listing. That data will be returned via the CreateVideoClipObject() method when clients request more info or populate the pre-play screen. That way, the extra request is only made for the single item just prior to playback rather than for every item before loading the menu structure.

 

 

Thanks.

Always feel free to ask lots of questions. That's how most of us got started.

Thanks a lot for the reply.

I tried to remove the http calls when building the directory, but as far as i can tell, the roku client requires a full metadata object in the directory listing page or it won't play the video. Maybe I'm just missing something but I spent a lot of time trying to get it to work. Creating a VideoClipObject with just title and thumb, and only pulling the video details on the info page works in the Web client, but not the roku client. (I can't get anything to work with the PHT.) So I added a little caching of the info, which speeds it up a couple hundred ms per video after first load. Not much but with a dozen videos it's noticeable.

I must say, Channel development with PLex is a pretty frustrating experience, but again thanks for the help. Any thought to open sourcing the dev docs? Put them up on github and we could all contribute and bring them up to date. Maybe include a channel template starter kit to make getting started quicker.

Regards.

I am working on updating the template for ServiceInfo.plist (this one gives you a basic example - https://forums.plexapp.com/index.php/topic/62610-channel-development-templates/?p=393464) But I wanted to make one that gives all the options like the Info.plist gives for channels here https://forums.plexapp.com/index.php/topic/62610-channel-development-templates/?p=365280.

The plist being combined in the documentation is noted here (Scroll to the end): https://docs.google.com/document/d/1MyhhTsg5xdDD5LRbOZ5x5QxkmEyXv6rB-22Z7tdpy34/edit?pli=1. That is why I was going to make a new version and link it into that document.

If you want an example of a channel without a URL service that builds the MediaObject separate without pulling any of the metadata in that function this RSS Feed is a good basic example. The only thing it does within the CreateObject function is look at the URL structure, so it is not pulling any data from the page in that function. And it works with Roku. https://github.com/shopgirl284/RSSFeed.bundle/blob/master/Contents/Code/__init__.py#L211. This example doesn't have a URL service, because it is pulling from a lot of different sites, and the user can add any site they want as long as the page fits a particular xml page structure, so there is no URL pattern that can be determined.

I tend to think it is better to create a URL service if you can. And let me preface my argument for a URL service by saying I am in no way an expert. Actually it is quite the opposite. I hate writing a URL service and still do not feel like I truly grasp all the ins and outs of them. Mike knows so much more about this than me and I still constantly ask him questions about the URL service.

But as annoying as a URL service is to create and figure out, at least once you get the basics and what all the parts are supposed to be doing,  you realize writing a separate URL service and separating it into all of its functions makes it easier to focus on the hard parts and find any problem easier. Or at least it does for me.

First, since all it does is play the video, it lets you tests the process of playing your video and knowing it works in a completely separate and independent program from all the other issues you may find when writing your channel code. So you know you have the hardest part done (getting the video to play) before you start writing the __init__.py.

And it breaks all the parts of the URL service into specialized functions, so it makes it easier to keep all the parts separated and make sure each part is doing what it should.  The PlayVideo function, where you actually pull and manipulate the files to produce the video is still doing most of the work and the hardest part to get working, but it is easier when you can focus on that one function because you know all the other functions are working.

It also helps me to follow some of the unspoken "rules" when I know what should or shouldn't be done in each of those functions of the URL service, like not pulling any extra data in your MediaObjectforURL function (where you create a MediaObject). And different clients seem to process the URL service different ways, but having everything separated into functions in the URL service seems to make less likely to cause errors on the different clients or at least easier to find where it is causing and error.

Even though it is often extra code, being able to break all the parts into simple functions makes it a little easier for me keep it all straight in my head and narrow down where the issues are.

Thanks shopgirl, you've been a big help with your posts elsewhere on the forum.

I did look at the RSS bundle, but I just couldn't get the videos to play on the Roku without the full metadata object and I was tired of messing with it when I already had something that worked. Looking at the XML output of my functions under the different scenarios, i couldn't see any differences when trying to play the video, but I'm sure it was something I overlooked. I wish there was a simple "play(video_url)" function in the api.

BTW, I just updated the template for the ServiceInfo.plist. Hopefully it makes it a little clearer about what goes there versus what should be included in your Info.plist.

https://forums.plexapp.com/index.php/topic/62610-channel-development-templates/?p=393464

hi, is there anything wrong with the channel. there are some sub-channels within NBC Sports channel such as Premier League that throws out error message when I try to access. No problem with channels like NBA or F1.

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