| 1 | +++ contrib/setbookmark (revision 0)
|
|---|
| 2 | @@ -0,0 +1,51 @@
|
|---|
| 3 | +#!/usr/bin/perl -w
|
|---|
| 4 | +# $Id: setbookmark,v 1.3 2008-06-27 22:14:22 ajlill Exp $
|
|---|
| 5 | +# Set a bookmark at progstart if we recorded with pre-roll
|
|---|
| 6 | +# Invoke as a user job like so:
|
|---|
| 7 | +# setbookmark --chanid=$CHANID% --starttime="%STARTTIMEISO%" --progstart="%PROGSTARTISO%"
|
|---|
| 8 | +
|
|---|
| 9 | +use DBI;
|
|---|
| 10 | +use Getopt::Long;
|
|---|
| 11 | +use Time::Local;
|
|---|
| 12 | +
|
|---|
| 13 | +my( $starttime, $progstart, $chanid, $database, $host, $user, $pass, $debug );
|
|---|
| 14 | +GetOptions( 'host=s'=>\$host,
|
|---|
| 15 | + 'database=s'=>\$database,
|
|---|
| 16 | + 'user=s'=>\$user,
|
|---|
| 17 | + 'pass=s'=>\$pass,
|
|---|
| 18 | + "starttime=s" => \$starttime,
|
|---|
| 19 | + "progstart=s" => \$progstart,
|
|---|
| 20 | + "chanid=i" => \$chanid,
|
|---|
| 21 | + "debug!" => \$debug
|
|---|
| 22 | + );
|
|---|
| 23 | +
|
|---|
| 24 | +open( DBG, ">/tmp/setbookmark.dbg") if( $debug );
|
|---|
| 25 | +
|
|---|
| 26 | +if (!$host) { $host="freevo"; }
|
|---|
| 27 | +if (!$database) { $database="mythconverg"; }
|
|---|
| 28 | +if (!$user) { $user="mythtv"; }
|
|---|
| 29 | +if (!$pass) { $pass="mythtv"; }
|
|---|
| 30 | +
|
|---|
| 31 | +# TODO: look at the file and get the real fps
|
|---|
| 32 | +$fps = 30;
|
|---|
| 33 | +
|
|---|
| 34 | +my $dbh =
|
|---|
| 35 | + DBI->connect("dbi:mysql:database=$database:host=$host","$user","$pass") or
|
|---|
| 36 | + die "Cannot connect to database ($!)\n";
|
|---|
| 37 | +
|
|---|
| 38 | +print DBG "Found progstart($progstart) for $chanid $starttime\n" if ( $debug );
|
|---|
| 39 | +if( $progstart ne $starttime ) {
|
|---|
| 40 | + ($y,$mo,$d,$h,$m,$s) = split( /[-: T]/, $starttime);
|
|---|
| 41 | + $st = timelocal($s,$m,$h,$d,$mo-1,$y);
|
|---|
| 42 | + ($y,$mo,$d,$h,$m,$s) = split( /[-: T]/, $progstart);
|
|---|
| 43 | + $pg = timelocal($s,$m,$h,$d,$mo-1,$y);
|
|---|
| 44 | + $frames = ($pg - $st) * $fps;
|
|---|
| 45 | + print DBG "Seconds starttime($st) progstart($pg) frames($frames)\n" if ( $debug );
|
|---|
| 46 | +} else {
|
|---|
| 47 | + exit;
|
|---|
| 48 | +}
|
|---|
| 49 | +$sth = $dbh->prepare("insert into recordedmarkup ( chanid, starttime, mark, type ) values ( $chanid, \"$starttime\", $frames, 2 )");
|
|---|
| 50 | +$sth->execute();
|
|---|
| 51 | +$sth = $dbh->prepare("update recorded set bookmark = 1 where chanid = $chanid and starttime = \"$starttime\"");
|
|---|
| 52 | +$sth->execute();
|
|---|
| 53 | +exit 0;
|
|---|
| 54 |
|
|---|
| 55 | Property changes on: contrib/setbookmark
|
|---|
| 56 | ___________________________________________________________________
|
|---|
| 57 | Name: svn:executable
|
|---|
| 58 | + *
|
|---|
| 59 |
|
|---|