<div>I know we&#39;re all anxiously awaiting new releases to natively support Schedules Direct; I&#39;m planning to upgrade as soon as I can, but in the meantime I made a small script to semi-automatically run a modified version of XMLTV&#39;s tv_grab_na_dd followed by mythfilldatabase, adjusting the new program ID format to match the old database.&nbsp; It&#39;s not pretty (though it does nice things like wait for the next suggested run time), and it&#39;s definitely not permanent, but will give me a bit of breathing room to upgrade on my own schedule.&nbsp; At the very least, you can extract the manual commands to roll your own solution; it took me some trial and error to figure out the right command line parameters.
</div>
<div>&nbsp;</div>
<div>This assumes XMLTV (and tv_grab_na_dd) is already installed (an older version without the new URL is okay; see modification instructions); this was true in my ATRPMS &quot;yum install mythtv-suite&quot; following Jarod&#39;s guide.&nbsp; See the help/comments at the beginning for more instructions.
</div>
<div>&nbsp;</div>
<div>Good luck; I hope this helps a few people.</div>
<div>&nbsp;</div>
<div>Josh</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>#!/usr/bin/perl<br><br>sub printhelp {<br>print &lt;&lt;ENDOFHELP;<br>&nbsp; <br>SchedulesDirect semi-automatic downloader for legacy MythTV installations<br>Josh Mastronarde, <a href="mailto:jmastron@gmail.com">jmastron@gmail.com
</a><br>8-22-07<br><br>Syntax:&nbsp; sdfill &lt;options&gt;<br>        -nodownload        Don&#39;t download data (use last downloaded file)<br>        -nofill                Don&#39;t run mythfilldatabase        <br>        -once                Only run once<br><br><br>This script will grab listings data, modify the episode ID field to match
<br>the old data, and run mythfilldatabase.&nbsp; If -once not specified, it will loop<br>waiting for the next suggested time from the last run.<br><br>Steps to prepare:<br><br>1)&nbsp; Find XMLTV&#39;s tv_grab_na_dd (was in /usr/bin for me); copy to
<br>&nbsp;&nbsp;&nbsp; ./tv_grab_na_sd<br><br>2)&nbsp; Modify ./tv_grab_na_sd; replace the &quot;dd_service&quot; line with:<br>&nbsp;&nbsp;&nbsp; my $dd_service=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;<a href="http://docs.tms.tribune.com/tech/tmsdatadirect/zap2it/xtvd.wsdl">http://docs.tms.tribune.com/tech/tmsdatadirect/zap2it/xtvd.wsdl
</a>&#39;;<br><br>3)&nbsp; Run: ./tv_grab_na_sd --configure --config-file ~/.xmltv/tv_grab_na_sd.conf&quot;<br><br>4)&nbsp; Replace &quot;CA54023&quot; with your lineup id (from the above .conf file; leave off<br>&nbsp;&nbsp;&nbsp; the &quot;:-&quot;, I think)
<br><br>If you want to run by hand, the key commands are in &quot;$grabcmd&quot; and<br>&quot;$mythfillcmd&quot; below, along with the small section of code after &quot;Modify<br>episode/program IDs&quot; to shorten the IDs.
<br><br><br>ENDOFHELP<br>exit(1);<br>}<br><br>use Time::Local;<br><br># Defaults<br><br>$xmlfile1 = &quot;sdlist.xml&quot;;<br>$xmlfile2 = &quot;sdlist_fixed.xml&quot;;<br>$grablog = &quot;grab_log&quot;;<br><br>$grabcmd = &quot;./tv_grab_na_sd --config-file ~/.xmltv/tv_grab_na_sd.conf &quot; .
<br>        &nbsp;&nbsp; &quot;--days 14 --dd-data $xmlfile1 --download-only --list-times&quot;;<br><br>$mythfillcmd = &quot;mythfilldatabase --dd-file 1 -1 CA54023 $xmlfile2&quot;;<br><br># Parse command line arguments<br>while (@ARGV) {
<br>&nbsp; $arg = shift(@ARGV);<br>&nbsp; if ($arg eq &quot;-nodownload&quot;) {<br>&nbsp;&nbsp;&nbsp; $nodownload = 1;<br>&nbsp; } elsif ($arg eq &quot;-nofill&quot;) {<br>&nbsp;&nbsp;&nbsp; $nofill = 1;<br>&nbsp; } elsif ($arg eq &quot;-h&quot;) {<br>&nbsp;&nbsp;&nbsp; &amp;printhelp;
<br>&nbsp; } elsif ($arg eq &quot;-once&quot;) {<br>&nbsp;&nbsp;&nbsp; $once = 1;<br>&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; push(@narg, $arg);<br>&nbsp; }<br>}<br><br>$| = 1;<br>print &quot;\n---- SDfill started at &quot;, &amp;prlocal(time()), &quot;\n\n&quot;;<br><br>
# Loop (but only once if -once flag set)<br><br>$run = 1;<br>while ($run) {<br>&nbsp; $run = 0 if ($once);<br><br>&nbsp; # Check for logfile from last grabber run and look for suggested time<br><br>&nbsp; if (-e $grablog) {<br>&nbsp;&nbsp;&nbsp; $suggtime = &quot;&quot;;
<br>&nbsp;&nbsp;&nbsp; open(grablog, &quot;&lt;$grablog&quot;) || die &quot;Error: Can&#39;t open $grablog\n&quot;;<br>&nbsp;&nbsp;&nbsp; while (&lt;grablog&gt;) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (($year,$mon,$day,$hour,$min,$sec) = ($_ =~ /^suggestedTime&nbsp; \|(\d+)\-(\d+)\-(\d+)T(\d+):(\d+):(\d+)Z/)) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $suggtime = timegm($sec,$min,$hour,$day,$mon-1,$year-1900);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; close(grablog);<br>&nbsp;&nbsp;&nbsp; if ($suggtime) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $waitsecs = $suggtime - time();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $waithrs = int($waitsecs/3600);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $waitmins = int($waitsecs/60) % 60;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;---- Sleeping until suggested &quot;, &amp;prlocal($suggtime), &quot;, $waithrs:$waitmins from now ----\n\n&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sleep($waitsecs);<br>&nbsp;&nbsp;&nbsp; }
<br>&nbsp; }<br><br><br>&nbsp; print &quot;\n---- Grab starting at &quot;, &amp;prlocal(time()), &quot;\n\n&quot;;<br><br>&nbsp; unless ($nodownload) {<br>&nbsp;&nbsp;&nbsp; unlink(&quot;sdlist.xml&quot;);<br>&nbsp;&nbsp;&nbsp; print &quot;Running: $grabcmd\n&quot;;
<br>&nbsp;&nbsp;&nbsp; open(f, &quot;$grabcmd 2&gt;&amp;1 |&quot;) || die &quot;Error: Can&#39;t execute tv_grab\n&quot;;<br>&nbsp;&nbsp;&nbsp; open(grablog, &quot;&gt;$grablog&quot;) || die &quot;Error: Can&#39;t write $grablog\n&quot;;<br>&nbsp;&nbsp;&nbsp; while (&lt;f&gt;) {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print grablog;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; close(f);<br>&nbsp;&nbsp;&nbsp; close(grablog);<br>&nbsp; }<br><br>&nbsp; # Modify episode/program IDs to remove 2 digits to match old format<br>&nbsp; <br>&nbsp; print &quot;\n\n---- Fixing Episode Number format\n\n&quot;;
<br>&nbsp; open(xmlin, &quot;&lt;$xmlfile1&quot;) || die &quot;Error: Can&#39;t open $xmlfile1&quot;;<br>&nbsp; open(xmlout, &quot;&gt;$xmlfile2&quot;) || die &quot;Error: Can&#39;t open $xmlfile2&quot;;<br>&nbsp; <br>&nbsp; while (&lt;xmlin&gt;) {
<br>&nbsp;&nbsp;&nbsp; s/(\&lt;program id=\&#39;..)00/$1/;<br>&nbsp;&nbsp;&nbsp; s/(\&lt;schedule program=\&#39;..)00/$1/;<br>&nbsp;&nbsp;&nbsp; s/(\&lt;programGenre program=\&#39;..)00/$1/;<br>&nbsp;&nbsp;&nbsp; s/(\&lt;series\&gt;..)00/$1/;<br>&nbsp;&nbsp;&nbsp; print xmlout;<br>&nbsp; }<br>&nbsp; close(xmlin);
<br>&nbsp; close(xmlout);<br><br>&nbsp; # Run mythfilldatabase<br><br>&nbsp; unless ($nofill) {<br>&nbsp;&nbsp;&nbsp; print &quot;Running: $mythfillcmd\n&quot;;<br>&nbsp;&nbsp;&nbsp; open(f, &quot;$mythfillcmd 2&gt;&amp;1 |&quot;) || die &quot;Error: Can&#39;t execute mythfilldatabase\n&quot;;
<br>&nbsp;&nbsp;&nbsp; while (&lt;f&gt;) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br><br>print &quot;\n---- Grab done at &quot;, &amp;prlocal(time()), &quot;\n\n&quot;;<br>}<br><br><br># Helper routine to print nicely formatted local time from a timestamp
<br><br>sub prlocal {<br>&nbsp; my($intime) = @_;<br>&nbsp; my ($sec,$min,$hour,$mday,$mon,$year) = localtime($intime);<br>&nbsp; return(sprintf(&quot;%04d/%02d/%02d %02d:%02d:%02d&quot;, $year+1900,$mon+1,$mday,$hour,$min,$sec));<br>}<br>
&nbsp;</div>
<div>&nbsp;</div>