Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jgatcomb
Visitor

First Project Too Big Too Fast?

Brief Background: I have been programming for well over a decade in a variety of languages. I bought my first Roku on Black Friday 2012 and now have one for every TV. About 2 months ago, I taught myself how to write PlayOn scripts using Lua. This was extremely trivial and when I ran into any problems that I couldn't handle, I augmented things with Perl. I took a short vacation from work and decided to teach myself how to bypass PlayOn all together and write a Roku channel directly.

Problem: I haven't found a tutorial that works for me (I realize I am probably the problem). They all seem to be a brief introduction to static video files. I also didn't really find the examples in the SDK all that helpful though I am sure I will once I understand more. Ultimately, I am looking for something along the lines of: "Here is how you fetch a web page and store the source in a variable. Here is how you parse the HTML looking for links to videos (along with the meta data such as title, description, length, etc). Here is how you present that video to the user. Here is how you stream that video along with caveats if the video is flash not mp4"

Project:

One of the first projects I did for PlayOn was WeatherNation which is one I attempted to duplicate as a Roku Channel. Since I didn't have a firm grasp of Lua at the time, I had to augment with Perl so the links point to my server (which dynamically embeds a flash video from WeatherNation) and I use URL parameters to determine which video to play (Live, NorthEast, MidWest, etc). I am providing the PlayOn code below to demonstrate how simple it was.


--[[Settings
name = "Weather Nation PlayOn Plugin";
id = "WNPlugin";
description = "Brings http://weathernationtv.com to PlayOn";
version = 2.0.0;
EndSettings]]--

--[[Update
return nil;
EndUpdate]]--

--[[Director
function director:GetPlayerViewingRectangle(playerSize)
return Rectangle(0, 0, playerSize.Width, playerSize.Height - 30);
end;

EndDirector]]--

function wn_resolve(url)
_SPECIAL_resolve_xml = '<media><url type="flash">'..str_html_encode(url)..'</url><options><AudioAbortInterval>30</AudioAbortInterval><VideoAbortInterval>30</VideoAbortInterval></options></media>';
end

function main_menu()
_vr(
"Live",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_dfl9c83f')",
"Live weather from across the country",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Top Of The Hour",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_ke7byih4')",
"Weather from across the country updated at the top of the hour",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Half Past The Hour",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_z3ubehea')",
"Weather from across the country updated half past the hour",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Northeast",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_bc372mi8')",
"Weather from the northeast region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Mid Atlantic",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_vb6g4lm8')",
"Weather from the mid-atlantic region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Southeast",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_9uudtw6g')",
"Weather from the southeast region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Midwest",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_2vq1g74u')",
"Weather from the midwest region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Central Plains",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_lz21fuon')",
"Weather from the central plains region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Southern",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_nxtsjh2i')",
"Weather from the southern region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Northwest",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_x2kxrpgt')",
"Weather from the northwest region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
_vr(
"Southwest",
"code:wn_resolve('http://216.224.180.204:5150/weather.html?id=1_tj6qkfic')",
"Weather from the southwest region",
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash4/c135.55.691.691/s160x160/427692_10150720904089874_1019916183_n.jpg",
0
);
end

main_menu();


Questions:

1. Can anyone point me to a tutorial more along the lines of what I am looking for?

2. If no such tutorial exists, can someone show me how to do the same thing as the code above as a channel?


I realize number 2 is a lot to ask. All I can do in return is promise that once I come up to speed, I will be a fruitful contributor to the community.

Cheers,
Joshua
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

Re: First Project Too Big Too Fast?

I'm no expert but I think you're asking too much of the roku platform. Re (1) You'd want to do all that stuff on a server using a technology that's suited for doing it (there are many, of which to my knowledge, roku Brightscript is not really one) and then serve it up in a way that works well with roku / the XML generated to work with your channel as per the videoplayer example.
I hope this helps?
cheers
aspiring
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: First Project Too Big Too Fast?

All the things you describe can be done in BrightScript. HTML scraping is not a typical use though, normally your channel would talk to an API to get all the necessary data as XML or JSON and your BrightScript would parse that data into the structures necessary to make your channel behave as desired.

"jgatcomb" wrote:
Here is how you fetch a web page and store the source in a variable.


roURLTransfer http://sdkdocs.roku.com/display/RokuSDK ... rlTransfer

"jgatcomb" wrote:
Here is how you parse the HTML looking for links to videos (along with the meta data such as title, description, length, etc).


If the HTML is well formed XML, which is almost never true, use roXMLElement http://sdkdocs.roku.com/display/RokuSDKv48/roXMLElement
Otherwise you could experiment with roRegEx http://sdkdocs.roku.com/display/RokuSDKv48/roRegex

"jgatcomb" wrote:
Here is how you present that video to the user.


roVideoScreen http://sdkdocs.roku.com/display/RokuSDK ... ideoScreen
0 Kudos
destruk
Streaming Star

Re: First Project Too Big Too Fast?

Why is it every week someone has to advertise that you can pay for pirated content on roku using PlayOn? Doesn't having to pay for something entirely defeat the purpose of pirating it?
In the case of weathernationtv.com -
Restrictions on Use.
a. You shall Use the Services for lawful purposes only.
b. No Services or content may be downloaded, copied, modified, reproduced, distributed, transmitted, broadcast, displayed, linked, framed, sold, licensed or otherwise exploited for any other purposes what so ever without prior written consent of WNTV.
e. Except for user content posted by you, you may not copy, modify, translate, publish, broadcast, transmit, distribute, display, trade, share or sell any content appearing on Weathernationtv.com. You acknowledge and agree that all content on Weathernationtv.com, including without limitation, the text, software, scripts, graphics, photos, sounds, music, videos, interactive features and the trademarks, service marks, copyrights and logos associated with such Services (with the exception of user content), is protected under federal, state and international trademark and copyright laws and/or statutory and common laws and that all times the ownership in such trademarks and copyrights shall remain the sole property of WNTV, its affiliates, their licensors, or other parties, as applicable.

Sounds like your created roku channel violates their terms laid out on their website here to me:
http://weathernationtv.com/Terms
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.