Ticket #334: mythtv-mythlink.patch
File mythtv-mythlink.patch, 3.3 KB (added by , 19 years ago) |
---|
-
contrib/mythlink.pl
41 41 $replacement_char = $dreplacement_char; 42 42 $space_char = $dspace_char; 43 43 44 # Load the destination directory , if one wasspecified44 # Load the destination directory and other options, if specified 45 45 GetOptions('dest|destination|path=s' => \$dest, 46 46 'format=s' => \$format, 47 47 'sepchar|separator-char=s' => \$separator_char, … … 219 219 # Bad paths 220 220 die "$dest is not a directory.\n" unless (-d $dest); 221 221 222 # Prepare a database query 223 $sh = $dbh->prepare(q{SELECT basename, chanid, DATE_FORMAT(starttime, '%Y-%m-%d-%H-%i-%S'), DATE_FORMAT(endtime, '%Y-%m-%d-%H-%i-%S'), title, subtitle, description, recgroup, category, originalairdate FROM recorded}) 224 or die "Unable to prepare query: ".$dbh->errstr."\n"; 225 226 # Create symlinks for the files on this machine 227 228 # Query the desired info about the recordings 229 $rc = $sh->execute or die "Could not execute ($q): $!\n\n"; 230 $rc = $sh->bind_columns(\$basename, \$channel,\$starttime,\$endtime,\$title,\$subtitle,\$description,\$recgroup,\$category,\$oad); 231 222 232 # Delete any old links 223 233 foreach my $file (<$dest/*>) { 224 234 next unless (-l $file); 225 235 unlink $file or die "Couldn't remove old symlink $file: $!\n"; 226 236 } 227 237 228 # Prepare a database query229 $sh = $dbh->prepare('SELECT title, subtitle, description, recgroup, category, originalairdate FROM recorded WHERE chanid=? AND starttime=? AND endtime=?');238 # Iterate over all the recordings 239 while ($sh->fetchrow_arrayref) { 230 240 231 # Create symlinks for the files on this machine 232 foreach my $file (<$video_dir/*.nuv>) { 233 next if ($file =~ /^ringbuf/); 234 # Pull out the various parts that make up the filename 235 my ($channel, 236 $syear, $smonth, $sday, $shour, $sminute, $ssecond, 237 $eyear, $emonth, $eday, $ehour, $eminute, $esecond) = $file =~/^$video_dir\/([a-z0-9]+)_(....)(..)(..)(..)(..)(..)_(....)(..)(..)(..)(..)(..)\.nuv$/i; 238 # Found a bad filename? 239 unless ($channel) { 240 print "Unknown filename format: $file\n"; 241 next; 242 } 243 # Query the desired info about this recording 244 $sh->execute($channel, "$syear$smonth$sday$shour$sminute$ssecond", "$eyear$emonth$eday$ehour$eminute$esecond") 245 or die "Could not execute ($q): $!\n\n"; 246 my ($title, $subtitle, $description, $recgroup, $category, $oad) = $sh->fetchrow_array; 241 # Verify the file exists on this host 242 my $file = $video_dir."/".$basename; 243 next unless (-e $file); 244 247 245 # Format some fields we may be parsing below 248 246 # Start time 247 my ($syear, $smonth, $sday, $shour, $sminute, $ssecond) = split(/\-/, $starttime, 6); 249 248 my $meridian = ($shour > 12) ? 'AM' : 'PM'; 250 249 my $hour = ($shour > 12) ? $shour - 12 : $shour; 251 250 if ($hour < 10) { … … 255 254 $hour = 12; 256 255 } 257 256 # End time 257 my ($eyear, $emonth, $eday, $ehour, $eminute, $esecond) = split(/\-/, $endtime, 6); 258 258 my $emeridian = ($ehour > 12) ? 'AM' : 'PM'; 259 259 my $ethour = ($ehour > 12) ? $ehour - 12 : $ehour; 260 260 if ($ethour < 10) {