Edit: Added rekey function due to popular demand!
Edit Added lazy replace function
With these scripts you should not have to touch the web interface ever again.
The only function I left out was replace. Edit Added lazy replace function
Replace is just deleting then uploading so I did not see a need to implement it.
If someone needs a replace script just say so and I will crank one out.
Here are the funcitons.
uproku: uploads zip file to roku
delroku: deletes the zip file on the roku.
packageroku: takes a already uploaded zip file and turns it into a package and downloads it.
inspectroku: uploads and inspects a package from your harddrive and gives you relevant info on it.
rekeyroku: uploads a package and load its key
#this is all the current functions.
#this uploads a zip file to the roku
uproku ()
{
if [ "$1" ] && [ "$2" ]; then
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
curl --silent --show-error --user-agent "$uagent" --form archive=@$1 --form "mysubmit=Replace" "http://$2/plugin_install" |grep "Application Received:"|tr '>' '\n'|tail -n 1 ;
echo "size on disk is $(ls -alb $1 |awk '{ print $5 }') bytes ";
else
echo -e "this willupload a zip to a roku, you inputed too few arguments format is\nuproku zipname IPaddress_of_ROKU ";
fi
}
#this deletes a zip file from the roku
delroku ()
{
if [ "$1" ]; then
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
curl --silent --show-error --user-agent "$uagent" --form "archive=" --form 'mysubmit=Delete' "http://$1/plugin_install" |grep Delete|tr '>' '\n'|tail -n 1 ;
else
echo -e "this program will delete a zip from the roku, you inputed two few arguments format is\nuproku zipname IPaddress_of_ROKU ";
fi
}
#lazy replace function uses same parameters as uproku in the same order.
replaceroku ()
{
delroku "$2" ;
uproku "$1" "$2" ;
}
#this takes an already uploaded zip file on the roku and converts it into a package then downloads the package to the current directory.
packageroku ()
{
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
ftime=$(($(date +'%s')*1000)) ;
if [ "$1" ] && [ "$2" ] && [ "$3" ] && [ ${#1} -lt 32 ]; then
purl=$(curl --silent --show-error --user-agent "$uagent" --form "app_name=$1" --form "passwd=$2" --form "pkg_time=$ftime" --form "mysubmit=Package" "http://$3/plugin_package" |grep "href"|grep -v "plugin_inspect\|plugin_install"|awk -F 'href="' '{ print $2 }'|tr '"' '\n'|head -n1 😉 ;
wget http://$3/$purl ;
else
echo -e "this will take an existing zip file on the roku and turn it into a package, either app name too large or you inputed two few arguments format is\npackageroku appname dev_password IPaddress_of_ROKU ";
fi
}
#this will inspect a already packaged package, it will show various pieces of information about the package.
inspectroku ()
{
if [ "$1" ] && [ "$2" ] && [ "$3" ]; then
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
output=$(curl --silent --show-error --user-agent "$uagent" --form archive=@$1 --form "passwd=$2" --form "mysubmit=Inspect" "http://$3/plugin_inspect") ;
pdate=$(date --date "Jan 1, 1970 00:00:00 +0000 + $(( $(echo $output|awk -F 'Date\\(' '{ print $2 }'| awk -F '\\)' '{ print $1 }')/1000 )) seconds");
echo $output|html2text|tail -n5|sed "s/Creation Date:/Creation Date: $pdate/g" ;
else
echo -e "this program will upload a package and incpect it, you inputed too few arguments format is\ninspectroku packagename dev_password IPaddress_of_ROKU ";
fi
}
#this will upload a package and load its key.
rekeyroku ()
{
if [ "$1" ] && [ "$2" ] && [ "$3" ]; then
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
output=$(curl --silent --show-error --user-agent "$uagent" --form archive=@$1 --form "passwd=$2" --form "mysubmit=Rekey" "http://$3/plugin_inspect") ;
echo $output |awk -F '<font color="red">' '{ print $2 }'|tr '<' '\n'|head -n 1 ;
else
echo -e "this program will upload a package and load its key, you inputed too few arguments format is\nrekeyroku packagename dev_password IPaddress_of_ROKU ";
fi
}
$delroku roku01.local
Delete Succeeded.
$uproku videoplayer.zip roku01.local
Application Received: 127030 bytes stored.
size on disk is 127030 bytes
$packageroku 'sample video player' 'your_dev_password' roku01.local
--2011-04-29 13:50:24-- http://roku01.local/pkgs/somepackage.pkg
Resolving roku01.local... 192.168.0.24
Connecting to roku01.local|192.168.0.24|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 130000 (127K) [text/plain]
Saving to: `somepackage.pkg'
100%[==========================================================================================>] 130,000 --.-K/s in 0.02s
2011-04-29 13:50:24 (5.25 MB/s) - `somepackage.pkg' saved [130000/130000]
$ inspectroku somepackage.pkg devpassword roku01.local
App Name: video player
Dev ID: SOME_DEV_ID
Creation Date: Fri Apr 29 16:24:37 EDT 2011
$ rekeyroku somepackage.pkg dev_password roku01.local
Success.
If you make your own private channels, these scripts will allow you to upload your channel from the linux command line or delete the channel from the command line.
I am working towards a kate script to use make to "make" the roku zip package.
and then use uproku to upload the zip file to my roku automatically.
Kate is a KDE text editor I use for modifying brightscript. hopefully they will add brightscript highlighting soon.
These are bash functions, either you can cut and paste them into your current shell or place them in your bashrc.
or you can make a file per function called the name of the function.
for instance to make uproku into a standalone program create a file called uproku and populate it with text below.
#/bin/bash
uproku ()
{
if [ "$1" ] && [ "$2" ]; then
uagent='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
curl --silent --show-error --user-agent "$uagent" --form archive=@$1 --form "mysubmit=Replace" "http://$2/plugin_install" |grep "Application Received:"|tr '>' '\n'|tail -n 1 ;
echo "size on disk is $(ls -alb $1 |awk '{ print $5 }') bytes ";
else
echo -e "this willupload a zip to a roku, you inputed too few arguments format is\nuproku zipname IPaddress_of_ROKU ";
fi
}
uproku "$1" "$2";
in the example above you will notice that the function has the same name as the filename of the script. this works because the function will get executed before the local file(except the first time you run the file when the function is not defined yet)..
also you will notice he last line uproku "$1" "$2"; if you were doing a script with three parameters like packageroku the last line would be.
packageroku "$1" "$2" "$3";
or for delroku since it only has one parameter.
delroku "$1";