RTMP Stream (ABC iView)

Hi All

 

Im very new when it come to Plex and Python in general but I have a lot of other coding experience, I recently decided to give creating a Plex channel a try. Im working on a channel for ABC iView, so far its going very well I have been able to parse all the media info and display it however when it comes to actually playing the video im a bit stumped...

 

I have been googling and searching these forums for a while now with not luck...

 

Here is the code I have been used to test playback..

     oc.add(VideoClipObject(key = RTMPVideoURL(url = 'rtmp://cp53909.edgefcs.net/ondemand?auth=daEcrdpc8acdcbrdAa8avdpa5bGd3c8dQbB-brz_kl-8-qnq_rEtqH&aifp=v001', clip = 'mp4:flash/playback/_definst_/kids/bobbuilder_13_12', swfurl = 'http://www.abc.net.au/iview/images/iview.jpg' swfvfy = True), rating_key = '123',title = 'TEST'))

Im not sure what the rating_key is but without it I get an error in the logs...

AttributeException: If no URL is provided, the key and rating_key attributes must be set.

now the videos seems to start playing but its like it can't connect or something as I get black screen with the following message....

201: unable to load stream or clip file

If I change the url to something that i know is broken (eg rtmp://some.fake.address ) it doesnt even get that far so its like its connecting to the server ok but not finding the correct video.

 

After even more digging around I found a plugin that already worked! .... but it was for XBMC so after doing some more digging I found that the XMBC plugin used the following code to display the video....

rtmp_url = "%s?auth=%s playpath=%s swfurl=%s swfvfy=true" % (auth['rtmp_url'], auth['token'], playpath, config.swf_url)

    
        xbmc.Player().play(rtmp_url, listitem)

When checking the logs I found its using the following url...

rtmp://cp53909.edgefcs.net/ondemand?auth=daEcrdpc8acdcbrdAa8avdpa5bGd3c8dQbB-brz_kl-8-qnq_rEtqH&aifp=v001 playpath=mp4:flash/playback/_definst_/kids/bobbuilder_13_12 swfurl=http://www.abc.net.au/iview/images/iview.jpg swfvfy=true

So i know the URL is valid and works its just that either im passing it to plex in the wrong format (which i suspect is the case) or Plex handles RTMP feed differently

 
 
Any help on this is very much appreciated!
 
I have some plans to make a few more plugin for plex, but i want to get this sorted out first :)
 
Sorry for the length of this post but as you can tell I have been looking into this for a while now and im hoping its something simple that I have missed!
 
cheers!

I'm sort of having the same issue. Documentation on this is basically non-existent but I at least managed to get my code to run on desktop clients but I I think the method I used to do this is deprecated now.

I want to rewrite my entire plugin so it will work on all devices.

You can check my code here: https://github.com/drzoidberg33/SuperSport.bundle/blob/master/Contents/Code/__init__.py

Maybe something in there can help you out and it would be great if a seasoned pro could stop by and hand us a few pointers :)

I moved this topic to the Channel Development forum because I think you're more likely to catch the eyes of the folks actually working with channel coding.

Your code looks decent. My only comments initially are that;

1. the rating_key is intended to be some unique string to identify a video from a different video. Often, it can be set to the UID or PID that the content provider uses to identify the videos.

2. I have trouble believing that you have the correct swf_url. Not having access to the site or the streams, I can't confirm but, it seems strange that the swf would link to a .jpg file. If that's what the XBMC plugin uses and it works, I guess it's possible but I would suggest doing a little more digging for a better swf url.

What Mike says, the swf url value seems a bit weird. Looking at the website, I think the value should be:

http://www.abc.net.au/iview/iview_383.swf

The name of the parameter is also wrong, it has to be swf_url (not swfurl).

There's also a comma missing before swfvfy, but you an leave out that parameter altogether.

When using rtmp streams this way, you need to add a special key/value pair to the Info.plist file, so that PMS will use librtmp. If this key/value is missing, PMS will try to load the streams in a Flash player (that's where the "201: unable to load stream or clip file" error is coming from).

Add this to your Info.plist (the Info.plist of your plugin as well as ServiceInfo.plist is you're using URL Services):

    PlexFrameworkFlags
    
        UseRealRTMP
    

(Example: https://github.com/plexinc-plugins/CBS.bundle/blob/master/Contents/Info.plist#L17)

Are you testing with a hard coded auth token? That could also cause problems, because those tokens usually expire quickly after being generated.

wow! thanks guys for the quick reply!

I got it working! 

It was a combination of syntax and the missing setting in the info file :)

here is the code....

        oc.add(VideoClipObject(key = RTMPVideoURL(url = 'rtmp://cp53909.edgefcs.net/ondemand?auth=', clip = 'mp4:flash/playback/_definst_/kids/bobbuilder_13_12', swf_url = 'http://www.abc.net.au/iview/images/iview.jpg'), rating_key = '123',title = '123'))

you obviously need to add in the auth token, which bring me to my next problem....

You are right about the auth key needing to be dynamic, however at the time I was just getting the key manually and pasting it when ever i needed to test. I just wanted to make sure the stream was going to play before making the plugin actually work.

Now I didnt think getting the key was going to be hard as its just contained in an XML file which i have read config from before, but the normal XML parser doesnt seem to be working...

This is the code im using to try and read the token...

def GetAuthToken():
  xml = XML.ElementFromURL('http://tviview.abc.net.au/iview/auth/?v2')
  return xml.xpath('//iview[0]/token')

This is the XML file im trying to read from...

<?xml version="1.0" encoding="utf-8"?>

1.1.1.1
Telstra
Telstra
Akamai
rtmp://cp53909.edgefcs.net/ondemand
rtmp://cp44823.edgefcs.net/ondemand
daEauaCbjatdhard6cKaPa3bGcbc8cldJaM-brAsOh-8-jkt_AEAqM&aifp=v001
st=1365846535~exp=1365856534~acl=/*~hmac=1c3500a92fe1aeccbf420b1ac6702d4dad49801e8882348f496a2d32f8b62e37

no

now again knowing that the XBMC plugin was working I took another look and found they are parsing the XML using something called "BeautifulSoup"   
 

I have tried doing an easy_install of this module without success and also tried to place the BeautifulSoup.py into the same dir and my code and calling it from there without any luck.

Has anyone ever used this BeautifulSoup thing before? im not keen on including it if it means that anyone using the plugin also has to install this separately.

once again your help is much appreciated :)

This is the code im using to try and read the token...

 

def GetAuthToken():
 
xml = XML.ElementFromURL('http://tviview.abc.n.../iview/auth/?v2')
 
return xml.xpath('//iview[0]/token')

I haven't tried it myself but I think it should work with:

return xml.xpath('//iview[0]//token//text()')

If it doesn't work, try adding this log call to find out all item names:

Log(xml.xpath("//*[name()]"))

Hi!

The XML file uses an "anonymous namespace" (besides 2 others -- xsd and xsi). You can name the anonymous namespace, we usually use "a" (for "anonymous") for this. You can then use that namespace after you declare it in the xpath, like so:

def GetAuthToken():
  xml = XML.ElementFromURL('http://tviview.abc.net.au/iview/auth/?v2')
  return xml.xpath('//a:token', namespaces={'a': 'http://www.abc.net.au/iView/Services/iViewHandshaker'})

No need to import BeautifulSoup :rolleyes:

getting closer....

I get the following error in the logs when I try the above code

TypeError:  is not JSON serializable

 

When i do a curl on the url it tells me its moved but doesnt give me an address...

also I tried 

Log(xml.xpath("//*[name()]"))
 

but nothing got sent to the logs. I asume its because of the above namespace issue 

Im working on a backup solution involving regex but my preferred solution is to get the XML parser work

Thanks for everyone's help with this, its much appreciated  :)

Whoops, my bad, sorry! I forgot text() and [0]

def GetAuthToken():
  xml = XML.ElementFromURL('http://tviview.abc.net.au/iview/auth/?v2')
  return xml.xpath('//a:token/text()', namespaces={'a': 'http://www.abc.net.au/iView/Services/iViewHandshaker'})[0]

YAY!!!! IT WORKS!!

Thanks for everyone help with this :)

Hopefully I can now pull all the bits together and get the plugin out within the next week or so :)

If not ill at least post the source code, as if it doesnt happen in the next week it might be a while as im going to be very busy after that and dont know how much time ill get to work on it

I have plans to do all the Australian TV Catchup channels in the future but this is my first time using python so its a bit slow going :P

Thanks again and keep up the good work :)

In case anyone comes looking for this....

https://github.com/kyleh0000/PlexABCiView

There are still a few things to be done in the GUI, but everything seems to be working as far as I can tell :)

Thanks again everyone!

In case anyone comes looking for this....

https://github.com/kyleh0000/PlexABCiView

There are still a few things to be done in the GUI, but everything seems to be working as far as I can tell :)

Thanks again everyone!

Nice work, will try it out! Tried the existing iView channel but it doesn't seem to work anymore, so great that there is another option.

Does it work in Plex/Web?

It does not unfortunately, simply due to the fact it uses rtmp steams which can’t be transcoded and can only be played in the osx version of the client


Sorry :frowning:

That’s not necessarily true. PMS is capable transcoding RTMP streams as long as 1.) the feed is not “live”, and 2.) the video content of the stream is not encrypted. As long as the “UseRealRTMP” flag is set in the channel’s Info.plist (and ServiceInfo.plist if using a URL service), the video should be transcoded for other clients.


(null)

WELL DONE!!!

EXCELLENT WORK.

It'll look and operate great once all finished.

Thanks for making Plex a greater experience for us Aussies :)

In case anyone comes looking for this....

https://github.com/kyleh0000/PlexABCiView

There are still a few things to be done in the GUI, but everything seems to be working as far as I can tell :)

Thanks again everyone!

signed up to the forum just to say thanks for developing this plugin - greatly appreciated!

That's not necessarily true. PMS is capable transcoding RTMP streams as long as 1.) the feed is not "live", and 2.) the video content of the stream is not encrypted. As long as the "UseRealRTMP" flag is set in the channel's Info.plist (and ServiceInfo.plist if using a URL service), the video should be transcoded for other clients.

(null)

Really? awesome I did not know that!

My plugin doesnt seem to work for anything but OSX Plex Client I have set the UseRealRTMP flag in the info file and I dont think its a live stream, but could be wrong.

It would be great to get it working on other clients but thats something ill look into more down the trak

cheers!

It would be great to get it working on other clients but thats something ill look into more down the trak

I just sent you a pull request on Github with some changes that I think *should* make playback work in non desktop clients.