<div>I know we're all anxiously awaiting new releases to natively support Schedules Direct; I'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's tv_grab_na_dd followed by mythfilldatabase, adjusting the new program ID format to match the old database. It's not pretty (though it does nice things like wait for the next suggested run time), and it's definitely not permanent, but will give me a bit of breathing room to upgrade on my own schedule. 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> </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 "yum install mythtv-suite" following Jarod's guide. See the help/comments at the beginning for more instructions.
</div>
<div> </div>
<div>Good luck; I hope this helps a few people.</div>
<div> </div>
<div>Josh</div>
<div> </div>
<div> </div>
<div>#!/usr/bin/perl<br><br>sub printhelp {<br>print <<ENDOFHELP;<br> <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: sdfill <options><br>        -nodownload        Don't download data (use last downloaded file)<br>        -nofill                Don'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. 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) Find XMLTV's tv_grab_na_dd (was in /usr/bin for me); copy to
<br> ./tv_grab_na_sd<br><br>2) Modify ./tv_grab_na_sd; replace the "dd_service" line with:<br> my $dd_service=<br> '<a href="http://docs.tms.tribune.com/tech/tmsdatadirect/zap2it/xtvd.wsdl">http://docs.tms.tribune.com/tech/tmsdatadirect/zap2it/xtvd.wsdl
</a>';<br><br>3) Run: ./tv_grab_na_sd --configure --config-file ~/.xmltv/tv_grab_na_sd.conf"<br><br>4) Replace "CA54023" with your lineup id (from the above .conf file; leave off<br> the ":-", I think)
<br><br>If you want to run by hand, the key commands are in "$grabcmd" and<br>"$mythfillcmd" below, along with the small section of code after "Modify<br>episode/program IDs" to shorten the IDs.
<br><br><br>ENDOFHELP<br>exit(1);<br>}<br><br>use Time::Local;<br><br># Defaults<br><br>$xmlfile1 = "sdlist.xml";<br>$xmlfile2 = "sdlist_fixed.xml";<br>$grablog = "grab_log";<br><br>$grabcmd = "./tv_grab_na_sd --config-file ~/.xmltv/tv_grab_na_sd.conf " .
<br>         "--days 14 --dd-data $xmlfile1 --download-only --list-times";<br><br>$mythfillcmd = "mythfilldatabase --dd-file 1 -1 CA54023 $xmlfile2";<br><br># Parse command line arguments<br>while (@ARGV) {
<br> $arg = shift(@ARGV);<br> if ($arg eq "-nodownload") {<br> $nodownload = 1;<br> } elsif ($arg eq "-nofill") {<br> $nofill = 1;<br> } elsif ($arg eq "-h") {<br> &printhelp;
<br> } elsif ($arg eq "-once") {<br> $once = 1;<br> } else {<br> push(@narg, $arg);<br> }<br>}<br><br>$| = 1;<br>print "\n---- SDfill started at ", &prlocal(time()), "\n\n";<br><br>
# Loop (but only once if -once flag set)<br><br>$run = 1;<br>while ($run) {<br> $run = 0 if ($once);<br><br> # Check for logfile from last grabber run and look for suggested time<br><br> if (-e $grablog) {<br> $suggtime = "";
<br> open(grablog, "<$grablog") || die "Error: Can't open $grablog\n";<br> while (<grablog>) {<br> if (($year,$mon,$day,$hour,$min,$sec) = ($_ =~ /^suggestedTime \|(\d+)\-(\d+)\-(\d+)T(\d+):(\d+):(\d+)Z/)) {
<br> $suggtime = timegm($sec,$min,$hour,$day,$mon-1,$year-1900);<br> }<br> }<br> close(grablog);<br> if ($suggtime) {<br> $waitsecs = $suggtime - time();<br> $waithrs = int($waitsecs/3600);<br>
$waitmins = int($waitsecs/60) % 60;<br> <br> print "---- Sleeping until suggested ", &prlocal($suggtime), ", $waithrs:$waitmins from now ----\n\n";<br> sleep($waitsecs);<br> }
<br> }<br><br><br> print "\n---- Grab starting at ", &prlocal(time()), "\n\n";<br><br> unless ($nodownload) {<br> unlink("sdlist.xml");<br> print "Running: $grabcmd\n";
<br> open(f, "$grabcmd 2>&1 |") || die "Error: Can't execute tv_grab\n";<br> open(grablog, ">$grablog") || die "Error: Can't write $grablog\n";<br> while (<f>) {
<br> print;<br> print grablog;<br> }<br> close(f);<br> close(grablog);<br> }<br><br> # Modify episode/program IDs to remove 2 digits to match old format<br> <br> print "\n\n---- Fixing Episode Number format\n\n";
<br> open(xmlin, "<$xmlfile1") || die "Error: Can't open $xmlfile1";<br> open(xmlout, ">$xmlfile2") || die "Error: Can't open $xmlfile2";<br> <br> while (<xmlin>) {
<br> s/(\<program id=\'..)00/$1/;<br> s/(\<schedule program=\'..)00/$1/;<br> s/(\<programGenre program=\'..)00/$1/;<br> s/(\<series\>..)00/$1/;<br> print xmlout;<br> }<br> close(xmlin);
<br> close(xmlout);<br><br> # Run mythfilldatabase<br><br> unless ($nofill) {<br> print "Running: $mythfillcmd\n";<br> open(f, "$mythfillcmd 2>&1 |") || die "Error: Can't execute mythfilldatabase\n";
<br> while (<f>) {<br> print;<br> }<br> }<br><br>print "\n---- Grab done at ", &prlocal(time()), "\n\n";<br>}<br><br><br># Helper routine to print nicely formatted local time from a timestamp
<br><br>sub prlocal {<br> my($intime) = @_;<br> my ($sec,$min,$hour,$mday,$mon,$year) = localtime($intime);<br> return(sprintf("%04d/%02d/%02d %02d:%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min,$sec));<br>}<br>
</div>
<div> </div>