Ticket #6006: myth.rebuilddatabase.pl.2.diff
File myth.rebuilddatabase.pl.2.diff, 3.5 KB (added by , 15 years ago) |
---|
-
myth.
old new 28 28 ## ./myth.rebuilddatabase.pl 29 29 30 30 ## Change log: 31 ## 12-14-2008 (kb9vqf@pearsoncomputing.net) 32 ## Updated script to: 33 ## Populate file size 34 ## Correctly handle start date and time 35 ## Detect recording length with mplayer 36 ## Automatically preview file with xine 31 37 ## 9-19-2003: (awithers@anduin.com) 32 38 ## Anduin fights the urge to make code more readable (aka C like). Battle 33 39 ## of urges ends in stalemate: code was reindented but not "changed" (much). … … 72 78 my $norename = 0; 73 79 my $storagegroup = "Default"; 74 80 81 my $filesize = 0; 82 75 83 my $date_regx = qr/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/; 76 84 my $db_date_regx = qr/(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/; 77 85 my $channel_regx = qr/(\d\d\d\d)/; … … 277 285 278 286 279 287 # normal case: import file into the database 288 $filesize = `xine ${show}`; 280 289 281 290 my ($channel, $syear, $smonth, $sday, $shour, $sminute, $ssecond, 282 291 $eyear, $emonth, $eday, $ehour, $eminute, $esecond); … … 376 385 $newtitle = GetAnswer("... title", $newtitle); 377 386 $newsubtitle = GetAnswer("... subtitle", $newsubtitle); 378 387 $newdescription = GetAnswer("Description", $newdescription); 388 $starttime = "$syear-$smonth-$sday $shour:$sminute:$ssecond"; 379 389 $starttime = GetAnswer("... start time (YYYY-MM-DD HH:MM:SS)", $starttime); 380 390 $recgroup = GetAnswer("... Recording Group", "Default"); 381 391 } … … 385 395 } else { 386 396 $duration = "60"; 387 397 } 398 399 $duration = `mplayer -identify ${show} -frames 0 2> /dev/null | grep ID_LENGTH`; 400 $duration =~ s/ID_LENGTH=//; 401 $duration = $duration / 60; 402 chomp $duration; 403 388 404 $duration = GetAnswer("... duration (in minutes)", $duration); 389 405 $endtime = time_format("yyyy-mm{on}-dd hh:mm{in}:ss", str2time($starttime) + $duration * 60); 390 406 … … 396 412 $time1 =~ s/[ \-:]//g; 397 413 $mythfile = sprintf("%s_%s.%s", $channel, $time1, $ext); 398 414 } 399 400 my $sql = "insert into recorded (chanid, starttime, endtime, title, subtitle, description, hostname, basename, progstart, progend, storagegroup, recgroup) values ((?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?))"; 415 $filesize = `du -sk ${show}`; 416 $filesize =~ s/ .*//; 417 chomp $filesize; 418 $filesize = "${filesize}000"; 419 my $sql = "insert into recorded (chanid, starttime, endtime, title, subtitle, description, hostname, basename, progstart, progend, storagegroup, recgroup, filesize) values ((?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?), (?))"; 401 420 402 421 if ($test_mode) { 403 422 404 423 $sql =~ s/\(\?\)/"%s"/g; 405 424 my $statement = sprintf($sql, $channel, $starttime, $endtime, $newtitle, 406 425 $newsubtitle, $newdescription, $host, $mythfile, 407 $starttime, $endtime, $storagegroup, $recgroup );426 $starttime, $endtime, $storagegroup, $recgroup, $filesize); 408 427 print("Test mode: insert would have been been:\n"); 409 428 print($statement, ";\n"); 410 429 … … 413 432 $sth = $dbh->prepare($sql); 414 433 $sth->execute($channel, $starttime, $endtime, $newtitle, 415 434 $newsubtitle, $newdescription, $host, $mythfile, 416 $starttime, $endtime, $storagegroup, $recgroup )435 $starttime, $endtime, $storagegroup, $recgroup, $filesize) 417 436 or die "Could not execute ($sql)\n"; 418 437 419 438 if ($mythfile ne $showBase) {