Thursday, December 10, 2009

Using git to maintain project sources

In the last post I provided the details of how to create a YouTube plugin.
The code has been added to git social coding website.

http://github.com/vsrivastav/YouTubePlugin

Sunday, December 6, 2009

Building a YouTube Plugin for mythTV

So I have been busy with my studies. Just finished 1st year of my MBA curriculum and have been thinking what to do during my break besides playing with my son. I built a youtube plugin for my mythTV.

YouTube is a massive collection of videos. Google provides the "Zend" youTube API in php and other languages, which allows programmatic access to a user's playlist, user's subscriptions and user's favourite lists. I decided to tap into this zend YouTube API to build a youTube plugin. Following are the characteristics of this plugin:

1. It is written entirely in php and uses zend youTube php libraries.
2. Currently it downloads videos from a user's public favorite and playlists.
3. It downloads the youTube videos as mp4 file (video:mpeg4, audio codec: acc) with a resolution which allows these files to be played on iPod.
4. It uses cclive (it is available on yum or apt repository) to download video entries.

References:
The youTube API is available at:
http://code.google.com/apis/youtube/2.0/developers_guide_php.html

Prerequisite
1. You have a mythtv user (in my case I call it mythtv and I have auto login enabled for this user). The home dir for this user is /home/mythtv. Please replace it appropriately if you are using a different mythtv user.
2. Provide sudo permission to mythtv user. This is needed because the playlist xml files has to be created in /usr/share/mythtv directory.
3. Install the Google's youTube zend API. I have it installed in ~/opt folder of mythtv user.


Configuration Steps:

1. Integrating into the mythtv menu: The mythtv is installed by default in the following folder (on fedora): "/usr/share/mythtv". The mainmenu.xml is the entry point for the mythTV GUI for building the menu. I added the following to the mainmenu.xml file:

<button>
<type>MOVIETIMES</type>
<text>YouTube Favorites</text>
<action>MENU youTube_plugin.xml</action>
</button>
;

as a child node of mythmenu element

2. Creating the youTube plugin xml file link: create a soft link youTube_plugin.xml pointing to -> /home/mythtv/.mythtv/youTube_plugin.xml

cd /usr/share/mythtv
sudo ln -s /home/mythtv/.mythtv/youTube_plugin.xml

3. Install the youTubeFav.php plugin, chmod +x it and configure it to run as a cron job nightly.

4. Setup the youtube account ids in the ~/.youTubeCfg file
USERS_LIST=<youtube user ids seperated by commas>
DOWNLOAD=1
DOWNLOAD_DIR=x # not currently used
CREATE_PLAYLISTS=1
DOWNLOAD_FAVORITES_VIDEOS=0
DOWNLOAD_PLAYLIST_VIDEOS=1


It's is fun to watch your youTube playlist and favorites on TV as well as on your iPod/iPhone or iTouch. The nightly cron job keeps your TV and iPod synchronized.

I will provide more details in my next post with links to this youTubeFav.php script and mechanisms to copy the syncing these mp4 files to iPod. Please watch my next post for details. You can subscribe or follow this blog with buttons on right.

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.

Tuesday, March 3, 2009

Choosing a hardware for MythTV DVR

There were three factors important for me in deciding the machine configuration to use:
1. I wanted a small form factor so that I could keep is next to my TV in the living room
2. I wanted wireless to work on it.
3. I wanted a remote to work with it.

If you want to record and watch programs later, you may additionally want a TV tuner card in your configuration. Setting up a TV tuner card is more involved and we will leave it for later.

We will start with very basic setup of the MythTV system and later on move to more involved improvements that can be done on it. So! lets define our basic fully functional system that we want to tackle in this blog:

Our basic fully functional MythTV device will be running MythTV frontend application will have capabilities to play music, videos, apple trailers, allow subscriptions to audio and video podcasts, allow checking local weather forecast, allow choosing slick skins, support wireless connection to network and will have a remote.

I recommend using StreamZap remote, which I really like. It is low price and works well with both Linux and Windows. I also recommend a dual boot system that can boot up in windows if required. So here are the things we need:

1. A PC, if it has a windows OS on it, we can convert it into a dual boot, if not, we can just make it Linux only OS.
2. Wireless: either external or internal. Alternatively one can use an Ethernet connection. If you have one close to where you want to keep this device.
3. Streamzap remove control.

So next blog we will talk about how to partition your hard disk for dual boot. I have used several strategies over the years and will stick to the best that I like. Please keep tuned.

Saturday, February 21, 2009

Creating a MythTV DVR

MythTV is one of the tools that one can use. MythTV is a DVR and if you have a TV tuner card you can record on it programs to watch is later. However, MythTV runs only on Linux and requires one to be a Linux thoroughbred to configure a MythTV system with networking and other drivers. I have found Linux especially difficult with network drivers.

If one wants to use a computer and connect it to their TV, one of the things that should be consider is whether a wireless support is required on the PC. One can choose a small form factor and keep it along side their VCR and DVD player.

I choose a MythTV configuration without a TV tuner card but I created a Plugin containing a list of streaming web URL. The list is updated periodically and provide me with access to several video streaming web URL. Albeit a little slow to browse through because it requires buffering, but gets me set of video contents from web that I am interested in. Other than this I use MythTV for listening to my audio and video archive.

Stay tuned, next blog I will talk about what I have found to be the easiest way to install MythTV. If you have a PC to spare that can be connected to TV and an internet connection on it, you may find it interesting....

What this blog is about?

This blog is about streaming videos from web to TV. Most cable companies and telecommunication companies behave like monopolies. The prices are too steep and the content too steeped with advertisements.

If you have internet connection, most relevant information is available on web. Today any media company can't just live without providing content on the web. There is plethora of video content available on the web.

The great unbundling
The RSS, Atom, Podcasts, Videocasts are driving us in a world where in we have capability to subscribe and access only the content that interests us. We can subscribe to only feeds that interests us, we search and filter content which we are interested in. The technology has driven us into silos, where we create a wall around ourselves with only relevant contents and never get exposed to things not of our interest. The internet has segmented and nurtured the human behavior in unfathomable ways. But this unbundling has not yet peculated in video services in our living room. This is a blog about one individual's struggle to consolidate the information on how to do it.

Video Services
What we need is a tool that facilitates bringing these video services on the web together on your big screen. I will try to discuss the tools and technologies that can facilitate this. So keep tuned.