Tuesday, March 24, 2009

MythTV plugin to watch Internet TV

If you have a mythTV box. You can simply make some minor modifications to it by creating a plugin which allows it to stream content from the web. This plugin simply contains URLs appropriately formatted to appear is mythTV menu items.

Following outlines the steps needed to build this plugin.

#!/usr/bin/perl -w
###########################################################
# File: online_movies.pl
#
# Download html from the following URL and parse for mms content and
# then build the online_movies.xml from it.
#
# 1. http://onlinevideochannel.blogspot.com/
###########################################################
use strict;
package OnlineMovies;
use base "HTML::Parser";
use Data::Dumper;

sub text {
my ($self,$text) = @_;
#print $text;
}

sub start {
my ($self, $tag, $attr, $attrseq, $origtext) = @_;
if ($tag eq "a"){
my $channel = $attr->{'channel'};
if( $channel ) {
my $href = $attr->{"href"};
print $channel,",",$href , "\n";
}
}
}

sub end {
my($self, $tag, $origtext) = @_;
#print $tag;
}

my $p = new OnlineMovies;
$p->parse_file("/tmp/index.html");
=====================================
Here's a Shell Script to process the downloaded HTML file and convert it into MythTV plugin:

wget -O /tmp/index.html http://onlinevideochannel.blogspot.com/
/home/mythtv/bin/online_movies.pl > /tmp/movie_urls.txt
cat /tmp/movie_urls.txt | awk '
BEGIN { FS = ",";
print "";
print "\t < button >";
print "\tRSYNC";
print "\t";
print "\t";
print "\t < /button > ";
};
{
if( NF > 0 ) {
print "\t < button >";
print "\tVIDEO_BROWSER";
printf ("\t\n", NR, $1);
printf ("\t\n",$2);
print "\t < /button >";
}
};
END {
print "
";
}
' > /usr/local/share/online_movies.xml

===================
Here's how to integrate this plugin into information menu:
add the following buttons to the /usr/local/share/mythtv/info_menu.xml


< button>
MOVIETIMES
Online Movies
MENU online_movies.xml
</button>
.
.


So you are all set....
Enjoy watching some hindi and English channels over the web.
The only caveat is that it takes time to buffer the content and the UI is frozen when this buffering is going on.

So I run this script as a cron job every night to get the latest channels from the online video blog which my wife maintains.

No comments:

Post a Comment