initial commit with readme, boxee app, version 1.0 of the boxee.php script

This commit is contained in:
Erik Kristensen 2010-06-08 22:31:22 -04:00
commit 818c323744
3 changed files with 221 additions and 0 deletions

19
README Normal file
View File

@ -0,0 +1,19 @@
Installation
-------------
1. Download mythtv-rss-<version>.zip
2. Extract contents of mythtv-rss-<version>.zip
3. Copy boxee.php to webroot of your MythTV Backend (hopefully where your recordings are kept)
4. Create a soft link to the recordings folder so that your recordings are accessible via http. (IE ln -s /path/to/recordings /DOCUMENT_ROOT/recordings)
5. Edit boxee.php, read the comments at the top of the file, update configuration variables as needed. Only one configuration variable needs to be changed for sure.
6. Copy the Boxee App to your apps folder --
* Linux: ~/.boxee/UserData/apps/
* Mac/ATV: ~/Library/Application Support/BOXEE/UserData/apps/
* Windows Vista: C:\Users\<windows user name>\AppData\Roaming\BOXEE\userdata\apps\
* Windows XP: C:\Documents and Settings\<your windows user name>\Application Data\BOXEE\userdata\apps\
7. Edit the descriptor.xml file, update the rss path to http://<IP_OR_HOSTNAME_OF_YOUR_MYTHTV_BACKEND/boxee.php
Caveats
--------
Unfortunately until I figure out or have time to figure out how to prompt a user inside Boxee to enter in their IP of their MythTV backend, the app has to run in test mode locally -- eventually I would like to put this up in its own repository someplace. Long term goal would be to convert the MythBox plugin for XBMC to Boxee so we could take full advantage of the MythTV API.

15
mythtv-rss/descriptor.xml Normal file
View File

@ -0,0 +1,15 @@
<app>
<id>mythtv-rss</id>
<name>MythTV</name>
<version>1.0</version>
<description>View Recorded Programs from your MythTV Backend</description>
<thumb>http://upload.wikimedia.org/wikipedia/commons/3/3c/Mythtv.png</thumb>
<media>video</media>
<copyright>Erik Kristensen</copyright>
<email>erik@erikkristensen.com</email>
<type>rss</type>
<platform>all</platform>
<minversion>0.9.20</minversion>
<url>rss://<YOUR_MYTHBACKEND_HOSTNAME_HERE>/boxee.php</url>
<test-app>true</test-app>
</app>

187
scripts/boxee.php Normal file
View File

@ -0,0 +1,187 @@
<?php
/**
* MythTV MythBackend RSS Script for MythTV RSS Boxee App
*
* Name: MythTV RSS Boxee App
* Website: http://erikkristensen.com/boxee-mythtv/
* Source: http://github.com/ekristen/MythTV-RSS-Boxee-App
* License: MIT License
* Version: 1.0
*
*
* Author: Erik Kristensen
* Email: erik@erikkristensen.com
* Website: http://erikkristensen.com
*
*
* This software is released under the MIT License.
*
* Copyright (c) 2010 Erik Kristensen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Set the relative path to the webroot to how Boxee will access your recordings.
* For example if you create symlink in the document root called "recordings" to your
* recordings directory where all the mpeg2 get stored your path will be 'recordings'.
* NOTE: there is NO trailing or beginning slash!!!!!!
*/
$config['RecordingsPath'] = null;
/**
* This script needs to know the hostname or IP of this system
* so it can link back to the webserver for the media. Leave this
* value null if you want the script to try and automatically detect
* the IP.
*/
$config['HostnameIP'] = null;
/*
* Leave these set to null if you want the script to find the
* MySQL credentials for MythTV automatically, if you are getting
* an error using the automatic method, add your MySQL credentials
* here.
*/
$config['DBHostName'] = null;
$config['DBUserName'] = null;
$config['DBName'] = null;
$config['DBPassword'] = null;
//---------------------------------------------------------------//
// EDIT BELOW THIS POINT AT YOUR OWN RISK! YOU HAVE BEEN WARNED! //
//---------------------------------------------------------------//
// Make sure that the RecordingsPath has been set.
if ($config['RecordingsPath'] == null)
{
die('Configuration Error: Please set the variable $config[RecordingsPath] in at the top of this file.');
}
// Make sure that either the database file exists or the username has been set in this file.
if (!file_exists('/home/mythtv/.mythtv/mysql.txt') && !isset($config['database']['username']))
{
die('Oops! I could not find the mysql credentials for MythTV!');
}
// Make sure the file exists and try to pull in the database information.
if (file_exists('/home/mythtv/.mythtv/mysql.txt'))
{
$lines = @file('/home/mythtv/.mythtv/mysql.txt') or die('Error: Something went wrong! Could not access the file where the MySQL credentials are!');
for ($x=0; $x<count($lines); $x++)
{
list($name,$value) = split('=',$lines[$x]);
$config[$name] = trim($value);
}
}
// Automatically pull the IP of this server if it wasn't set in the config
if ($config['HostnameIP'] == null)
{
$config['HostnameIP'] = $_SERVER['SERVER_ADDR'];
}
// Name of the script, this is if people decide to change the name of the script...
$config['script_name'] = $_SERVER['SCRIPT_NAME'];
/**
* Make our connection to the database.
*/
@mysql_connect($config['DBHostName'], $config['DBUserName'], $config['DBPassword']) or die('Error: Unable to connect to the database! ('.mysql_error().')');
@mysql_select_db($config['DBName']);
/**
* Detect if a request is being passed to the script.
* Looking for Type to be set, then Queue or Show and if Show then a Title
* From that information we build out the RSS that Boxee needs.
*/
if (isset($_REQUEST['type'])):
if ($_REQUEST['type'] == 'queue')
{
$channel_title = 'Queue';
$channel_descr = 'Queue of My Recorded Programs from MythTV';
$sql = "SELECT * FROM recorded WHERE watched = 0 ORDER BY originalairdate DESC";
$qry = mysql_query($sql);
}
else if ($_REQUEST['type'] == 'show')
{
$channel_title = 'MythTV Recorded Programs';
$channel_descr = 'My Recorded Programs from MythTV';
$title = str_replace("_", " ", $_REQUEST['title']);
$sql = "SELECT * FROM recorded WHERE title = '{$title}' ORDER BY originalairdate,starttime DESC";
$qry = mysql_query($sql);
}
?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:boxee="as http://boxee.tv/spec/rss/">
<channel>
<title><?php echo $channel_title; ?></title>
<link>http://www.mythtv.org/</link>
<description><?php echo $channel_descr; ?></description>
<?php
while ($obj = mysql_fetch_object($qry)):
$runtime = strtotime($obj->progend) - strtotime($obj->progstart);
$content_url = "http://{$config['HostnameIP']}/{$config['RecordingsPath']}/{$obj->basename}";
$thumbnail_url = $content_url . ".png";
?>
<item>
<title><?php echo $obj->subtitle; ?></title>
<description><?php echo $obj->description; ?></description>
<media:content url="<?php echo $content_url; ?>" type="video/mpeg" duration="<?php echo $runtime; ?>" />
<media:thumbnail url="<?php echo $thumbnail_url; ?>" />
<media:category scheme="urn:boxee:genre"><?php echo $obj->category; ?></media:category>
<boxee:runtime><?php echo gmdate("H:i:s", $runtime); ?></boxee:runtime>
<boxee:content_type>tv</boxee:content_type>
<boxee:tv-show-title><?php echo $obj->subtitle; ?></boxee:tv-show-title>
<boxee:release-date><?php echo $obj->originalairdate; ?></boxee:release-date>
<pubDate><?php echo date("D, j M Y G:i:s T", strtotime($obj->originalairdate)); ?></pubDate>
</item>
<?php
endwhile; ?>
</channel>
</rss>
<?php
else:
$sql = "SELECT * FROM recorded GROUP BY title";
$qry = mysql_query($sql);
?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:boxee="as http://boxee.tv/spec/rss/">
<channel>
<title>MythTV Recorded Programs</title>
<link>http://www.mythtv.org/</link>
<description>My Recorded Programs from MythTV</description>
<item>
<title>Queue</title>
<link>rss://<?php echo $config['HostnameIP']; ?><?php echo $config['script_name']; ?>?type=queue</link>
</item>
<?php
while ($obj = mysql_fetch_object($qry)): ?>
<item>
<title><?php echo $obj->title; ?></title>
<link>rss://<?php echo $config['HostnameIP']; ?><?php echo $config['script_name']; ?>?type=show&amp;title=<?php echo strtoupper(str_replace(" ", "_", $obj->title)); ?></link>
<media:thumbnail url="http://<?php echo $config['HostnameIP']; ?>/<?php echo $config['RecordingsPath']; ?>/<?php echo $obj->basename; ?>.png" />
</item>
<?php
endwhile; ?>
</channel>
</rss>
<?php endif; ?>