summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-12-09 11:19:45 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-12-09 11:19:45 +0000
commit8b397f54ce235829feb01b5b453383f9678e5d21 (patch)
treeba5b6d260e8565fff0897e862dcff28c950955b9 /lib
parentd986ff1c851b7169d5d9537b03858eaaaae621d1 (diff)
downloadxxv-8b397f54ce235829feb01b5b453383f9678e5d21.tar.gz
xxv-8b397f54ce235829feb01b5b453383f9678e5d21.tar.bz2
* Update translation
* AUTOTIMER: Show lookup at waiter, after epg update * RECORDS: Update preview images with current duration * RECORDS: Simplification of SearchEPGID
Diffstat (limited to 'lib')
-rw-r--r--lib/XXV/MODULES/AUTOTIMER.pm72
-rw-r--r--lib/XXV/MODULES/EPG.pm36
-rw-r--r--lib/XXV/MODULES/RECORDS.pm70
3 files changed, 90 insertions, 88 deletions
diff --git a/lib/XXV/MODULES/AUTOTIMER.pm b/lib/XXV/MODULES/AUTOTIMER.pm
index 4f281ea..1187160 100644
--- a/lib/XXV/MODULES/AUTOTIMER.pm
+++ b/lib/XXV/MODULES/AUTOTIMER.pm
@@ -289,15 +289,20 @@ sub _init {
main::after(sub{
my $m = main::getModule('EPG');
- $m->updated(sub{
+ $m->updated(
+ sub{
+ my $watcher = shift;
+ my $console = shift;
+ my $waiter = shift;
+
return 0 if($obj->{active} ne 'y');
lg 'Start autotimer callback to find new events!';
- return $obj->autotimer();
+ return $obj->_autotimerLookup($watcher,$console,$waiter);
- });
+ },"AUTOTIMER: Callback to compare epg data ...");
return 1;
- }, "AUTOTIMER: Install callback at update epg data ...", 30);
+ }, "AUTOTIMER: Install callback to compare epg data ...", 30);
return 1;
}
@@ -315,6 +320,36 @@ sub autotimer {
my $console = shift;
my $autotimerid = shift;
+ my $waiter;
+ if(ref $console && !$autotimerid && $console->typ eq 'HTML') {
+ $waiter = $console->wait(gettext("Searching for autotimer ..."),0,1000,'no');
+ }
+
+ my ($log,$C,$M) = $obj->_autotimerLookup($watcher,$console,$waiter,$autotimerid);
+
+ # last call of waiter
+ $waiter->end() if(ref $waiter);
+
+ if(ref $console) {
+ $console->start() if(ref $waiter);
+ unshift(@{$log},sprintf(gettext("Autotimer process created %d timers and modified %d timers."), $C, $M));
+ lg join("\n", @$log);
+ $console->message($log);
+ $console->link({
+ text => gettext("Back to autotimer listing."),
+ url => "?cmd=alist",
+ }) if($console->typ eq 'HTML');
+ }
+
+ return 1;
+}
+sub _autotimerLookup {
+ my $obj = shift || return error('No object defined!');
+ my $watcher = shift;
+ my $console = shift;
+ my $waiter = shift;
+ my $autotimerid = shift;
+
# Get Autotimer
my $sth;
if($autotimerid) {
@@ -328,11 +363,9 @@ sub autotimer {
}
my $att = $sth->fetchall_hashref('Id');
- my $waiter;
- if(ref $console && !$autotimerid && $console->typ eq 'HTML') {
- my $zaehler = scalar keys %$att;
- $waiter = $console->wait(gettext("Searching for autotimer ..."), 0, ++$zaehler, 'no');
- }
+ # Adjust waiter max value now.
+ $waiter->max(scalar keys %$att)
+ if(ref $console && ref $waiter);
my $l = 0; # Lines for Waiter
my $C = 0; # Total of created and modifed timers
@@ -373,12 +406,12 @@ sub autotimer {
foreach my $id (sort keys %$att) {
my $a = $att->{$id};
- $waiter->next(++$l, undef, sprintf(gettext("Search for autotimer with ID(%d) with search pattern '%s'"), $id, $a->{Search}))
+ $waiter->next(++$l, undef, sprintf(gettext("Search for autotimer '%s'"), $a->{Search}))
if(ref $waiter);
if(ref $console && $autotimerid) {
$console->message(' ') if($console->{TYP} eq 'HTML');
- $console->message(sprintf(gettext("Search for autotimer with ID(%d) with search pattern '%s'"), $id, $a->{Search}));
+ $console->message(sprintf(gettext("Search for autotimer '%s'"), $a->{Search}));
}
# Build SQL Command and run it ....
@@ -522,23 +555,8 @@ sub autotimer {
$timermod->readData();
- # last call of waiter
- $waiter->end() if(ref $waiter);
-
- if(ref $console) {
- $console->start() if(ref $waiter);
- unshift(@{$log},sprintf(gettext("Autotimer process created %d timers and modified %d timers."), $C, $M));
- lg join("\n", @$log);
- $console->message($log);
- $console->link({
- text => gettext("Back to autotimer listing."),
- url => "?cmd=alist",
- }) if($console->typ eq 'HTML');
- }
-
- return 1;
+ return (\@{$log},$C,$M);
}
-
# ------------------
# Name: autotimerCreate
# Descr: Routine to display the create form for Autotimer.
diff --git a/lib/XXV/MODULES/EPG.pm b/lib/XXV/MODULES/EPG.pm
index fc5a722..1d64765 100644
--- a/lib/XXV/MODULES/EPG.pm
+++ b/lib/XXV/MODULES/EPG.pm
@@ -296,7 +296,7 @@ sub startReadEpgData {
$obj->deleteDoubleEPGEntrys();
- $obj->updated() if($updated);
+ $obj->_updated($watcher,$console,$waiter) if($updated);
# last call of waiter
$waiter->end() if(ref $waiter);
@@ -310,25 +310,33 @@ sub startReadEpgData {
}
}
-# Routine um Callbacks zu registrieren und
-# diese nach dem Aktualisieren der EPG Daten zu starten
+# Routine um Callbacks zu registrieren die nach dem Aktualisieren der EPG Daten
+# ausgeführt werden
# ------------------
sub updated {
# ------------------
my $obj = shift || return error('No object defined!');
- my $cb = shift || 0;
+ my $cb = shift || return error('No callback defined!');
my $log = shift || 0;
- if($cb) {
- push(@{$obj->{after_updated}}, [$cb, $log]);
- } else {
- foreach my $CB (@{$obj->{after_updated}}) {
- next unless(ref $CB eq 'ARRAY');
- lg $CB->[1]
- if($CB->[1]);
- &{$CB->[0]}()
- if(ref $CB->[0] eq 'CODE');
- }
+ push(@{$obj->{after_updated}}, [$cb, $log]);
+}
+
+# Ausführen der Registrierten Callbacks nach dem Aktualisieren der EPG Daten
+# ------------------
+sub _updated {
+# ------------------
+ my $obj = shift || return error('No object defined!');
+ my $watcher = shift;
+ my $console = shift;
+ my $waiter = shift;
+
+ foreach my $CB (@{$obj->{after_updated}}) {
+ next unless(ref $CB eq 'ARRAY');
+ lg $CB->[1]
+ if($CB->[1]);
+ &{$CB->[0]}($watcher,$console,$waiter)
+ if(ref $CB->[0] eq 'CODE');
}
}
# This Routine will compare data from epg.data
diff --git a/lib/XXV/MODULES/RECORDS.pm b/lib/XXV/MODULES/RECORDS.pm
index f29758a..0db14ad 100644
--- a/lib/XXV/MODULES/RECORDS.pm
+++ b/lib/XXV/MODULES/RECORDS.pm
@@ -352,7 +352,7 @@ sub _notify_readData {
# ------------------
my $obj = shift || return error('No object defined!');
my $e = shift;
- lg sprintf "notify events for %s:%d received: %x\n", $e->fullname, $e->cookie, $e->mask;
+ lg sprintf "notify events for %s:%d received: %x", $e->fullname, $e->cookie, $e->mask;
if((time - $obj->{lastupdate}) > 15 # Only if last update prior 15 seconds (avoid callback chill)
&& $obj->readData()) {
@@ -368,10 +368,10 @@ sub _notify_readData {
after => $after,
cb => sub {
if((time - $obj->{lastupdate}) >= ($after - 30)) {
- $_[0]->w->cancel;
if($obj->readData()) {
$obj->{lastupdate} = time;
}
+ $_[0]->w->cancel;
}
}
);
@@ -421,10 +421,12 @@ sub parseData {
$event->{id} = $id;
$event->{state} = $state eq '*' ? 1 : 0;
$event->{starttime} = timelocal(0,$minute,$hour,$day,$month-1, $year);
+
+ $title =~ s/~ $//g; # Remove empty subtitle
$event->{title} = $title;
$hash = sprintf("%s~%s",$title,$event->{starttime});
- %{$dataHash->{$hash}} = %{$event};
+ %{$dataHash->{lc($hash)}} = %{$event};
}
return ($dataHash);
}
@@ -518,8 +520,8 @@ sub readData {
my $sql = qq|SELECT SQL_CACHE r.eventid as eventid, r.RecordId as id,
UNIX_TIMESTAMP(e.starttime) as starttime,
e.duration as duration, r.State as state,
- CONCAT_WS('~',e.title,e.subtitle) as title,
- CONCAT_WS('~',e.title,e.subtitle,UNIX_TIMESTAMP(e.starttime)) as hash,
+ CONCAT_WS("~",e.title,e.subtitle) as title,
+ LOWER(CONCAT_WS("~",e.title,e.subtitle,UNIX_TIMESTAMP(e.starttime))) as hash,
UNIX_TIMESTAMP(e.addtime) as addtime,
r.Path as path,
r.Type as type,
@@ -561,6 +563,10 @@ sub readData {
my $duration = $obj->_recordinglength($db_data->{$h}->{path});
if($duration != $db_data->{$h}->{duration}) {
+ # Update duration at database entry
+ $db_data->{$h}->{duration} = $duration;
+ $db_data->{$h}->{FileSize} = $obj->_recordingsize($db_data->{$h}->{path}, ($duration * 8 * $obj->{framerate}));
+
# set addtime only if called from EVENT::TIMER
# avoid generating preview image during user actions
# it's should speedup reading recordings
@@ -571,10 +577,6 @@ sub readData {
push(@{$obj->{JOBS}}, $command)
if($command && not grep(/\Q$command/g,@{$obj->{JOBS}}));
}
- # Update duration at database entry
- $db_data->{$h}->{duration} = $duration;
- $db_data->{$h}->{FileSize} = $obj->_recordingsize($db_data->{$h}->{path}, ($duration * 8 * $obj->{framerate}));
-
$obj->_updateEvent($db_data->{$h});
$obj->_updateFileSize($db_data->{$h});
@@ -622,7 +624,6 @@ sub readData {
foreach my $t (keys %{$db_data}) {
push(@todel,$db_data->{$t}->{RecordMD5});
}
-
my $sql = sprintf('DELETE FROM RECORDS WHERE RecordMD5 IN (%s)', join(',' => ('?') x @todel));
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute(@todel)
@@ -830,18 +831,7 @@ sub analyze {
return 0;
}
- my @t = split('~', $recattr->{title});
- my $title = $recattr->{title};
- my $subtitle;
- if(scalar @t > 1) { # Splitt genre~title | subtitle
- my @p = split('/', $info->{path});
- $subtitle = delete $t[-1]
- if(scalar @p > 3 && $p[-2] ne '_');
- $subtitle = undef if(defined $subtitle and $subtitle eq ' ');
- $title = join('~',@t);
- }
-
- my $event = $obj->SearchEpgId( $recattr->{starttime}, $info->{duration}, $title, $subtitle, $info->{channel} );
+ my $event = $obj->SearchEpgId( $recattr->{starttime}, $info->{duration}, $recattr->{title}, $info->{channel} );
if($event) {
my $id = $event->{eventid};
$event->{addtime} = time;
@@ -855,6 +845,14 @@ sub analyze {
# Sollte kein Event gefunden werden so muss dieser in OLDEPG mit
# den vorhandenen Daten (lstr nummer) eingetragen werden und eine PseudoEventId (min(eventid)-1)
# erfunden werden ;)
+ my @t = split('~', $recattr->{title});
+ my $title = $recattr->{title};
+ my $subtitle;
+ if(scalar @t > 1) { # Splitt genre~title | subtitle
+ $subtitle = delete $t[-1];
+ $title = join('~',@t);
+ }
+
$event = $obj->createOldEventId($recattr->{id}, $recattr->{starttime}, $info->{duration}, $title, $subtitle, $info);
unless($event) {
error sprintf("Couldn't create event!: '%s' !",$recattr->{id});
@@ -1135,47 +1133,25 @@ sub SearchEpgId {
my $start = shift || return error('No start time defined!');
my $dur = shift || return 0;
my $title = shift || return error('No title defined!');
- my $subtitle = shift;
my $channel = shift;
my $sth;
my $bis = int($start + $dur);
- if($subtitle && $channel && $channel ne "") {
- $sth = $obj->{dbh}->prepare(
-qq|SELECT SQL_CACHE * FROM OLDEPG WHERE
- UNIX_TIMESTAMP(starttime) >= ?
- AND UNIX_TIMESTAMP(starttime)+duration <= ?
- AND title = ?
- AND subtitle = ?
- AND channel_id = ?|);
- $sth->execute($start,$bis,$title,$subtitle,$channel)
- or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
- } elsif($channel && $channel ne "") {
+ if($channel && $channel ne "") {
$sth = $obj->{dbh}->prepare(
qq|SELECT SQL_CACHE * FROM OLDEPG WHERE
UNIX_TIMESTAMP(starttime) >= ?
AND UNIX_TIMESTAMP(starttime)+duration <= ?
- AND title = ?
- AND subtitle IS NULL
+ AND CONCAT_WS("~",title,subtitle) = ?
AND channel_id = ?|);
$sth->execute($start,$bis,$title,$channel)
or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
- } elsif($subtitle) {
- $sth = $obj->{dbh}->prepare(
-qq|SELECT SQL_CACHE * FROM OLDEPG WHERE
- UNIX_TIMESTAMP(starttime) >= ?
- AND UNIX_TIMESTAMP(starttime)+duration <= ?
- AND title = ?
- AND subtitle = ?|);
- $sth->execute($start,$bis,$title,$subtitle)
- or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
} else {
$sth = $obj->{dbh}->prepare(
qq|SELECT SQL_CACHE * FROM OLDEPG WHERE
UNIX_TIMESTAMP(starttime) >= ?
AND UNIX_TIMESTAMP(starttime)+duration <= ?
- AND title = ?
- AND subtitle IS NULL|);
+ AND CONCAT_WS("~",title,subtitle) = ?|);
$sth->execute($start,$bis,$title)
or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
}