Myth Apple Trailers
From MythTV
Contents |
Description
Unofficial Add-on for MythTV to get Apple.com Movie Trailers
version: 0.4.3
Software Requirements
Requires PHP (4/5), Mplayer, w32codecs (to play quicktime)
- The new version has been updated to no longer depend on the php-xml libraries. I rewrote the rss feed grabber code to use all standard php functions. Tested and works with fedora with basic php support. I also tested it on centos with PHP 4.3.9 which works fine. submit any bug reports to : undertoe at chemlab dot org
Installation
Install php command line executable, mplayer, and windows 32bit codecs on (ubuntu). You might have to take a few extra steps, if w32codecs is not available on your system info can be found here.
sudo apt-get update && sudo apt-get install php5-cli mplayer w32codecs
Download the Myth Trailer Grabber in mythtv user dir
Note: NOTE: This guide assumes that your user is "mythtv", such as what is setup by MythDora; if you use a different user, replace the "/home/mythtv" with "/home/yourUserName"
cd /home/mythtv/
Option 1: If you want to ONLY stream the trailers from the apple website, use this script:
wget http://colt45.chemlab.org/misc_scripts/mythtrailer/0.4/mythappletrailer-0.04.3.tar tar -xvf mythappletrailer-0.04.3.tar cp mythappletrailer-0.04.3/myth_trailers_grabber ./
Option 2: If you want to be able to download the trailers every night to your local machine for faster playback, as well as have the option to stream directly, use this script:
wget http://creasonfamily.com/files/mythtv/mythappletrailer-0.04.2.tar.gz tar -zxf mythappletrailer-0.04.2.tar.gz cp mythappletrailer-0.04.2/myth_trailers_grabber ./
As mythtv user
touch /home/mythtv/appletrailer.xml
As root
sudo ln -s /home/mythtv/appletrailer.xml /usr/share/mythtv/appletrailer.xml
Add menu entry to the information section of MythTV theme xml file
sudo nano /usr/share/mythtv/info_menu.xml
the end of the file will look like this
</button> </mythmenu>
insert the following text before the </mythmenu>
<button>
<type>MOVIETIMES</type>
<text>Apple Trailers</text>
<action>MENU appletrailer.xml</action>
</button>
the end of the file result will now appear like this
</button>
<button>
<type>MOVIETIMES</type>
<text>Apple Trailers</text>
<action>MENU appletrailer.xml</action>
</button>
</mythmenu>
Add cron job as mythtv user once a night to download the new appletrailer.xml file Example: your paths may differ
crontab -e 0 2 * * * /usr/bin/php -q /home/mythtv/myth_trailers_grabber > /home/mythtv/appletrailer.xml
For the first time (before everything happens automatically) you should run the cron job to populate appletrailer.xml file by
/usr/bin/php -q /home/mythtv/myth_trailers_grabber > /home/mythtv/appletrailer.xml
Reload the frontend then go in to the Info Center > Apple Trailers. There you have it all the apple trailers.
- Note: Trailers could take a awhile to load if you're streaming them and not downloading, so after you click on the trailer in myth there maybe some delay depending on your internet connection speeds, size of trailer and amount you are pre-caching (if any).
Configuration (Optional)
nano /home/mythtv/myth_trailers_grabber
Edit options at top of file
Here is an enhanced mplayer command that drastically improved things for HD:
$player_exec_cmd= '/usr/bin/mplayer -fs -zoom -quiet -user-agent NSPlayer -cache-min 75 -cache 16384'; //mplayer command
Here is an alternate command for using xine instead of mplayer:
$STREAMING_EXEC_CMD = 'xine -pfhq --no-splash';
and don't forget to rerun the cron after you change the config:
/usr/bin/php -q /home/mythtv/myth_trailers_grabber > /home/mythtv/appletrailer.xml
Screen shots
list of watchable movie trailers
Support
This script will not work by default under Gentoo. The default php.ini disallows using fopen to access URLs. The appropriate setting is in '/etc/php/cli-php5/php.ini' and the value 'allow_url_fopen' must be changed to 'On'. -- wagnerrp, 5/13/08
If you find that selecting a trailer to watch does nothing in MythTV 0.21 and Trailer Grabber 0.4.3, you may need to modify line 76 of the script to read:
print "\t\t<action>EXEC $VideoPlayCMD</action>\n";
It seems that the EXEC was missing, but needed. --Geoffp, 5/17/08
For 0.43: you can put in the grabber (after line 67) a few more lines which change links to 720p links:
$MovieTitle = $Row['info'][0]['title'];
$MovieLink = $Row['preview'][0]['large'];
// try to replace it with 720p link if 720p link exists
$MovieLink720p = str_replace('_h640w.','_720p.',$MovieLink);
$headers = get_headers($MovieLink720p);
if (preg_match('/200/',$headers[0])) {
$MovieLink = $MovieLink720p;
}
$VideoPlayCMD = PLAYERCMD . ' ' . $MovieLink;
You can also use _480p., _1080i., _1080p. etc. The scripts is running 0,5 - 2 seconds longer for every trailer, but it gets videos with much better quality. And it should not matter if it runs in the crontab. It can be changed to check first for 1080p and 720p and than fall back to original link if these do not exist.--Mickey 17:03, 22 June 2008 (UTC)
Cleaning Up Ampersand & Character in the Movie Title
Sometimes a title will have an ampersand, like "Abc & Def". When this is used for a Myth menu item it will cause mythfrontend to crash with a segfault. You can edit this and input the proper char for XML:
Change this approx line 74:
print "\t\t<type>VIDEO_BROWSER</type>\n";
print "\t\t<text>$MovieTitle</text>\n";
to:
print "\t\t<type>VIDEO_BROWSER</type>\n";
$MovieTitle = preg_replace('/ & /', ' & ', $MovieTitle);
print "\t\t<text>$MovieTitle</text>\n";
And the & char will be replaced in the appletrailer.xml with & which prints the & character but doesn't crash mythfrontend.
More support can be found here at the MythTalk.com community
MythTalk.com Apple Trailers Forum
Email undertoe at chemlab dot org with any questions or sugestions

