summaryrefslogtreecommitdiffstats
path: root/abs/extra-testing/mythappletrailers
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2009-01-04 18:49:24 (GMT)
committerJames Meyer <james.meyer@operamail.com>2009-01-04 18:49:24 (GMT)
commit116edc0c0cc1b926acce635a76d102408b118a92 (patch)
tree237e661dc7f5b1bb4b18350ab3a48e5a15283851 /abs/extra-testing/mythappletrailers
parent29e945b91760568116a21e0076fae046b33a2663 (diff)
parent7f42f55d022dc8ca818a76dccfc66fce7c8dea4f (diff)
downloadlinhes_pkgbuild-116edc0c0cc1b926acce635a76d102408b118a92.zip
linhes_pkgbuild-116edc0c0cc1b926acce635a76d102408b118a92.tar.gz
linhes_pkgbuild-116edc0c0cc1b926acce635a76d102408b118a92.tar.bz2
Merge branch 'HEAD' of ssh://jams@knoppmyth.net/mount/repository/LinHES-PKGBUILD.git
Diffstat (limited to 'abs/extra-testing/mythappletrailers')
-rw-r--r--abs/extra-testing/mythappletrailers/PKGBUILD9
-rwxr-xr-xabs/extra-testing/mythappletrailers/myth_trailers_grabber214
-rw-r--r--abs/extra-testing/mythappletrailers/mythappletrailers.install8
-rwxr-xr-xabs/extra-testing/mythappletrailers/trailers2
4 files changed, 227 insertions, 6 deletions
diff --git a/abs/extra-testing/mythappletrailers/PKGBUILD b/abs/extra-testing/mythappletrailers/PKGBUILD
index 73f7add..ec4d701 100644
--- a/abs/extra-testing/mythappletrailers/PKGBUILD
+++ b/abs/extra-testing/mythappletrailers/PKGBUILD
@@ -3,14 +3,14 @@
pkgname=mythappletrailers
pkgver=0.04.3
-pkgrel=6
+pkgrel=12
pkgdesc="Unofficial Add-on for MythTV to get Apple.com Movie Trailers."
arch=('i686' 'x86_64')
license=('GPL2')
url="http://www.mythtv.org/wiki/index.php/Myth_Apple_Trailers"
depends=('php')
install=mythappletrailers.install
-source=('http://colt45.chemlab.org/misc_scripts/mythtrailer/0.4/mythappletrailer-0.04.3.tar'
+source=('myth_trailers_grabber'
'trailers')
build() {
@@ -21,6 +21,7 @@ build() {
touch $startdir/pkg/home/mythtv/appletrailer.xml
chown 1000:1000 $startdir/pkg/home/mythtv/appletrailer.xml
chmod 755 trailers
- chmod 755 myth*/myth*
- cp trailers $startdir/pkg/etc/cron.daily
+ chmod 755 myth_trailers_grabber
+ cp myth_trailers_grabber $startdir/pkg/usr/bin/
+ cp trailers $startdir/pkg/etc/cron.daily/
}
diff --git a/abs/extra-testing/mythappletrailers/myth_trailers_grabber b/abs/extra-testing/mythappletrailers/myth_trailers_grabber
new file mode 100755
index 0000000..1d686aa
--- /dev/null
+++ b/abs/extra-testing/mythappletrailers/myth_trailers_grabber
@@ -0,0 +1,214 @@
+<?php
+/**
+ * Copyright (C) 2007 Ben Leto <undertoe@chemlab.org>
+ *
+ * Description: Apple Trailer Grabber for mythtv
+ *
+ * Version 0.4.3
+ *
+ * Apple Trailer Grabber is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Apple Trailer Grabber is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Usage: read the INSTALL file
+ * Setup as a cron script to run as frequently as you want
+ *
+ *
+ */
+
+/************************************************************************/
+// CONFIGURATION
+
+// command to use when streaming content from the internet - cache 50% before displaying and use 32MB of memory
+$STREAMING_EXEC_CMD = '/usr/bin/mplayer -fs -zoom -really-quiet -user-agent NSPlayer -cache 16000';
+$APPLE_FEED = 'http://www.apple.com/trailers/home/xml/current.xml';
+/************************************************************************/
+// Shouldn't Need To modify anything beyond here
+
+
+define("PLAYERCMD", $STREAMING_EXEC_CMD);
+define("XMLFEED", $APPLE_FEED);
+
+/************************************************************************/
+
+init_main();
+
+// Function: returns null | init_main ()
+// Description: Outputs Apple Trailer XML feed to watchable movie urls in MythTV menu XML format
+function init_main()
+{
+
+ print "<mythmenu name=\"TRAILERS\">\n";
+
+ if(valid_url(XMLFEED)){
+
+ // Gather Array of Current Movie Trailers
+ //XML Data
+ $xml_data = url_to_string(XMLFEED);
+ //Creating Instance of the Class
+ $xmlObj = new XmlToArray($xml_data);
+ $arrayData = $xmlObj->createArray();
+
+ foreach($arrayData['records']['movieinfo'] as $Row){
+
+ $MovieTitle = $Row['info'][0]['title'];
+ $MovieLink = $Row['preview'][0]['large'];
+ $VideoPlayCMD = PLAYERCMD . ' ' . $MovieLink;
+
+ if(!valid_url($MovieLink)){
+ $MovieTitle = $MovieTitle . '*VIDEO ERROR*';
+ $VideoPlayCMD = '';
+ }
+
+ print "\t<button>\n";
+ print "\t\t<type>VIDEO_BROWSER</type>\n";
+ $MovieTitle = preg_replace('/ & /', ' &amp; ', $MovieTitle);
+ print "\t\t<text>$MovieTitle</text>\n";
+ print "\t\t<action>EXEC $VideoPlayCMD</action>\n";
+ print "\t</button>\n\n";
+
+ }
+ }else{
+ print "\t<button>\n";
+ print "\t\t<type>VIDEO_BROWSER</type>\n";
+ print "\t\t<text>Error Grabbing XML Feed</text>\n";
+ print "\t\t<action></action>\n";
+ print "\t</button>\n\n";
+ }
+
+ print "</mythmenu>\n";
+
+
+
+}
+
+
+// Function: returns boolean | valid_url ( var | url to check)
+// Description: Checks to see if a url is a valid page
+function valid_url($str)
+{
+ if(@fopen($str, "r")) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+// Function: returns string | all elements of XML ( var | url to feed)
+// Description: Converts each element in an XML feed to single line string
+// Notes: must have 'allow_url_fopen = On' in php.ini
+function url_to_string($url){
+ $lines = file($url);
+ foreach ($lines as $line) {
+ $lineR = trim($line);
+ }
+ $lineR = eregi_replace("<" . "large" . "[^>]*>", "<large>", $lineR); //hack for apple goofy xml
+ return $lineR;
+}
+
+// Class: returns (~) x array | elements of XML ( var | XML in string)
+// Description: Converts each element in an XML feed to an Array
+class XmlToArray
+{
+
+ var $xml='';
+
+ /**
+ * Default Constructor
+ * @param $xml = xml data
+ * @return none
+ */
+
+ function XmlToArray($xml)
+ {
+ $this->xml = $xml;
+ }
+
+ /**
+ * _struct_to_array($values, &$i)
+ *
+ * This is adds the contents of the return xml into the array for easier processing.
+ * Recursive, Static
+ *
+ * @access private
+ * @param array $values this is the xml data in an array
+ * @param int $i this is the current location in the array
+ * @return Array
+ */
+
+ function _struct_to_array($values, &$i)
+ {
+ $child = array();
+ if (isset($values[$i]['value'])) array_push($child, $values[$i]['value']);
+
+ while ($i++ < count($values)) {
+ switch ($values[$i]['type']) {
+ case 'cdata':
+ array_push($child, $values[$i]['value']);
+ break;
+
+ case 'complete':
+ $name = $values[$i]['tag'];
+ if(!empty($name)){
+ $child[$name]= ($values[$i]['value'])?($values[$i]['value']):'';
+ if(isset($values[$i]['attributes'])) {
+ $child[$name] = $values[$i]['attributes'];
+ }
+ }
+ break;
+
+ case 'open':
+ $name = $values[$i]['tag'];
+ $size = isset($child[$name]) ? sizeof($child[$name]) : 0;
+ $child[$name][$size] = $this->_struct_to_array($values, $i);
+ break;
+
+ case 'close':
+ return $child;
+ break;
+ }
+ }
+ return $child;
+ }//_struct_to_array
+
+ /**
+ * createArray($data)
+ *
+ * This is adds the contents of the return xml into the array for easier processing.
+ *
+ * @access public
+ * @param string $data this is the string of the xml data
+ * @return Array
+ */
+ function createArray()
+ {
+ $xml = $this->xml;
+ $values = array();
+ $index = array();
+ $array = array();
+ $parser = xml_parser_create();
+ xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ xml_parse_into_struct($parser, $xml, $values, $index);
+ xml_parser_free($parser);
+ $i = 0;
+ $name = $values[$i]['tag'];
+ $array[$name] = isset($values[$i]['attributes']) ? $values[$i]['attributes'] : '';
+ $array[$name] = $this->_struct_to_array($values, $i);
+ return $array;
+ }
+
+
+}
+
+?>
diff --git a/abs/extra-testing/mythappletrailers/mythappletrailers.install b/abs/extra-testing/mythappletrailers/mythappletrailers.install
index 22dada0..133390c 100644
--- a/abs/extra-testing/mythappletrailers/mythappletrailers.install
+++ b/abs/extra-testing/mythappletrailers/mythappletrailers.install
@@ -1,15 +1,21 @@
# arg 1: the new package version
post_install() {
+ ln -s /home/mythtv/appletrailer.xml /usr/share/mythtv/appletrailer.xml
}
-
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
+ if [ -e /usr/share/mythtv/appletrailer.xml ]
+ then
+ exit
+ else
ln -s /home/mythtv/appletrailer.xml /usr/share/mythtv/appletrailer.xml
+ fi
}
# arg 1: the old package version
post_remove() {
+ rm -fr /usr/share/mythtv/appletrailer.xml
}
op=$1
diff --git a/abs/extra-testing/mythappletrailers/trailers b/abs/extra-testing/mythappletrailers/trailers
index 61567ec..65ac9c2 100755
--- a/abs/extra-testing/mythappletrailers/trailers
+++ b/abs/extra-testing/mythappletrailers/trailers
@@ -1,2 +1,2 @@
#!/bin/sh
-su mythtv -c '/usr/bin/php -q /usr/bin/myth_trailers_grabber.php > /home/mythtv/appletrailer.xml'
+su mythtv -c '/usr/bin/php -q /usr/bin/myth_trailers_grabber > /home/mythtv/appletrailer.xml'