nprapps / roku-tinydesk

Tiny Desk Concerts Roku app
http://www.npr.org/series/tiny-desk-concerts/
Other
30 stars 5 forks source link

Copyright 2013 NPR. All rights reserved. No part of these materials may be reproduced, modified, stored in a retrieval system, or retransmitted, in any form or by any means, electronic, mechanical or otherwise, without prior written permission from NPR.

(Want to use this code? Send an email to nprapps@npr.org!)

Tiny Desk Concerts Roku app

Setup

Put your Roku into Dev Mode.

Your Roku will tell you its IP address and have you set a developer password. Set these in your .bash_profile:

export ROKU_IP="10.0.1.2"
export ROKU_PASSWORD="mypassword"

Install the Python requirements:

$ mkvirtualenv roku-tinydesk
$ pip install requirements.txt

Generate JSON feed

This step is not necessary to run the app.

To regenerate the API feed you will need a superuser NPR API key and our AWS keys. Set the API key in your .bash_profile like so:

export NPR_API_KEY="SUPERUSER_KEY_HERE"

Install s3cmd and configure it with the nprapps AWS keys:

$ s3cmd --configure

To generate (and deploy) the Tiny Desk API feed:

$ workon roku-tinydesk
$ ./update_feed.py

Package & Deploy

To package up the code and deploy it to your Roku:

$ ./install.sh

Enjoy!

Distribute the app

Note: If this process isn't completed with Chris' Roku keys, users of the app will lose their registry data. The way around this is to "rekey" each developer's Roku with the same RSA key. Read more here:

http://sdkdocs.roku.com/display/RokuSDKv48/Channel+Packaging+And+Publishing#ChannelPackagingAndPublishing-30PackagingApplications

Note part 2: This is probably irrelevant anyway, because you would need Chris' Roku credentials to access the upload page. Ergo, these docs are really just for him.

Distributing the app to Roku requires jumping through additional hoops. First, you'll need to generate crypotgraphic keys on your Roku. Do this like so:

$ telnet $ROKU_IP 8080
> genkey

Your password will be print out: save it. Exit the telnet session by typing quit.

Add this new password to your ~/.bash_profile:

export ROKU_GENKEY_PASSWORD="YOUR_PASSWORD_HERE"

Now to generate a shippable zip, simply run:

$ ./ship.sh 1.0

You must supply a version number as the first argument.

Now take your new package and upload it at: https://owner.roku.com/Developer/Apps/Packages/23962

Debugging

To connect to your Roku for debugging:

$ telnet $ROKU_IP 8085

Google Analytics

The following events are tracked in Google Analytics:

Category Action Label Value Custom 1 Custom 2
Tiny Desk Startup rokuModel rokuFirmware
Tiny Desk Shutdown sessionDuration numWatched numFinished
Tiny Desk Start title fromList searchTerm
Tiny Desk Continue title fromList searchTerm
Tiny Desk Finish title
Tiny Desk Stop title playtime stoppedAtPct
Tiny Desk Search term
Tiny Desk Feed Unavailable
Tiny Desk Completion percent

Notes:

Code conventions

Because Roku dev lacks strong (or any) code conventions, I'm defining my own.

Syntax

All rules for function names also apply when calling case-insensitive built-in functions, e.g. createObject() and count().

Code organization

Leave a line of whitespace after function and before end function

Never use sub. Always use function.

Classes

In class constructors define the class object as this. In member functions redefine the class object as this = m. Never use m to refer to the global namespace.

Comments

Comments describing a functions purpose should precede the function defintion.

Modules should begin with a block comment explaning their purpose:

'
' Explainer goes here
'

function main()
    blah blah