Getting Attribute Value from RSS FEED

I have the below RSS Feed and I am trying get the attribute value of url for VOD element. How do I use XPATH to get attribute value.



RSS FEED :


<rsp><br />
  <code id="1"><br />
    <vodList><br />
      <vod id="123" title="Video1" url="http://mydomain.com/url1.mp4/><br />
      <vod id="124" title="Video2" url="http://mydomain.com/url2.mp4/><br />
    <vodList><br />
  </code><br />
</rsp>



I have the code written like below and tried different methods. So far no success.

CODE:

for video in XML.ElementFromURL(RSS_FEED).xpath('//vod'):<br />
  url = video.xpath('//vod')[0].get('url')<br />




Please help.

Hi!

A first look shows that the RSS feed is not valid xml, but maybe that happened when pasting the contents of an xml file in here? The closing " is missing on the url attributes. Also the closing tag is wrong (it’s missing a /).



If the xml is valid, the for loop to get the url attribute of all the elements can be written like this:


for video in XML.ElementFromURL(RSS_FEED).xpath('//vod'):<br />
  url = video.get('url')<br />


The XML is copy/pasted. But the original XML is OK. Will check and let you know I am able to get the URL value using your suggestion. Thanks for the reply.

I was able to parse the XML and able to get the details. But I have the final media link available with in the XML. If I assign the url from xml to url of VideoClipObject then the plug in won’t list the items. I think it needs a web page link than the final media link.



I do not wish to write ServiceCode.pys as the media link available in XML Feed. Is there any alternative for this.



thanks in advance.

Hi!

If you set the url attribute of a VideoClipObject, it expects a URL Service. If you don’t need or want that, you can write it like this (just put your for-loop around the oc.add(…)).

Will try and let you know. This is exactly what I am looking for. Thanks.

I was able to parse and load the channel using Plex Client. I am able to play the videos using Plex. But When I try to access the same using Roku, I can navigate till the episode and play list of episodes, but no option to get Play link. I have List and InfoList groups created with in the plex channel. In List group I have different episodes and with in InfoList group I have the play list of that episode.



Do I need to add one more group view in plex channel to list the details of each play list of an episode in order to play them on ROKU ?



Please advise.



thanks.

Hi!

Viewgroups shouldn’t matter at all here. Can I have a look at your code?

oc.add(

VideoClipObject(

title = title,

summary = title +’ @ '+summary,

rating_key = id,

thumb = Function(Thumb, url=thumb),

key = id,

items = [MediaObject(parts=[PartObject(key=video_url)])]

)

)

Looks good to me! Just one thing I noticed: is the right attribute name for video_url ‘urls’, with the ‘s’ at the end?


video_url = video.get('urls')


In the sample XML you gave it was 'url', without the 's':

video_url = video.get('url')



**Edit:** Found one more thing. This:

thumb = Function(Thumb, url=thumb),


should be:

thumb = Callback(Thumb, url=thumb),

Yes, It is URLS only. I typed wrong in my first post. Even with Function it loads the thumbs on both Plex and Roku.



I think the issue is Roku - Plex Client will add Play Buttons only if it is a Clip or Episode. I changed the code to display the videoClip as one more layer. Will test it with the changes.



thank you for all your help so far.

If I assign a numeric value to key in videoClipObject then ROKU is playing other wise it is trying make URL connection and hanging there.



Now I can play the channel as I expected.



BTW, How to get TODAY’s date in PLEX ?



I need Today’s date in String format. (MM/DD/YYYY) format.

oc.add(

VideoClipObject(

title = title,

summary = title +’ @ '+summary,

rating_key = id,

thumb = Function(Thumb, url=thumb),

key = id,

items = [MediaObject(parts=[PartObject(key=video_url)])]

)

)





I made changes like above. ID is a unique id from my RSS Feed. Now the channel works in Roku as well.

Hi Sander1,



I was able to create my own channels now in Plex and have it work on my ROKU. They all function fully as expected.



I appriciate all your help.



regards

Ramesh

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