Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

Cant parse feed

I don't know what happend but it worked a minute ago...

I validated the xml but I still keep getting "can't parse feed" message in the telnet and my screen won't load...all the others work fine though.

Here's the linke to the xml "http//"

I used the videoplayer example and made changes to adapt to my needs..
Anyway here's the code..any input would be greatly appreciated cause I'm getting pretty frustrated with it.

'** Video Player Example Application - Show Feed
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.

'** Set up the show feed connection object
'** This feed provides the detailed list of shows for
'** each subcategory (categoryLeaf) in the category
'** category feed. Given a category leaf node for the
'** desired show list, we'll hit the url and get the
'** results.

Function InitShowFeedConnection(category As Object) As Object

if validateParam(category, "roAssociativeArray", "initShowFeedConnection") = false return invalid

conn = CreateObject("roAssociativeArray")
conn.UrlShowFeed = category.feed

conn.Timer = CreateObject("roTimespan")

conn.LoadShowFeed = load_show_feed
conn.ParseShowFeed = parse_show_feed
conn.InitFeedItem = init_show_feed_item

print "created feed connection for " + conn.UrlShowFeed
return conn

End Function

'Initialize a new feed object
Function newShowFeed() As Object

o = CreateObject("roArray", 100, true)
return o

End Function

' Initialize a ShowFeedItem. This sets the default values
' for everything. The data in the actual feed is sometimes
' sparse, so these will be the default values unless they
' are overridden while parsing the actual game data
Function init_show_feed_item() As Object
o = CreateObject("roAssociativeArray")

o.ContentId = ""
o.Title = ""
o.ContentType = ""
o.ContentQuality = ""
o.Synopsis = ""
o.Genre = ""
o.Runtime = ""
o.StreamQualities = CreateObject("roArray", 5, true)
o.StreamBitrates = CreateObject("roArray", 5, true)
o.StreamUrls = CreateObject("roArray", 5, true)

return o
End Function

'** Grab and load a show detail feed. The url we are fetching
'** is specified as part of the category provided during
'** initialization. This feed provides a list of all shows
'** with details for the given category feed.
Function load_show_feed(conn As Object) As Dynamic

if validateParam(conn, "roAssociativeArray", "load_show_feed") = false return invalid

print "url: " + conn.UrlShowFeed
http = NewHttp(conn.UrlShowFeed)

rsp = http.GetToStringWithRetry()
print "Request Time: " + itostr(m.Timer.TotalMilliseconds())

feed = newShowFeed()
if not xml.Parse(rsp) then
print "Can't parse feed"
return feed

if xml.GetName() <> "feed" then
print "no feed tag found"
return feed

if islist(xml.GetBody()) = false then
print "no feed body found"
return feed

m.ParseShowFeed(xml, feed)
print "Show Feed Parse Took : " + itostr(m.Timer.TotalMilliseconds())

return feed

End Function

Function parse_show_feed(xml As Object, feed As Object) As Void

showCount = 0
showList = xml.GetChildElements()

for each curShow in showList

'for now, don't process meta info about the feed size
if curShow.GetName() = "resultLength" or curShow.GetName() = "endIndex" then
goto skipitem

item = init_show_feed_item()

'fetch all values from the xml for the current show
item.hdImg = validstr(curShow@hdImg)
item.sdImg = validstr(curShow@sdImg)
item.ContentId = validstr(curShow.contentId.GetText())
item.Title = validstr(curShow.title.GetText())
item.Description = validstr(curShow.description.GetText())
item.ContentType = validstr(curShow.contentType.GetText())
item.ContentQuality = validstr(curShow.contentQuality.GetText())
item.Synopsis = validstr(curShow.synopsis.GetText())
item.Genre = validstr(curShow.genres.GetText())
item.Runtime = validstr(curShow.runtime.GetText())
item.ImageCount = strtoi(validstr(curShow.ImageCount.GetText()))
item.Url = validstr(curShow.Url.GetText())
item.HDBifUrl = validstr(curShow.hdBifUrl.GetText())
item.SDBifUrl = validstr(curShow.sdBifUrl.GetText())
item.StreamFormat = validstr(curShow.streamFormat.GetText())
if item.StreamFormat = "" then 'set default streamFormat to mp4 if doesn't exist in xml
item.StreamFormat = "mp4"

'map xml attributes into screen specific variables
item.ShortDescriptionLine1 = item.Title
item.ShortDescriptionLine2 = item.Description
item.HDPosterUrl = item.hdImg
item.SDPosterUrl = item.sdImg

item.Length = strtoi(item.Runtime)
item.Categories = CreateObject("roArray", 5, true)
item.Actors = CreateObject("roArray", 5, true)
item.Description = item.Synopsis

'Set Default screen values for items not in feed
item.HDBranded = false
item.IsHD = false
item.StarRating = "0"
item.ContentType = "episode"

'media may be at multiple bitrates, so parse an build arrays
for idx = 0 to 4
e =[idx]
if e <> invalid then
next idx

showCount = showCount + 1



End Function

0 Kudos
5 Replies
Roku Employee
Roku Employee

Re: Cant parse feed

Note that you left the : off after the http in your URL, the XML appears to be valid if I fix that.

- Joel
0 Kudos
Level 7

Re: Cant parse feed

Thank you so much Joel! Smiley Very Happy
0 Kudos
Level 7

Re: Cant parse feed

Hmm, the code is given a feed url from a different xml but I Went to add it to the xml and its already there...The xml was always able to be parsed by my browser but not the roku player for some reason..
But the : has always been there I just didn't type it right when I submitted it to the forum.
0 Kudos
Level 7

Re: Cant parse feed

Print out rsp before you parse it. I suspect it doesn't contain what you think it does.

0 Kudos
Level 7

Re: Cant parse feed

I've a similar issue. My m3u8 streams works well with when they are hosted on s3 but gives "can't parse" error when hosted from other web servers or Google cloud.

Do any body have a solution for this behavior?
0 Kudos