Solutions: The example code is available for download. When you complete a new TV-web channel and publish it, send me a link so I can help spread the word.
Behind the scene: The growing use of RSS distribution for video via torrents or streaming can be easily expanded from PC users to TV viewers. In hardware terms, what is needed is a TV that supports browsing of TV-formatted web, i.e. TV-web. An active-TV technology enabled TV or Set-Top Box is just one such device.
If you are not interested in torrent support, skip the following section and start reading from the Adding an RSS Feed section.
Configuring uTorrent Support
(Please see updated blog entry on this topic) uTorrent is a tiny bittorrent client-engine for the PC. The uTorrent TV-web page contains JavaScript which communicates with the uTorrent software running on a networked PC. If, for some reason, the TV-web page can’t communicate with the uTorrent software, then the message below appears on the TV. This usually indicates that the uTorrent engine has not been started before the TV-web page was accessed. (Before using the bittorrent TV-web page, uTorrent should be downloaded and installed on the supporting PC.)
There may be other reasons the TV-web page can’t successfully communicate with the torrent engine and require a little diagnostic work. The uTorrent software can be controlled via a browser interface. This enables remote browser access to a PC running uTorrent. The uTorrent “Preferences” must be correctly configured for this to work. The remote TV-web page assumes the “incoming connection” is set to the default port, 12060. See the setup option below.
The uTorrent Web UI interface enables remote login to the torrent PC. The remote login ID must be set to “active-TV” with password “pass”. This is the initial password. It can be changed to your own preference; however, make sure the ID on the uTorrent TV-web Settings page is set to the same value.
After a torrent is complete, uTorrent can move the downloaded files to a “completion directory”. The TV-web software does not care if this option is used, or what directory is identified, but it is best to use a directory which is accessible by one the media servers used by the system.
Media Servers currently popular with active-TV technology are provided by D-Link, TVersity, Microsoft and Media Mall. The D-Link server is included in basic install-software for the DSM-520. It enables access to a networked PC’s file system. The server software on the PC must be set to indicate what part of the file system is to be shared with the DSM-520. Use of the D-Link server does not require active-TV software to be in use by the DSM-520.
Similar to the D-Link server, the TVersity server can also work with the basic UPnP-DLNA services of the DSM-520 or other networked media players. This means the TVersity server can give a networked TV access to the PC file system without active-TV support software running on the PC or TV. Additionally, TVersity can give a basic UPnP device access to RSS feeds; But in this case the TV UI is determined by the local device and not by an associated TV-web page. However, TVersity also has an active-TV conforming TV-web page which supports access to the PC file system, but this time via a TVersity TV-web page.
The MediaMall server is another option when remotely accessing the PC file system. In this case there are only TV-web page interfaces to the PC’s file system. These are found under the “More Programs” – “My video”, “My Music” and “My Photos”.
PC media servers are programmed to scan the shared portion of the file system at regular intervals. In this way they find changes to the file system and the arrival of new files to be shared. After a torrent download has completed it is not available at the TV until after the next media server “scan”. When doing so, the uTorrent TV-web page ‘asks’ the torrent engine for the location of the completed torrent. In this way the torrented video is immediately available for viewing via access from the uTorrent TV-web page.
Take care with the access permission applied to torrented files. The DSM-520 logs into the PC just like any other PC user. If a torrent is started from a TV-web page, then downloaded files may have access restrictions imposed on other PC login IDs.
Adding an RSS Feed
The uTorrent TV-web channel, or any RSS- fed TV-web page, has a link to a setup page, partially shown below. Each of the 3 menu entries consists of a left or A-part, which generally selects the torrent or video source. The right or B-part is used for further selection from within the chosen A-part source. Those planning on extending RSS video or torrent feeds must know how to make the simple changes to the HTML file for the channel’s TV-web page.
For the menu-3 entry above, the source is “BitTorrent” and the sub selection is “TV”. The list of possible entries for A-part selection is defined by the Torrent_A array in the uTorrent_16x9.htm file. To add a new A-part entry, corresponding to a new RSS feed, a new identification-string must be included in the Torrent_A array
var Torrent_A = new Array("Democracy Now", "torrents”, "BitTorrent");
The support software calls the getMenuB() function to determine the possible B-part selection – given a chosen A-part. This function must be expanded to include any new RSS feed. The getMenuB() function need only return an array of part-B options; such as returning the array BitTorrent_B shown below.
function getMenuB( A_choice) {
if (A_choice == "BitTorrent") {
return BitTorrent_B;
}
}
var BitTorrent_B = new Array("TV", "Movies");
Once a user of the settings page completes final selection for each of the 3 menu entries, the setAB() function is called to establish the RSS URLs to be used with each menu entry. Adding a new RSS feed would require corresponding expansion of the setAB() function. The logic is quite simple, as shown below.
if (A_choice == "BitTorrent") {
return BitTorrent_B;
}
}
var BitTorrent_B = new Array("TV", "Movies");
Once a user of the settings page completes final selection for each of the 3 menu entries, the setAB() function is called to establish the RSS URLs to be used with each menu entry. Adding a new RSS feed would require corresponding expansion of the setAB() function. The logic is quite simple, as shown below.
function setAB( column, A_choice, B_choice) {
if (A_choice == "BitTorrent"){
if(B_choice == "TV" ) {
column_url[column -1] = "http://www.bittorrent.com/search/index.rss?category=TV+Shows&filter=free&orderBy=popularity&availability=all";
}
else if(B_choice == "Movies" ) {
column_url[column -1] = "http://www.bittorrent.com/search/index.rss??category=Movies&filter=free&orderBy=popularity&availability=all";
}
}
Parsing the RSS Video Feed
Using the RSS feed’s URL, an XML documented is downloaded from the RSS server. To study an XML layout, it can be saved to the PC as an ..xml file and examined by opening with Microsoft’s IE7 browser. There are differences between the formatting of each RSS feed. But typically, each video entry in the XML table or listing looks like the example below. In this case the start of each video entry is marked with the <item> tag. The “Willie Nelson” entry below is from an RSS feed from http://www.bittorrent.com/.
- < item>
< title>Willie Nelson: Austin City Limits< /title>
< link>http://www.bittorrent.com/users/austin-city-limits-dvd/torrent/Willie_Nelson__Austin_City_Limits/92fd7a06efd9c16afaea2ff5a8a1031da1c35fad?csrc=search-rss< /link>
<>Songwriting legend (and biodiesel proponent) Willie Nelson performs live at the Austin City Limits.< /description>
< pubdate>Tue, 08 May 2007 22:17:28 -0000< /pubdate>
< comments>Seeders:0 Downloaders:0< /comments>
< enclosure url="http://torrents.bittorrent.com/austin-city-limits-dvd/92fd7a06efd9c16afaea2ff5a8a1031da1c35fad/Willie_Nelson.wmv.torrent" length="38718489" type="application/x-bittorrent">
< /item>
The TV-web page’s support code uses JavaScript to exact the relevant date for each video entry. The fillVideoArray() function is used for this task. It must be expanded to include support for passing a new RSS feed.
function fillVideoArray ( column, first_video, quantity) {
if(menuAB[column -1].A_choice == "torrents" ) {
return torrentsFillVideoArray(column, first_video, quantity);
}
else if( menuAB[column -1].A_choice =="BitTorrent") {
return bitTorrentFillVideoArray(column, first_video, quantity);
}
The fillVideoArray() function is used to produce an array of menuEntry , know as the Video array. Each entry has a title, description, rating and so on. All that is required is ‘walking’ thought each XML entry and extracting the relevant data for entry into the Video array.
function menuEntry ()
{
this.title;
this.description;
this.url;
this.rating;
this.duration;
this.date;
this.image;
};
The essential part of the parse routine is below. There are two important routines to understand: getElementsByTagName() and getAttribute(). For example, the tag-name “enclosure” contains the URL for the video. Some tag-names don’t have attributes and getElementsByTagname() is used alone to access the required Video entry – such as “title” in the example. In the case of the video URL, the URL is an attribute of the “enclosure” tag. This requires use of the getAttribute() to exact the URL data.
video_index =0;
for (var i=0; i<(xmlElement.length + skip) & video_index < entryitem =" xmlElement[i];" image = "BitTorrent.png" rating=" 0.0;" titleitem =" entryItem.getElementsByTagName(" title =" titleItem[0].text;" descriptionitem =" entryItem.getElementsByTagName(" description =" descriptionItem[0].text;" enclosureitem =" entryItem.getElementsByTagName(" duration =" Math.floor(" url = "torrent@" dateitem =" entryItem.getElementsByTagName(" date =" dateItem[0].text;" date =" date.substr(0,">
Note in the above example there is no per-video image data or rating. In such case an empty string ( “” ) or 0.0 value can be used for the corresponding Video entry, or some more useful value can be created or inserted. The “duration” entry has been filled with the size of the torrent file, this entry normally contains a string indicating the run-time of the video. It is important to note that in this bittorrent example the video URL has the string “torrent@” prepended. This is only required for torrent videos. When parsing an RSS feed for normally streamed video, which are to be viewed immediately, “torent@” should not be added to the video URL.
The TV-web is used to display the Video array information for each video menu entry. The image above shows the information extracted for the “Willie Nelson” example.
With menu settings: “torrent” – “active torrents”, information about the progression of video torrents is reported. This is only provided for torrents containing video or other media file. It is possible to torrent, say, an .exe file; but the torrent progress would not be reported, as the file is not for TV access. So, perhaps RSS filtering above should exclude .exe files.
As this proof-of-concept is further developed, more features and support for additional torrent engines will likely be added. For now, however, it has been proven that torrents listings can be viewed, selected, download and watched -- all from the TV, a welcome step towards making the pleasures and ease of 'catch-up TV' viewing, heretofore only available on the PC, now available directly on the TV. The steps outlined above, show how to add addition RSS video sources to a TV’s channel listings.
Feedback, corrections and comments welcome. Contact me for more information or support with active-TV technology development. Daniel Mann