<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>MythTV Tips</title>
	<atom:link href="http://www.oneweb.co.uk/mythtv/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.oneweb.co.uk/mythtv</link>
	<description>Things that helped me setup MythTV and Mythbuntu</description>
	<pubDate>Mon, 04 Jan 2010 17:32:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Update to Configuring Your MCE IR Remote - Getting Meta Data Fast</title>
		<link>http://www.oneweb.co.uk/mythtv/2010/01/update-to-configuring-your-mce-ir-remote-getting-meta-data-fast/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2010/01/update-to-configuring-your-mce-ir-remote-getting-meta-data-fast/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 17:32:08 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=117</guid>
		<description><![CDATA[Just made another quick update to the Configuring Your MCE IR Remote post. I have assigned the &#8220;Clear&#8221; button to download meta data for videos when in the video manager. This is far quicker than pressing &#8220;i&#8221; and scrolling through menus and means you can get all the cover / fan art and synopsis with [...]]]></description>
			<content:encoded><![CDATA[<p>Just made another quick update to the<a href="/mythtv/2009/02/configuring-your-mce-ir-remote/"> Configuring Your MCE IR Remote</a> post. I have assigned the &#8220;Clear&#8221; button to download meta data for videos when in the video manager. This is far quicker than pressing &#8220;i&#8221; and scrolling through menus and means you can get all the cover / fan art and synopsis with one key press.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2010/01/update-to-configuring-your-mce-ir-remote-getting-meta-data-fast/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Acer Aspire Revo - A cheap HD frontend?</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/08/acer-aspire-revo-a-cheap-hd-frontend/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/08/acer-aspire-revo-a-cheap-hd-frontend/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 12:19:36 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[hd]]></category>

		<category><![CDATA[MythBuntu]]></category>

		<category><![CDATA[Silent]]></category>

		<category><![CDATA[VDPAU]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=107</guid>
		<description><![CDATA[Was tipped off about this fantastic article from a recent Ubuntu Uk Podcast.  The hardware looks pretty interesting an could make a great HD frontend for MythTV with VDPAU enabled. There&#8217;s a good post about trying VDPAU in MythBuntu on the forums but I haven&#8217;t had a chance to try it yet as I don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oneweb.co.uk/mythtv/wp-content/uploads/2009/08/ord-ace-revo-150x150.jpg"><img class="size-full wp-image-111 alignright" title="ord-ace-revo-150x150" src="http://www.oneweb.co.uk/mythtv/wp-content/uploads/2009/08/ord-ace-revo-150x150.jpg" alt="ord-ace-revo-150x150" width="150" height="150" /></a>Was tipped off about <a href="http://popey.com/blog/2009/08/06/acer-aspire-revo-ubuntu-boxee-and-remote-control/" target="_blank">this fantastic article</a> from a recent <a href="http://podcast.ubuntu-uk.org/" target="_blank">Ubuntu Uk Podcast</a>.  The hardware looks pretty interesting an could make a great HD frontend for MythTV with <a href="http://www.mythtv.org/wiki/VDPAU" target="_blank">VDPAU</a> enabled. There&#8217;s a good post about <a href="http://ubuntuforums.org/showthread.php?t=1063102" target="_blank">trying VDPAU in MythBuntu</a> on the forums but I haven&#8217;t had a chance to try it yet as I don&#8217;t have one of the <a href="http://www.mythtv.org/wiki/VDPAU" target="_blank">supported GPUs</a>.</p>
<p>Anyway, just thought the article was so good it was worth pointing out for anyone that might be looking for a cheap, near silent HD frontend.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/08/acer-aspire-revo-a-cheap-hd-frontend/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Update to Configuring Your MCE IR Remote</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/08/update-to-configuring-your-mce-ir-remote/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/08/update-to-configuring-your-mce-ir-remote/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 16:23:09 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[audio delay]]></category>

		<category><![CDATA[lirc]]></category>

		<category><![CDATA[mplayer]]></category>

		<category><![CDATA[Remote]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=103</guid>
		<description><![CDATA[Just made a quick update to the Configuring Your MCE IR Remote post. I have added in Audio Delay + and - to the mplayer lirc config. This allows you to control the audio / video sync with the Blue and Yellow buttons on your MCE remote. I had quite a few films that have [...]]]></description>
			<content:encoded><![CDATA[<p>Just made a quick update to the <a href="/mythtv/2009/02/configuring-your-mce-ir-remote/">Configuring Your MCE IR Remote</a> post. I have added in Audio Delay + and - to the mplayer lirc config. This allows you to control the audio / video sync with the Blue and Yellow buttons on your MCE remote. I had quite a few films that have the audio out of sync so this can now be sorted without reaching for the keyboard <img src='http://www.oneweb.co.uk/mythtv/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/08/update-to-configuring-your-mce-ir-remote/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Normalise Movie Volume</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/03/normalise-movie-volume/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/03/normalise-movie-volume/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 13:49:59 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[mplayer]]></category>

		<category><![CDATA[normalise]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=92</guid>
		<description><![CDATA[I know DTS is all the rage at the moment but some DTS soundtracks have VERY LOUD LOUD BITS and very quiet quiet bits. This is great for the cinema or those people lucky enough to live in a detached house, but for my 2 bed flat it&#8217;s a bit over the top. To level [...]]]></description>
			<content:encoded><![CDATA[<p>I know <a target="_blank" href="http://en.wikipedia.org/wiki/DTS_Coherent_Acoustics">DTS</a> is all the rage at the moment but some DTS soundtracks have VERY LOUD LOUD BITS and <small>very quiet quiet bits</small>. This is great for the cinema or those people lucky enough to live in a detached house, but for my 2 bed flat it&#8217;s a bit over the top. To level things out mplayer can normalise your movie&#8217;s volume in realtime so that explosions are at the same volume as conversations. To enable normalisation add the following switch to the launch command for mplayer:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-af</span> volnorm</pre></div></div>

<p>So for example on your frontend navigate to &#8220;Utilities / Setup&#8221; -&gt; &#8220;Setup&#8221; -&gt; &#8220;Media Settings&#8221; -&gt; &#8220;Video Settings&#8221; -&gt; &#8220;Player Settings&#8221; and set the &#8220;Default Video Player&#8221; to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mplayer</span> <span style="color: #660033;">-fs</span> <span style="color: #660033;">-zoom</span> <span style="color: #660033;">-quiet</span> <span style="color: #660033;">-vo</span> xv <span style="color: #660033;">-subfont-text-scale</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-af</span> volnorm <span style="color: #660033;">-cache</span> <span style="color: #000000;">8912</span> <span style="color: #660033;">-cache-min</span> <span style="color: #000000;">4</span> <span style="color: #660033;">-lavdopts</span> <span style="color: #007800;">threads</span>=<span style="color: #000000;">2</span>:fast:<span style="color: #007800;">skiploopfilter</span>=all <span style="color: #660033;">-sws</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">%</span>s</pre></div></div>

<p>You may find it easier to connect to the mythconverg database and set the VideoDefaultPlayer to the value above for the host machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/03/normalise-movie-volume/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Automatically Convert Radio Shows To MP3 Format</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/02/automatically-convert-radio-shows-to-mp3-format/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/02/automatically-convert-radio-shows-to-mp3-format/#comments</comments>
		<pubDate>Sun, 15 Feb 2009 12:10:53 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Backend]]></category>

		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[autoaudio.sh]]></category>

		<category><![CDATA[encoding]]></category>

		<category><![CDATA[FFmpeg]]></category>

		<category><![CDATA[id3tag]]></category>

		<category><![CDATA[mp3]]></category>

		<category><![CDATA[radio]]></category>

		<category><![CDATA[transcode]]></category>

		<category><![CDATA[user job]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=73</guid>
		<description><![CDATA[It&#8217;s great to be able to record radio as well as TV channels using MythTV but to listen to them on an MP3 player they need to be transcoded to MP3 format. The process can be completely automated by setting up a User Job which runs after the show has recorded.
There are four main steps [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s great to be able to record radio as well as TV channels using MythTV but to listen to them on an MP3 player they need to be transcoded to MP3 format. The process can be completely automated by setting up a User Job which runs after the show has recorded.</p>
<p>There are four main steps needed to get this going:</p>
<p><strong>1. Install FFmpeg with MP3 encoding support<br />
</strong>There&#8217;s a great guide for installing FFmpeg with MP3 encoding support <a href="http://ubuntuforums.org/showthread.php?t=786095" target="_blank">here</a>. Just follow it through making sure you use the suggested &#8211;enable-libmp3lame switch when running ./configure in step 5.</p>
<p><strong>2. Install libid3-3.8.3-dev for automated ID3 tagging<br />
</strong>This library will allow the MP3 encoding script to place ID3 meta tags into the resulting MP3.  Info like artist, song and year is set based on the show you are recording.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libid3-3.8.3-dev</pre></div></div>

<p><strong>3. Setup conversion script and MythTV User Job<br />
</strong>The script below is the one that is executed by the User Job when the show finishes recording. It is based on <a href="http://www.mythtv.org/wiki/User:Nik_Doof/AutoAudio" target="_blank">this script</a> from the MythTV Wiki but I&#8217;ve modified it to work with the latest version of FFmpeg and tag and name the resulting MP3 in my preferred format.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;">###########</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Suggested execution format in the job settings for the backend (in general of the backend setup)</span>
<span style="color: #666666; font-style: italic;"># Remember to allow the job to run in the backend general settings too :)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># autoaudio.sh %FILE% %STARTTIMEISO% &quot;%TITLE%&quot;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">###########</span>
&nbsp;
<span style="color: #007800;">OUTPUTDIR</span>=<span style="color: #ff0000;">&quot;/media/recordedtv/transcoded&quot;</span>
<span style="color: #007800;">INPUTDIR</span>=<span style="color: #ff0000;">&quot;/media/recordedtv&quot;</span>
<span style="color: #007800;">INFILE</span>=$<span style="color: #000000;">1</span>
<span style="color: #007800;">ISODATE</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>F<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">PROGTITLE</span>=$<span style="color: #000000;">3</span>
<span style="color: #007800;">STARTDATE</span>=<span style="color: #800000;">${2:0:10}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Split</span>
<span style="color: #666666; font-style: italic;">###########</span>
<span style="color: #007800;">OUTFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$OUTPUTDIR</span>/<span style="color: #007800;">$PROGTITLE</span> - <span style="color: #007800;">$STARTDATE</span>.mp3&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#transcode mp2 audio to mp3</span>
<span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$INPUTDIR</span>/<span style="color: #007800;">$INFILE</span>&quot;</span> <span style="color: #660033;">-acodec</span> libmp3lame <span style="color: #660033;">-ab</span> 192k <span style="color: #660033;">-ar</span> <span style="color: #000000;">44100</span> <span style="color: #660033;">-f</span> mp3 <span style="color: #ff0000;">&quot;<span style="color: #007800;">$OUTFILE</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Tag</span>
<span style="color: #666666; font-style: italic;">##########</span>
<span style="color: #007800;">YEAR</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #000000; font-weight: bold;">%</span>Y<span style="color: #000000; font-weight: bold;">`</span>
id3tag <span style="color: #660033;">--artist</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$PROGTITLE</span>&quot;</span> <span style="color: #660033;">--song</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$PROGTITLE</span> - <span style="color: #007800;">$STARTDATE</span>&quot;</span> <span style="color: #660033;">--comment</span>=<span style="color: #ff0000;">&quot;&quot;</span> -y<span style="color: #007800;">$YEAR</span> <span style="color: #660033;">-A</span><span style="color: #ff0000;">&quot;Radio&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$OUTFILE</span>&quot;</span></pre></div></div>

<p>Copy the script above and put it in a new file in your home directory called autoaudio.sh. For me this was /home/colin/autoaudio.sh. Change the &#8220;OUTPUTDIR&#8221; and &#8220;INPUTDIR&#8221; paths to match your setup. &#8220;OUTPUTDIR&#8221; will be where the MP3 files are created and &#8220;INPUTDIR&#8221; should be the path to the mpg files of your recorded shows. </p>
<p>Remember to make the script executable.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> autoaudio.sh</pre></div></div>

<p>Also, make sure the MythTV user can write to the output path.</p>
<p><strong>4. Setup the user job</strong><br />
Go into the mythbackend setup and from the menu choose &#8220;General&#8221; and go to the last screen in this section titled &#8220;Job Queue (Job Commands)&#8221;. Enter a new job with the description of &#8220;Convert to MP3&#8243; then enter the command as below changing the path to the location of your autoaudio.sh file. For me this is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>colin<span style="color: #000000; font-weight: bold;">/</span>autoaudio.sh <span style="color: #000000; font-weight: bold;">%</span>FILE<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">%</span>STARTTIMEISO<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #ff0000;">&quot;%TITLE%&quot;</span></pre></div></div>

<p>Choose &#8220;Finish&#8221; so you are back at the mythbackend main menu. Now we need to allow the job to run, so go back into &#8220;General&#8221; and scroll through to the screen titled &#8220;Job Queue (Backend-Specific)&#8221;. Tick the box for &#8220;Allow Convert to MP3 jobs&#8221;. Click &#8220;Next&#8221; and &#8220;Finish&#8221; until you are back to the main menu.</p>
<p><strong>All Done</strong><br />
That&#8217;s it, you now have a user job which will convert shows to MP3, let&#8217;s check it works. I use <a href="http://www.mythtv.org/wiki/MythWeb" target="_blank">MythWeb</a> to manage things most of the time. In MythWeb, go to &#8220;Recorded Programs&#8221;, Click on a show title, then under &#8220;Queue a job&#8221; click the &#8220;Convert to MP3&#8243; button. If all went well you should see an MP3 file created in the output directory you specified in autoaudio.sh. There may be a delay between clicking the button and an MP3 being created depending on how often your mythbackend is set to run user jobs. If nothing is created check the mythbackend logfile at /var/log/mythtv/mythbackend.log for errors.</p>
<p>Once it&#8217;s all working it can be activated on an existing recording schedule.  In MythWeb, go to &#8220;Recording Schedules&#8221;, click on a schedule you have setup and look under &#8220;Advanced Options&#8221;. You should see a tick box for &#8220;Convert to MP3&#8243;. The show will now be converted to MP3 every time it records.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/02/automatically-convert-radio-shows-to-mp3-format/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Updated imdb.pl for getting hi-res movie posters</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/02/updated-imdbpl-for-getting-hi-res-movie-posters/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/02/updated-imdbpl-for-getting-hi-res-movie-posters/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 12:52:07 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Backend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[covers]]></category>

		<category><![CDATA[imdb]]></category>

		<category><![CDATA[imdb.pl]]></category>

		<category><![CDATA[posters]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=62</guid>
		<description><![CDATA[The current version of imdb.pl included with MythTV is not downloading hi-res poster images for movies due to a site change at IMDB&#8217;s end. I have edited imdb.pl to include a fix as detailed in https://bugs.launchpad.net/mythbuntu/+bug/256027 and included below.
To get it going, backup your old imdb.pl file in /usr/share/mythtv/mythvideo/scripts/ and replace with:

#!/usr/bin/perl -w
&#160;
#
# This perl [...]]]></description>
			<content:encoded><![CDATA[<p>The current version of imdb.pl included with MythTV is not downloading hi-res poster images for movies due to a site change at IMDB&#8217;s end. I have edited imdb.pl to include a fix as detailed in <a href="https://bugs.launchpad.net/mythbuntu/+bug/256027" target="_blank">https://bugs.launchpad.net/mythbuntu/+bug/256027</a> and included below.</p>
<p>To get it going, backup your old imdb.pl file in /usr/share/mythtv/mythvideo/scripts/ and replace with:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl -w</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># This perl script is intended to perform movie data lookups based on</span>
<span style="color: #666666; font-style: italic;"># the popular www.imdb.com website</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># For more information on MythVideo's external movie lookup mechanism, see</span>
<span style="color: #666666; font-style: italic;"># the README file in this directory.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Author: Tim Harvey (tharvey AT alumni.calpoly DOT edu)</span>
<span style="color: #666666; font-style: italic;"># Modified: Andrei Rjeousski</span>
<span style="color: #666666; font-style: italic;"># v1.1</span>
<span style="color: #666666; font-style: italic;"># - Added amazon.com covers and improved handling for imdb posters</span>
<span style="color: #666666; font-style: italic;"># v1.2</span>
<span style="color: #666666; font-style: italic;">#     - when searching amazon, try searching for main movie name and if nothing</span>
<span style="color: #666666; font-style: italic;">#       is found, search for informal name</span>
<span style="color: #666666; font-style: italic;">#     - better handling for amazon posters, see if movie title is a substring</span>
<span style="color: #666666; font-style: italic;">#       in the search results returned by amazon</span>
<span style="color: #666666; font-style: italic;">#     - fixed redirects for some movies on impawards</span>
<span style="color: #666666; font-style: italic;"># v1.3</span>
<span style="color: #666666; font-style: italic;">#     - fixed search for low res images (imdb changed the page layout)</span>
<span style="color: #666666; font-style: italic;">#     - added cinemablend poster search</span>
<span style="color: #666666; font-style: italic;">#     - added nexbase poster search</span>
<span style="color: #666666; font-style: italic;">#     - removed amazon.com searching for now</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># changes:</span>
<span style="color: #666666; font-style: italic;"># 10-26-2007:</span>
<span style="color: #666666; font-style: italic;">#   Added release date (in ISO 8601 form) to output</span>
<span style="color: #666666; font-style: italic;"># 9-10-2006: Anduin Withers</span>
<span style="color: #666666; font-style: italic;">#   Changed output to utf8</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> LWP<span style="color: #339933;">::</span><span style="color: #006600;">Simple</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;"># libwww-perl providing simple HTML get actions</span>
<span style="color: #000000; font-weight: bold;">use</span> HTML<span style="color: #339933;">::</span><span style="color: #006600;">Entities</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> URI<span style="color: #339933;">::</span><span style="color: #006600;">Escape</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">eval</span> <span style="color: #ff0000;">&quot;use DateTime::Format::Strptime&quot;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$has_date_format</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$@</span> <span style="color: #339933;">?</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> vars <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$opt_h</span> <span style="color: #0000ff;">$opt_r</span> <span style="color: #0000ff;">$opt_d</span> <span style="color: #0000ff;">$opt_i</span> <span style="color: #0000ff;">$opt_v</span> <span style="color: #0000ff;">$opt_D</span> <span style="color: #0000ff;">$opt_M</span> <span style="color: #0000ff;">$opt_P</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Getopt<span style="color: #339933;">::</span><span style="color: #006600;">Std</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;IMDB Query&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$version</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;v1.3.5&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$author</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Tim Harvey, Andrei Rjeousski&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@countries</span> <span style="color: #339933;">=</span> <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span>USA UK Canada Japan<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">binmode</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">STDOUT</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;:utf8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># display usage</span>
<span style="color: #000000; font-weight: bold;">sub</span> usage <span style="color: #009900;">&#123;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;usage: $0 -hdrviMPD [parameters]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -h           help<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -d           debug<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -r           dump raw query result data only<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -v           display version<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -i           display info<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -M [options] &lt;query&gt;    get movie list<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;               some known options are:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;                  type=[fuzy]         looser search<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;                  from_year=[int]     limit matches to year<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;                  to_year=[int]       limit matches to year<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;                  sort=[smart]        ??<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;                  tv=[no|both|only]   limits between tv and movies<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;               Note: multiple options must be separated by ';'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -P &lt;movieid&gt;  get movie poster<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;       -D &lt;movieid&gt;  get movie data<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># display 1-line of info that describes the version of the program</span>
<span style="color: #000000; font-weight: bold;">sub</span> version <span style="color: #009900;">&#123;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$title ($version) by $author<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># display 1-line of info that can describe the type of query used</span>
<span style="color: #000000; font-weight: bold;">sub</span> info <span style="color: #009900;">&#123;</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Performs queries using the www.imdb.com website.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># display detailed help</span>
<span style="color: #000000; font-weight: bold;">sub</span> help <span style="color: #009900;">&#123;</span>
   version<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   info<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   usage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> trim <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$str</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s+//</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$str</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s+$//</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">return</span> <span style="color: #0000ff;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># returns text within 'data' between 'beg' and 'end' matching strings</span>
<span style="color: #000000; font-weight: bold;">sub</span> parseBetween <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$beg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$end</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># grab parameters</span>
&nbsp;
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$ldata</span> <span style="color: #339933;">=</span> <span style="color: #000066;">lc</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ldata</span><span style="color: #339933;">,</span> <span style="color: #000066;">lc</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$beg</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$beg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">=</span> <span style="color: #000066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$ldata</span><span style="color: #339933;">,</span> <span style="color: #000066;">lc</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$end</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$start</span> <span style="color: #339933;">!=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$beg</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$start</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;"># return w/ decoded numeric character references</span>
      <span style="color: #666666; font-style: italic;"># (see http://www.w3.org/TR/html4/charset.html#h-5.3.1)</span>
      decode_entities<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066;">return</span> <span style="color: #0000ff;">$result</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000066;">return</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># get Movie Data</span>
<span style="color: #000000; font-weight: bold;">sub</span> getMovieData <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$movieid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># grab movieid parameter</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# looking for movie id: '%s'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$movieid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$name_link_pat</span> <span style="color: #339933;">=</span> <span style="color: #000066;">qr</span><span style="color: #ff0000;">'&lt;a href=&quot;/name/[^&quot;]*&quot;&gt;([^&lt;]*)&lt;/a&gt;'</span><span style="color: #000066;">m</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># get the search results  page</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$request</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.imdb.com/title/tt&quot;</span> . <span style="color: #0000ff;">$movieid</span> . <span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# request: '%s'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$request</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># parse title and year</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$year</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;title&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/title&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$title</span> <span style="color: #339933;">=~</span> <span style="color: #000066;">m</span><span style="color: #666666; font-style: italic;">#(.+) \((\d+).*\)#) # Note some years have a /II after them?</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">$year</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$2</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$title</span> <span style="color: #339933;">=~</span> <span style="color: #000066;">m</span><span style="color: #666666; font-style: italic;">#(.+) \(\?\?\?\?\)#)</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># parse director</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Director:&lt;/h5&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Directors:&lt;/h5&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$director</span> <span style="color: #339933;">=</span> <span style="color: #000066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/$name_link_pat/g</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># parse writer</span>
   <span style="color: #666666; font-style: italic;"># (Note: this takes the 'first' writer, may want to include others)</span>
   <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Writers &lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>/wga<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;(WGA)&lt;/a&gt;:&lt;/h5&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Writer:&lt;/h5&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Writers:&lt;/h5&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$writer</span> <span style="color: #339933;">=</span> <span style="color: #000066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/$name_link_pat/g</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># parse release date</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$releasedate</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">''</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$has_date_format</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dtp</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #339933;">::</span><span style="color: #006600;">Format</span><span style="color: #339933;">::</span><span style="color: #006600;">Strptime</span><span style="color: #009900;">&#40;</span>pattern <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'%d %b %Y'</span><span style="color: #339933;">,</span>
         on_error <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'undef'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$dt</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dtp</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">parse_datetime</span><span style="color: #009900;">&#40;</span>parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span>
            <span style="color: #ff0000;">&quot;&gt;Release Date:&lt;/h5&gt; &quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;a &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$dt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #0000ff;">$releasedate</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$dt</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">strftime</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%F&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># parse plot</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$plot</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Plot Outline:&lt;/h5&gt; &quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$plot</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$plot</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Plot Summary:&lt;/h5&gt; &quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$plot</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$plot</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&gt;Plot:&lt;/h5&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$plot</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #666666; font-style: italic;"># replace name links in plot (example 0388795)</span>
      <span style="color: #0000ff;">$plot</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/$name_link_pat/$1/g</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># replace title links</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$title_link_pat</span> <span style="color: #339933;">=</span> <span style="color: #000066;">qr</span><span style="color: #339933;">!&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;/title/[^&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #ff0000;">&quot;&gt;([^&lt;]*)&lt;/a&gt;!m;
      $plot =~ s/$title_link_pat/$1/g;
&nbsp;
      # plot ends at first remaining link
      my $plot_end = index($plot, &quot;</span><span style="color: #339933;">&lt;</span>a <span style="color: #ff0000;">&quot;);
      if ($plot_end != -1) {
         $plot = substr($plot, 0, $plot_end);
      }
      $plot = trim($plot);
   }
&nbsp;
   # parse user rating
   my $userrating = parseBetween($response, &quot;</span><span style="color: #339933;">&gt;</span>User Rating<span style="color: #339933;">:&lt;/</span>b<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #339933;">&lt;/</span>b<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
   $userrating = parseBetween($userrating, &quot;</span><span style="color: #009999;">&lt;b&gt;</span><span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #339933;">/</span><span style="color: #ff0000;">&quot;);
&nbsp;
   # parse MPAA rating
   my $ratingcountry = &quot;</span>USA<span style="color: #ff0000;">&quot;;
   my $movierating = trim(parseBetween($response, &quot;</span><span style="color: #339933;">&gt;</span>MPAA<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;:&lt;/</span>h5<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;));
   if (!$movierating) {
       $movierating = parseBetween($response, &quot;</span><span style="color: #339933;">&gt;</span>Certification<span style="color: #339933;">:&lt;/</span>h5<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
       $movierating = parseBetween($movierating, &quot;</span>certificates<span style="color: #339933;">=</span><span style="color: #0000ff;">$ratingcountry</span><span style="color: #ff0000;">&quot;,
                                   &quot;</span><span style="color: #339933;">/</span>a<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
       $movierating = parseBetween($movierating, &quot;</span><span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #339933;">&lt;</span><span style="color: #ff0000;">&quot;);
   }
&nbsp;
   # parse movie length
   my $rawruntime = trim(parseBetween($response, &quot;</span><span style="color: #339933;">&gt;</span>Runtime<span style="color: #339933;">:&lt;/</span>h5<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;, &quot;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;));
   my $runtime = trim(parseBetween($rawruntime, &quot;</span><span style="color: #ff0000;">&quot;, &quot;</span> min<span style="color: #ff0000;">&quot;));
   for my $country (@countries) {
      last if ($runtime =~ /^-?<span style="color: #000099; font-weight: bold;">\d</span>/);
      $runtime = trim(parseBetween($rawruntime, &quot;</span><span style="color: #0000ff;">$country</span><span style="color: #339933;">:</span><span style="color: #ff0000;">&quot;, &quot;</span> min<span style="color: #ff0000;">&quot;));
   }
&nbsp;
   # parse cast
   #  Note: full cast would be from url:
   #    www.imdb.com/title/&lt;movieid&gt;/fullcredits
   my $cast = &quot;</span><span style="color: #ff0000;">&quot;;
   $data = parseBetween($response, &quot;</span>Cast overview<span style="color: #339933;">,</span> first billed only<span style="color: #ff0000;">&quot;,
                               &quot;</span><span style="color: #339933;">/</span>table<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
   if (!$data) {
       $data = parseBetween($response, &quot;</span>Series Cast Summary<span style="color: #ff0000;">&quot;,
                               &quot;</span><span style="color: #339933;">/</span>table<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
   }
&nbsp;
   if (!$data) {
       $data = parseBetween($response, &quot;</span>Complete credited cast<span style="color: #ff0000;">&quot;,
                               &quot;</span><span style="color: #339933;">/</span>table<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
   }
&nbsp;
   if ($data) {
      $cast = join(',', ($data =~ m/$name_link_pat/g));
      $cast = trim($cast);
   }
&nbsp;
&nbsp;
   # parse genres
   my $lgenres = &quot;</span><span style="color: #ff0000;">&quot;;
   $data = parseBetween($response, &quot;</span><span style="color: #009999;">&lt;h5&gt;</span>Genre<span style="color: #339933;">:&lt;/</span>h5<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;,&quot;</span><span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><span style="color: #ff0000;">&quot;);
   if ($data) {
      my $genre_pat = qr'/Sections/Genres/(?:[a-z ]+/)*&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>^<span style="color: #339933;">&lt;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&lt;</span><span style="color: #ff0000;">'im;
      $lgenres = join('</span><span style="color: #339933;">,</span><span style="color: #ff0000;">', ($data =~ /$genre_pat/g));
   }
&nbsp;
   # parse countries
   $data = parseBetween($response, &quot;Country:&lt;/h5&gt;&quot;,&quot;&lt;/div&gt;&quot;);
   my $country_pat = qr'</span><span style="color: #339933;">/</span>Sections<span style="color: #339933;">/</span>Countries<span style="color: #339933;">/</span><span style="color: #009900;">&#91;</span>A<span style="color: #339933;">-</span>Z<span style="color: #009900;">&#93;</span><span style="color: #339933;">+/</span><span style="color: #ff0000;">&quot;&gt;([^&lt;]+)&lt;/a&gt;'i;
   my $lcountries = trim(join(&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;, ($data =~ m/$country_pat/g)));
&nbsp;
   # output fields (these field names must match what MythVideo is looking for)
   print &quot;</span>Title<span style="color: #339933;">:</span><span style="color: #0000ff;">$title</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Year<span style="color: #339933;">:</span><span style="color: #0000ff;">$year</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>ReleaseDate<span style="color: #339933;">:</span><span style="color: #0000ff;">$releasedate</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Director<span style="color: #339933;">:</span><span style="color: #0000ff;">$director</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Plot<span style="color: #339933;">:</span><span style="color: #0000ff;">$plot</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>UserRating<span style="color: #339933;">:</span><span style="color: #0000ff;">$userrating</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>MovieRating<span style="color: #339933;">:</span><span style="color: #0000ff;">$movierating</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Runtime<span style="color: #339933;">:</span><span style="color: #0000ff;">$runtime</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Writers<span style="color: #339933;">:</span> <span style="color: #0000ff;">$writer</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Cast<span style="color: #339933;">:</span><span style="color: #0000ff;">$cast</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Genres<span style="color: #339933;">:</span> <span style="color: #0000ff;">$lgenres</span>\n<span style="color: #ff0000;">&quot;;
   print &quot;</span>Countries<span style="color: #339933;">:</span> <span style="color: #0000ff;">$lcountries</span>\n<span style="color: #ff0000;">&quot;;
}
&nbsp;
# dump Movie Poster
sub getMoviePoster {
   my ($movieid)=@_; # grab movieid parameter
   if (defined $opt_d) { printf(&quot;</span><span style="color: #666666; font-style: italic;"># looking for movie id: '%s'\n&quot;, $movieid);}</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># get the search results  page</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$request</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.imdb.com/title/tt&quot;</span> . <span style="color: #0000ff;">$movieid</span> . <span style="color: #ff0000;">&quot;/posters&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# request: '%s'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$request</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$response</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">return</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># look for references to impawards.com posters - they are high quality</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$site</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.impawards.com&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$impsite</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>.<span style="color: #0000ff;">$site</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$impsite</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$impsite</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$site</span> . <span style="color: #0000ff;">$impsite</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# Searching for poster at: &quot;</span>.<span style="color: #0000ff;">$impsite</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$impres</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$impsite</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# got %i bytes<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$impres</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$impres</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># making sure it isnt redirect</span>
      <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$impres</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;0;URL=..&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# processing redirect to %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
         <span style="color: #666666; font-style: italic;"># this was redirect</span>
         <span style="color: #0000ff;">$impsite</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$site</span> . <span style="color: #0000ff;">$uri</span><span style="color: #339933;">;</span>
         <span style="color: #0000ff;">$impres</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$impsite</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># do stuff normally</span>
      <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$impres</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;img SRC=<span style="color: #000099; font-weight: bold;">\&quot;</span>posters/&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> ALT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #666666; font-style: italic;"># uri here is relative... patch it up to make a valid uri</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/\.(jpe?g|gif|png)$/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/http:(.*)/</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
             <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$impsite</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$impsite</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'/'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
             <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$path</span>.<span style="color: #ff0000;">&quot;posters/&quot;</span>.<span style="color: #0000ff;">$uri</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# found ipmawards poster: $uri<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># try looking on MoTechPosters </span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> eq <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;a href=&quot;([^&quot;]*)&quot;&gt;([^&quot;]*?)motechposters/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# found MoTechPosters poster page: $1 <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cinres</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# got %i bytes<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
           <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cinres</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;img src=&quot;([^&quot;]*?$movieid[^&quot;]*?)&quot;/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
             <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# MoTechPosters url retreived<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
               <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://posters.motechnet.com&quot;</span>.<span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># try looking on nexbase</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> eq <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;a href=&quot;([^&quot;]*)&quot;&gt;([^&quot;]*?)nexbase/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# found nexbase poster page: $1 <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
         <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cinres</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# got %i bytes<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cinres</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;a id=&quot;photo_url&quot; href=&quot;([^&quot;]*?)&quot; &gt;&lt;\/a&gt;/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# nexbase url retreived<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
               <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># try looking on cinemablend</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> eq <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;a href=&quot;([^&quot;]*)&quot;&gt;([^&quot;]*?)cinemablend/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# found cinemablend poster page: $1 <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
         <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$cinres</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# got %i bytes<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$cinres</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$cinres</span> <span style="color: #339933;">=~</span> <span style="color: #000066;">m</span><span style="color: #666666; font-style: italic;">#&lt;img\b[^&gt;]+\bsrc=&quot;(/images/reviews/[^&quot;]*?)&quot;#i) {</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# cinemablend url retreived<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.cinemablend.com/&quot;</span>.<span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># if the impawards site attempt didn't give a filename grab it from imdb</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> eq <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# looking for imdb posters<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
       <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$host</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://posters.imdb.com/posters/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$host</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&lt;td&gt;&lt;td&gt;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$host</span>.<span style="color: #0000ff;">$uri</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# no poster found<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@movie_titles</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$found_low_res</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$k</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># no poster found, take lowres image from imdb</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$uri</span> eq <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# looking for lowres imdb posters<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$host</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.imdb.com/title/tt&quot;</span> . <span style="color: #0000ff;">$movieid</span> . <span style="color: #ff0000;">&quot;/&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$host</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># Better handling for low resolution posters</span>
      <span style="color: #666666; font-style: italic;">#</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;a name=&quot;poster&quot;.*&lt;img.*src=&quot;([^&quot;]*).*&lt;\/a&gt;/ig</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# found low res poster at: $1<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
         <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
         <span style="color: #0000ff;">$found_low_res</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# no low res poster found<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
         <span style="color: #0000ff;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# starting to look for movie title<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># get main title</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# Getting possible movie titles:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #0000ff;">$movie_titles</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$k</span><span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;title&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;<span style="color: #000099; font-weight: bold;">\/</span>title&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# Title: &quot;</span>.<span style="color: #0000ff;">$movie_titles</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$k</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># now we get all other possible movie titles and store them in the titles array</span>
      <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&gt;([^&gt;^\(]*)([ ]{0,1}\([^\)]*\)[^\(^\)]*[ ]{0,1}){0,1}\(informal title\)/g</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #0000ff;">$movie_titles</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$k</span><span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> trim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;# Title: &quot;</span>.<span style="color: #0000ff;">$movie_titles</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$k</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$uri<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># dump Movie list:  1 entry per line, each line as 'movieid:Movie Title'</span>
<span style="color: #000000; font-weight: bold;">sub</span> getMovieList <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$filename</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@_</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;"># grab parameters</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># If we wanted to inspect the file for any reason we can do that now</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">#</span>
   <span style="color: #666666; font-style: italic;"># Convert filename into a query string</span>
   <span style="color: #666666; font-style: italic;"># (use same rules that Metadata::guesTitle does)</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$filename</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> uri_unescape<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;"># in case it was escaped</span>
   <span style="color: #666666; font-style: italic;"># Strip off the file extension</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'.'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #666666; font-style: italic;"># Strip off anything following '(' - people use this for general comments</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'('</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'('</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #666666; font-style: italic;"># Strip off anything following '[' - people use this for general comments</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'['</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000066;">rindex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'['</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># IMDB searches do better if any trailing ,The is left off</span>
   <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/(.*), The$/i</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># prepare the url</span>
   <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> uri_escape<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$options</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# query: '%s', options: '%s'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># get the search results  page</span>
   <span style="color: #666666; font-style: italic;">#    some known IMDB options are:</span>
   <span style="color: #666666; font-style: italic;">#         type=[fuzy]         looser search</span>
   <span style="color: #666666; font-style: italic;">#         from_year=[int]     limit matches to year (broken at imdb)</span>
   <span style="color: #666666; font-style: italic;">#         to_year=[int]       limit matches to year (broken at imdb)</span>
   <span style="color: #666666; font-style: italic;">#         sort=[smart]        ??</span>
   <span style="color: #666666; font-style: italic;">#         tv=[no|both|only]   limits between tv and movies (broken at imdb)</span>
   <span style="color: #666666; font-style: italic;">#$options = &quot;tt=on;nm=on;mx=20&quot;;  # not exactly clear what these options do</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$request</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.imdb.com/find?q=$query;$options&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# request: '%s'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$request</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$response</span> <span style="color: #339933;">=</span> get <span style="color: #0000ff;">$request</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_r</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">print</span> <span style="color: #0000ff;">$response</span><span style="color: #339933;">;</span>
      <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># check to see if we got a results page or a movie page</span>
   <span style="color: #666666; font-style: italic;">#    looking for 'add=&lt;movieid&gt;&quot; target=' which only exists</span>
   <span style="color: #666666; font-style: italic;">#    in a movie description page</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$movienum</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;add=&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$movienum</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$movienum</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;;add=&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$movienum</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$movienum</span> <span style="color: #339933;">!~</span> <span style="color: #009966; font-style: italic;">m/^[0-9]+$/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# Error: IMDB movie number ($movienum), isn't.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# redirected to movie page<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$movietitle</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;title&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;/title&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">$movietitle</span> <span style="color: #339933;">=~</span> <span style="color: #000066;">m</span><span style="color: #666666; font-style: italic;">#(.+) \((\d+)\)#;</span>
      <span style="color: #0000ff;">$movietitle</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
      <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$movienum:$movietitle<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># extract possible matches</span>
   <span style="color: #666666; font-style: italic;">#    possible matches are grouped in several catagories:</span>
   <span style="color: #666666; font-style: italic;">#        exact, partial, and approximate</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$popular_results</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;b&gt;Popular Titles&lt;/b&gt;&quot;</span><span style="color: #339933;">,</span>
                                              <span style="color: #ff0000;">&quot;&lt;/table&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$exact_matches</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;b&gt;Titles (Exact Matches)&lt;/b&gt;&quot;</span><span style="color: #339933;">,</span>
                                              <span style="color: #ff0000;">&quot;&lt;/table&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$partial_matches</span> <span style="color: #339933;">=</span> parseBetween<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$response</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;&lt;b&gt;Titles (Partial Matches)&lt;/b&gt;&quot;</span><span style="color: #339933;">,</span>
                                              <span style="color: #ff0000;">&quot;&lt;/table&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#   my $approx_matches = parseBetween($response, &quot;&lt;b&gt;Titles (Approx Matches)&lt;/b&gt;&quot;,</span>
<span style="color: #666666; font-style: italic;">#                                               &quot;&lt;/table&gt;&quot;);</span>
   <span style="color: #666666; font-style: italic;"># parse movie list from matches</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$beg</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&lt;tr&gt;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$end</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&lt;/tr&gt;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@movies</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#   my $data = $exact_matches.$partial_matches;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$popular_results</span>.<span style="color: #0000ff;">$exact_matches</span><span style="color: #339933;">;</span>
   <span style="color: #666666; font-style: italic;"># resort to partial matches if no exact</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span> eq <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$data</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$partial_matches</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
   <span style="color: #666666; font-style: italic;"># resort to approximate matches if no exact or partial</span>
<span style="color: #666666; font-style: italic;">#   if ($data eq &quot;&quot;) { $data = $approx_matches; }</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span> eq <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# no results<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #000066;">return</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$beg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">=</span> <span style="color: #000066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$end</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$year</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$title</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$start</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$start</span> <span style="color: #339933;">&lt;</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$start</span> <span style="color: #339933;">+=</span> <span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$beg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$entry</span> <span style="color: #339933;">=</span> <span style="color: #000066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$start</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">-</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">$start</span> <span style="color: #339933;">=</span> <span style="color: #000066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$beg</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">$finish</span> <span style="color: #339933;">=</span> <span style="color: #000066;">index</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$end</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$start</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$year</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$movienum</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># Some titles are identical, IMDB indicates this by appending /I /II to</span>
      <span style="color: #666666; font-style: italic;"># the release year.</span>
      <span style="color: #666666; font-style: italic;">#   e.g. &quot;Mon meilleur ami&quot; 2006/I vs &quot;Mon meilleur ami&quot; 2006/II</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$entry</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">m/&lt;a href=&quot;\/title\/tt(\d+)\/.*\&quot;&gt;(.+)&lt;\/a&gt; \((\d+)\/?[a-z]*\)(?: \((.+)\))?/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #0000ff;">$movienum</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span>
          <span style="color: #0000ff;">$title</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$2</span><span style="color: #339933;">;</span>
          <span style="color: #0000ff;">$year</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$3</span><span style="color: #339933;">;</span>
          <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$4</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Unrecognized entry format ($entry)<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
           <span style="color: #b1b100;">next</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># fix broken 'tv=no' option</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$options</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/tv=no/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> eq <span style="color: #ff0000;">&quot;TV&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# skipping TV program: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$options</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/tv=only/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> eq <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# skipping Movie: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #666666; font-style: italic;"># fix broken 'from_year=' option</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$options</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/from_year=(\d+)/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$year</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000ff;">$1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# skipping b/c of yr: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #666666; font-style: italic;"># fix broken 'to_year=' option</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$options</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/to_year=(\d+)/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$year</span> <span style="color: #339933;">&gt;</span> <span style="color: #0000ff;">$1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# skipping b/c of yr: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># option to strip out videos (I think that's what '(V)' means anyway?)</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$options</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/video=no/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> eq <span style="color: #ff0000;">&quot;V&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# skipping Video program: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># (always) strip out video game's (why does IMDB give these anyway?)</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span> eq <span style="color: #ff0000;">&quot;VG&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_d</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;# skipping videogame: %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
         <span style="color: #0000ff;">$skip</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #666666; font-style: italic;"># add to array</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$skip</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$moviename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$title</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$year</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              <span style="color: #0000ff;">$moviename</span> .<span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot; ($year)&quot;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#         $movies[$count++] = $movienum . &quot;:&quot; . $title;</span>
         <span style="color: #0000ff;">$movies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$count</span><span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$movienum</span> . <span style="color: #ff0000;">&quot;:&quot;</span> . <span style="color: #0000ff;">$moviename</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># display array of values</span>
   <span style="color: #b1b100;">for</span> <span style="color: #0000ff;">$movie</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@movies</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$movie<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Main Program</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># parse command line arguments</span>
getopts<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'ohrdivDMP'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># print out info</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> version<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> info<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># print out usage if needed</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_h</span> <span style="color: #339933;">||</span> $#ARGV<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> help<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_D</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;"># take movieid from cmdline arg</span>
   <span style="color: #0000ff;">$movieid</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Usage : $0 -D &lt;movieid&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   getMovieData<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$movieid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_P</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;"># take movieid from cmdline arg</span>
   <span style="color: #0000ff;">$movieid</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Usage : $0 -P &lt;movieid&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   getMoviePoster<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$movieid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">elsif</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">defined</span> <span style="color: #0000ff;">$opt_M</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;"># take query from cmdline arg</span>
   <span style="color: #0000ff;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Usage : $0 -M [options] &lt;query&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #0000ff;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$options</span><span style="color: #339933;">;</span>
      <span style="color: #0000ff;">$options</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   getMovieList<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$query</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;"># vim: set expandtab ts=3 sw=3 :</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/02/updated-imdbpl-for-getting-hi-res-movie-posters/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Quickly Sort Channels</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/02/quickly-sort-channels/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/02/quickly-sort-channels/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 14:00:27 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Backend]]></category>

		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[channels]]></category>

		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=45</guid>
		<description><![CDATA[Something that&#8217;s not quite perfect in MythTV is sorting channels. You can move channels around one by one in the backend setup screens but this is slow and boring. A quicker way is to update the channel table in the mythconverg database on your backed. I had a search around and found this useful post [...]]]></description>
			<content:encoded><![CDATA[<p>Something that&#8217;s not quite perfect in MythTV is sorting channels. You can move channels around one by one in the backend setup screens but this is slow and boring. A quicker way is to update the channel table in the mythconverg database on your backed. I had a search around and found <a href="http://ubuntuforums.org/showthread.php?t=497488" target="_blank">this useful post</a> on the Ubuntu forms but it was still a pain to have to adjust the SQL strings as they were.  My solution is to put the SQL into to a spreadsheet (attached below):</p>
<p><a href="http://www.oneweb.co.uk/mythtv/wp-content/uploads/2009/02/channel_order.xls"></a><a href="http://www.oneweb.co.uk/mythtv/wp-content/uploads/2009/02/channel_order.xls">Channel Order Helper Spreadsheet</a></p>
<p>Obviously your channel listing is going do be different to mine so I suggest you do the following:</p>
<ol>
<li>Download the spreadsheet</li>
<li>Get your existing channel names by running:

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #990099; font-weight: bold;">DISTINCT</span> name <span style="color: #990099; font-weight: bold;">FROM</span> channel <span style="color: #990099; font-weight: bold;">ORDER BY</span> <span style="color: #000099;">LPAD</span><span style="color: #FF00FF;">&#40;</span>channum<span style="color: #000033;">,</span> <span style="color: #008080;">3</span><span style="color: #000033;">,</span> <span style="color: #008080;">0</span><span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">ASC</span><span style="color: #000033;">;</span></pre></div></div>

</li>
<li>Paste them into column D in the spread sheet</li>
<li>Re-arrange as required</li>
<li>Select all the cells and copy into gedit or similar (removing any tabs)</li>
<li>Run all statements agains your mythconverg database.</li>
</ol>
<p>NB. This will update the channel numbers for all sources (you could always change the sql to include a &#8220;WHERE sourceid = 1&#8243; clause or simialr. Also, make sure that your frontend is set to sort by &#8220;Channel Number&#8221; in &#8220;Utilities/Setup&#8221; -&gt; &#8220;Setup&#8221; -&gt; &#8220;TV&#8221; -&gt; &#8220;Settings&#8221; -&gt; &#8220;General&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/02/quickly-sort-channels/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Play 720p HD Content Over Wireless &amp; Make The Subtitle Size Sensible</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/02/play-hd-720p-content-over-wireless-make-the-subtitle-size-sensible/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/02/play-hd-720p-content-over-wireless-make-the-subtitle-size-sensible/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 22:29:51 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[720p]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[hd]]></category>

		<category><![CDATA[mplayer]]></category>

		<category><![CDATA[subtitles]]></category>

		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=32</guid>
		<description><![CDATA[This one drove me nuts for a while, watching 720p content over 54Mbit/s wi-fi should work fine but with the &#8220;out of the box&#8221; settings HD moves were stuttering terribly for me.
As an additional niggle, embedded subtitles were appearing but they were enormous.
By default MythTV uses mplayer for mkv, avi and mpeg files. To resolve [...]]]></description>
			<content:encoded><![CDATA[<p>This one drove me nuts for a while, watching 720p content over 54Mbit/s wi-fi should work fine but with the &#8220;out of the box&#8221; settings HD moves were stuttering terribly for me.</p>
<p>As an additional niggle, embedded subtitles were appearing but they were enormous.</p>
<p>By default MythTV uses mplayer for mkv, avi and mpeg files. To resolve the stutter and subtitle issue open the MythTV frontend and go to &#8220;Utilities / Setup&#8221; -&gt; &#8220;Setup&#8221; -&gt; &#8220;Media Settings&#8221; -&gt; &#8220;Video Settings&#8221; -&gt; &#8220;Player Settings&#8221; and set the &#8220;Default Video Player&#8221; to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mplayer</span> <span style="color: #660033;">-fs</span> <span style="color: #660033;">-zoom</span> <span style="color: #660033;">-quiet</span> <span style="color: #660033;">-vo</span> xv <span style="color: #660033;">-subfont-text-scale</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-cache</span> <span style="color: #000000;">8912</span> <span style="color: #660033;">-cache-min</span> <span style="color: #000000;">4</span> <span style="color: #660033;">-lavdopts</span> <span style="color: #007800;">threads</span>=<span style="color: #000000;">2</span>:fast:<span style="color: #007800;">skiploopfilter</span>=all <span style="color: #660033;">-sws</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">%</span>s</pre></div></div>

<p>You may find it easier to connect to the mythconverg database and set the VideoDefaultPlayer to the value above for the host machine on wireless.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/02/play-hd-720p-content-over-wireless-make-the-subtitle-size-sensible/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Configuring Your MCE IR Remote</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/02/configuring-your-mce-ir-remote/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/02/configuring-your-mce-ir-remote/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 21:48:31 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[Frontend]]></category>

		<category><![CDATA[MythTv]]></category>

		<category><![CDATA[buttons]]></category>

		<category><![CDATA[keyboard]]></category>

		<category><![CDATA[lirc]]></category>

		<category><![CDATA[MCE]]></category>

		<category><![CDATA[Remote]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=11</guid>
		<description><![CDATA[You can use the keyboard to control absouletly everything in MythTV but it&#8217;s not that practical once the lights are out and you&#8217;re mid movie. So one of the first things I was looking to do is get my Microsoft MCE remote working just the way I wanted.
For some background info you might want to [...]]]></description>
			<content:encoded><![CDATA[<p>You can use the keyboard to control absouletly everything in MythTV but it&#8217;s not that practical once the lights are out and you&#8217;re mid movie. So one of the first things I was looking to do is get my Microsoft MCE remote working just the way I wanted.</p>
<p>For some background info you might want to check out the MCE Remote section of the MythTV wiki <a href="http://www.mythtv.org/wiki/MCE_Remote" target="_blank">here</a>.</p>
<p>MythTV does a pretty good job of setting up some defaults for the buttons but, if like me you&#8217;ve come from a Windows MCE system you may fine the lirc config files and associated script below useful.</p>
<p>These configs do four things above the functionality MythTV provides out of the box:</p>
<ol>
<li>Start / Restart mythfrontend when &#8220;the big green button&#8221; is pressed (handy if the frontend ever misbehaves)</li>
<li>Cycle through subtitles when watching TV or movies in mplayer</li>
<li>Make the Red button behave as expected for interactive TV. Green, Yellow, Blue and Teletext also act as they should.</li>
<li>Make other buttons behave as a Windows MCE user would expect.</li>
</ol>
<p>Here&#8217;s how all the buttons will function once everything is set up:</p>
<div id="attachment_19" class="wp-caption alignnone" style="width: 460px"><img class="size-full wp-image-19" title="MCE Remote Mappings" src="http://www.oneweb.co.uk/mythtv/wp-content/uploads/2009/02/mce-remote.jpg" alt="MCE Remote Mappings" width="450" height="550" /><p class="wp-caption-text">MCE Remote Mappings</p></div>
<p><strong><br />
Girlfriend proof it</strong></p>
<p>A small tip which helps with the gf factor is removing the exit and shutdown menu when the back button is pressed from the main menu. To do this, in the frontend go to &#8220;Utilities / Setup&#8221; -&gt; &#8220;Setup&#8221; -&gt; &#8220;General&#8221;. Go to the fourth screen with the title of  &#8220;General&#8221; and change the &#8220;System Exit Key&#8221; to &#8220;No exit key&#8221;. You can always exit the frontend with &#8220;alt F4&#8243; if you need to.</p>
<p><strong>Bash script to start / restart the frontend</strong></p>
<p>The first thing to do is setup the bash script which will start or restart the MythTV frontend application when the big green button on your remote is pressed. Copy the script below and put it in a new file in your home directory.  I put mine in ~/mythtv/runmyth</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">RUNNING</span>=<span style="color: #000000;">0</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> x <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-C</span> mythfrontend.re <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> PID<span style="color: #000000; font-weight: bold;">`</span> end; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #007800;">$x</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">'mythfrontend.re'</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">&amp;</span>amp; <span style="color: #7a0874; font-weight: bold;">continue</span>
    <span style="color: #007800;">RUNNING</span>=<span style="color: #000000;">1</span>;
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RUNNING</span> = <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #666666; font-style: italic;">#kill the process</span>
   <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-9</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-aef</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">'mythfrontend.re'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #666666; font-style: italic;">#start it up again</span>
  <span style="color: #000000; font-weight: bold;">`</span>mythfrontend <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #000000; font-weight: bold;">`</span>mythfrontend <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Don&#8217;t forget to make it executable</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> runmyth</pre></div></div>

<p><strong>lirc config files</strong><br />
Now that&#8217;s out the way here follows the lirc files for MythTV and mplayer. They should go into ~/.lirc/mythtv and ~/.lirc/mplayer respectively. Make sure the runmyth script path is defined correctly on line four of the mythtv lirc file.</p>
<p><strong>mythtv</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">begin
    prog = irexec
    button = Home
    config = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>colin<span style="color: #000000; font-weight: bold;">/</span>mythtv<span style="color: #000000; font-weight: bold;">/</span>runmyth <span style="color: #000000; font-weight: bold;">&amp;</span>amp<span style="color: #000000; font-weight: bold;">;;</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = LiveTV
    config = <span style="color: #000000; font-weight: bold;">%</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = RecTV
    config = ;
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = DVD
    config = m
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Red
    config = F2
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Green
    config = F3
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Yellow
    config = F4
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Blue
    config = F5
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Teletext
    config = F6
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Clear
    config = <span style="color: #c20cb9; font-weight: bold;">w</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Star
    config = T
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Record
    config = R
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Seven
    config = <span style="color: #000000;">7</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Right
    config = Right
    repeat = <span style="color: #000000;">3</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Mute
    config = <span style="color: #000000; font-weight: bold;">|</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Skip
    config = Right
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = One
    config = <span style="color: #000000;">1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Down
    config = Down
    repeat = <span style="color: #000000;">3</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Zero
    config = <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Replay
    config = Left
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Pause
    config = P
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Six
    config = <span style="color: #000000;">6</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Two
    config = <span style="color: #000000;">2</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = ChanDown
    config = Down
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = ChanUp
    config = Up
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Rewind
    config = <span style="color: #000000; font-weight: bold;">&amp;</span>lt;
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Forward
    config = <span style="color: #000000; font-weight: bold;">&amp;</span>gt;
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Play
    config = P
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = VolDown
    config = <span style="color: #7a0874; font-weight: bold;">&#91;</span>
    repeat = <span style="color: #000000;">1</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Stop
    config = Escape
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Back
    config = Escape
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = VolUp
    config = <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    repeat = <span style="color: #000000;">1</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Five
    config = <span style="color: #000000;">5</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = More
    config = I
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Four
    config = <span style="color: #000000;">4</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = OK
    config = Return
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Up
    config = Up
    repeat = <span style="color: #000000;">3</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Nine
    config = <span style="color: #000000;">9</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Three
    config = <span style="color: #000000;">3</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Enter
    config = Enter
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Eight
    config = <span style="color: #000000;">8</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Guide
    config = S
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = mythtv
    button = Left
    config = Left
    repeat = <span style="color: #000000;">3</span>
    delay = <span style="color: #000000;">0</span>
end</pre></div></div>

<p><strong>mplayer</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Play
    config = pause
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Star
    config = sub_select
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Blue
    config = audio_delay <span style="color: #000000;">0.1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Yellow
    config = audio_delay -<span style="color: #000000;">0.1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = ChanDown
    config = panscan -<span style="color: #000000;">0.1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = ChanUp
    config = panscan +<span style="color: #000000;">0.1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Pause
    config = pause
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = OK
    config = pause
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Power
    config = quit
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Mute
    config = mute
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = VolDown
    config = volume <span style="color: #660033;">-1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Skip
    config = seek +<span style="color: #000000;">15</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Enter
    config = pause
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Stop
    config = quit
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Up
    config = seek +<span style="color: #000000;">60</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = VolUp
    config = volume +<span style="color: #000000;">1</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Down
    config = seek <span style="color: #660033;">-60</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Replay
    config = seek <span style="color: #660033;">-15</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Right
    config = seek +<span style="color: #000000;">6</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Rewind
    config = seek <span style="color: #660033;">-30</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Forward
    config = seek +<span style="color: #000000;">30</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Home
    config = vo_fullscreen
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end
&nbsp;
begin
    remote = mceusb
    prog = <span style="color: #c20cb9; font-weight: bold;">mplayer</span>
    button = Left
    config = seek <span style="color: #660033;">-6</span> <span style="color: #000000;">0</span>
    repeat = <span style="color: #000000;">0</span>
    delay = <span style="color: #000000;">0</span>
end</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/02/configuring-your-mce-ir-remote/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Time to get public</title>
		<link>http://www.oneweb.co.uk/mythtv/2009/02/time-to-get-public/</link>
		<comments>http://www.oneweb.co.uk/mythtv/2009/02/time-to-get-public/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 13:30:22 +0000</pubDate>
		<dc:creator>colin</dc:creator>
		
		<category><![CDATA[MythTv]]></category>

		<guid isPermaLink="false">http://www.oneweb.co.uk/mythtv/?p=6</guid>
		<description><![CDATA[After many months of tweaking, hacking and generally abusing MythTv to behave the way I&#8217;d like (and be girlfriend friendly) I though it was about time to publish some of the things that have helped me.
Who knows how often I&#8217;ll update this blog but the current plan is just to add things as and when [...]]]></description>
			<content:encoded><![CDATA[<p>After many months of tweaking, hacking and generally abusing MythTv to behave the way I&#8217;d like (and be girlfriend friendly) I though it was about time to publish some of the things that have helped me.</p>
<p>Who knows how often I&#8217;ll update this blog but the current plan is just to add things as and when I discover them in the hope that it helps you too!</p>
<p>If you are new to MythTv check out the <a href="/mythtv/about/">About</a> page for general info and links.</p>
<p>Let the tips commence&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.oneweb.co.uk/mythtv/2009/02/time-to-get-public/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

