summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-09-08 12:07:50 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-09-08 12:07:50 +0000
commita6e099faa6681b21e25f9e5e4cc2038ae0f77b92 (patch)
tree9b9919ecbe16fab359f10c85d4022e34d4beee56 /lib
parent61cc4d2235b9c6fee2648ee570d8ae5ab85cc50c (diff)
downloadxxv-a6e099faa6681b21e25f9e5e4cc2038ae0f77b92.tar.gz
xxv-a6e099faa6681b21e25f9e5e4cc2038ae0f77b92.tar.bz2
* Let SVN control version date and revision
Diffstat (limited to 'lib')
-rw-r--r--lib/XXV/MODULES/AUTOTIMER.pm2260
-rw-r--r--lib/XXV/MODULES/CHANNELS.pm4
-rw-r--r--lib/XXV/MODULES/CHRONICLE.pm68
-rw-r--r--lib/XXV/MODULES/EPG.pm2186
-rw-r--r--lib/XXV/MODULES/MEDIALIB.pm2
-rw-r--r--lib/XXV/MODULES/MUSIC.pm18
-rw-r--r--lib/XXV/MODULES/RECORDS.pm142
-rw-r--r--lib/XXV/MODULES/TIMERS.pm42
-rw-r--r--lib/XXV/MODULES/VTX.pm2556
9 files changed, 3639 insertions, 3639 deletions
diff --git a/lib/XXV/MODULES/AUTOTIMER.pm b/lib/XXV/MODULES/AUTOTIMER.pm
index 04903ba..3991835 100644
--- a/lib/XXV/MODULES/AUTOTIMER.pm
+++ b/lib/XXV/MODULES/AUTOTIMER.pm
@@ -1,285 +1,285 @@
-package XXV::MODULES::AUTOTIMER;
-
-use strict;
-
-use Tools;
-use Locale::gettext;
-
-
-# ------------------
-# Name: module
-# Descr: The standard routine to describe the Plugin
-# Usage: my $modhash = $obj->module();
-# ------------------
-sub module {
- my $obj = shift || return error ('No Object!' );
- my $args = {
- Name => 'AUTOTIMER',
- Prereq => {
- # 'Perl::Module' => 'Description',
- },
- Description => gettext('This module search for epg entries with an user defined text and create new timer.'),
- Version => '0.95',
- Date => '2007-08-14',
- Author => 'xpix',
- Status => sub{ $obj->status(@_) },
- Preferences => {
- active => {
- description => gettext('Activate this service'),
- default => 'y',
- type => 'confirm',
- required => gettext('This is required!'),
- },
- exclude => {
- description => gettext('Exclude channel list for autotimer.'),
- type => 'string',
- default => 'POS > 50',
- check => sub{
- my $value = shift;
- if(index($value, ',') != -1) {
- return 'POS > 50'; # Nur um sicher zu sein, das die alten Werte nicht übernommen werden.
- } else {
- return $value;
- }
- },
- },
- },
- Commands => {
- astatus => {
- description => gettext('Status from autotimers'),
- short => 'as',
- callback => sub{ $obj->status(@_) },
- DenyClass => 'alist',
- },
- anew => {
- description => gettext("Create a new autotimer"),
- short => 'an',
- callback => sub{ $obj->autotimerCreate(@_) },
- Level => 'user',
- DenyClass => 'aedit',
- },
- adelete => {
- description => gettext("Delete a autotimer 'aid'"),
- short => 'ad',
- callback => sub{ $obj->autotimerDelete(@_) },
- Level => 'user',
- DenyClass => 'aedit',
- },
- aedit => {
- description => gettext("Edit a autotimer 'aid'"),
- short => 'ae',
- callback => sub{ $obj->autotimerEdit(@_) },
- Level => 'user',
- DenyClass => 'aedit',
- },
- asearch => {
- description => gettext("Search for autotimer with text 'aid'"),
- short => 'ase',
- callback => sub{ $obj->list(@_) },
- DenyClass => 'alist',
- },
- alist => {
- description => gettext("List the autotimer 'aid'"),
- short => 'al',
- callback => sub{ $obj->list(@_) },
- DenyClass => 'alist',
- },
- aupdate => {
- description => gettext("Start the autotimer process"),
- short => 'au',
- callback => sub{ $obj->autotimer(@_) },
- Level => 'user',
- DenyClass => 'aedit',
- },
- atoggle => {
- description => gettext("Toggle autotimer on or off 'aid'"),
- short => 'at',
- callback => sub{ $obj->autotimerToggle(@_) },
- Level => 'user',
- DenyClass => 'aedit',
+package XXV::MODULES::AUTOTIMER;
+
+use strict;
+
+use Tools;
+use Locale::gettext;
+
+
+# ------------------
+# Name: module
+# Descr: The standard routine to describe the Plugin
+# Usage: my $modhash = $obj->module();
+# ------------------
+sub module {
+ my $obj = shift || return error ('No Object!' );
+ my $args = {
+ Name => 'AUTOTIMER',
+ Prereq => {
+ # 'Perl::Module' => 'Description',
+ },
+ Description => gettext('This module search for epg entries with an user defined text and create new timer.'),
+ Version => (split(/ /, '$Revision$'))[1],
+ Date => (split(/ /, '$Date$'))[1],
+ Author => 'xpix',
+ Status => sub{ $obj->status(@_) },
+ Preferences => {
+ active => {
+ description => gettext('Activate this service'),
+ default => 'y',
+ type => 'confirm',
+ required => gettext('This is required!'),
+ },
+ exclude => {
+ description => gettext('Exclude channel list for autotimer.'),
+ type => 'string',
+ default => 'POS > 50',
+ check => sub{
+ my $value = shift;
+ if(index($value, ',') != -1) {
+ return 'POS > 50'; # Nur um sicher zu sein, das die alten Werte nicht übernommen werden.
+ } else {
+ return $value;
+ }
+ },
+ },
+ },
+ Commands => {
+ astatus => {
+ description => gettext('Status from autotimers'),
+ short => 'as',
+ callback => sub{ $obj->status(@_) },
+ DenyClass => 'alist',
+ },
+ anew => {
+ description => gettext("Create a new autotimer"),
+ short => 'an',
+ callback => sub{ $obj->autotimerCreate(@_) },
+ Level => 'user',
+ DenyClass => 'aedit',
+ },
+ adelete => {
+ description => gettext("Delete a autotimer 'aid'"),
+ short => 'ad',
+ callback => sub{ $obj->autotimerDelete(@_) },
+ Level => 'user',
+ DenyClass => 'aedit',
+ },
+ aedit => {
+ description => gettext("Edit a autotimer 'aid'"),
+ short => 'ae',
+ callback => sub{ $obj->autotimerEdit(@_) },
+ Level => 'user',
+ DenyClass => 'aedit',
+ },
+ asearch => {
+ description => gettext("Search for autotimer with text 'aid'"),
+ short => 'ase',
+ callback => sub{ $obj->list(@_) },
+ DenyClass => 'alist',
+ },
+ alist => {
+ description => gettext("List the autotimer 'aid'"),
+ short => 'al',
+ callback => sub{ $obj->list(@_) },
+ DenyClass => 'alist',
+ },
+ aupdate => {
+ description => gettext("Start the autotimer process"),
+ short => 'au',
+ callback => sub{ $obj->autotimer(@_) },
+ Level => 'user',
+ DenyClass => 'aedit',
+ },
+ atoggle => {
+ description => gettext("Toggle autotimer on or off 'aid'"),
+ short => 'at',
+ callback => sub{ $obj->autotimerToggle(@_) },
+ Level => 'user',
+ DenyClass => 'aedit',
},
asuggest => {
- hidden => 'yes',
+ hidden => 'yes',
callback => sub{ $obj->suggest(@_) },
DenyClass => 'alist',
- },
- },
- RegEvent => {
- 'newTimerfromAutotimer' => {
- Descr => gettext('Create event entries, if a new timer from autotimer created.'),
-
- # You have this choices (harmless is default):
- # 'harmless', 'interesting', 'veryinteresting', 'important', 'veryimportant'
- Level => 'veryinteresting',
-
- # Search for a spezial Event.
- # I.e.: Search for an LogEvent with match
- # "Sub=>text" = subroutine =~ /text/
- # "Msg=>text" = logmessage =~ /text/
- # "Mod=>text" = modname =~ /text/
- SearchForEvent => {
- Sub => 'AUTOTIMER',
- Msg => 'Save timer',
- },
- # Search for a Match and extract the information
- # of the TimerId
- # ...
- Match => {
- TimerId => qr/TimerId\:\s+\"(\d+)\"/s,
- },
- Actions => [
- q|sub{ my $args = shift;
- my $event = shift;
+ },
+ },
+ RegEvent => {
+ 'newTimerfromAutotimer' => {
+ Descr => gettext('Create event entries, if a new timer from autotimer created.'),
+
+ # You have this choices (harmless is default):
+ # 'harmless', 'interesting', 'veryinteresting', 'important', 'veryimportant'
+ Level => 'veryinteresting',
+
+ # Search for a spezial Event.
+ # I.e.: Search for an LogEvent with match
+ # "Sub=>text" = subroutine =~ /text/
+ # "Msg=>text" = logmessage =~ /text/
+ # "Mod=>text" = modname =~ /text/
+ SearchForEvent => {
+ Sub => 'AUTOTIMER',
+ Msg => 'Save timer',
+ },
+ # Search for a Match and extract the information
+ # of the TimerId
+ # ...
+ Match => {
+ TimerId => qr/TimerId\:\s+\"(\d+)\"/s,
+ },
+ Actions => [
+ q|sub{ my $args = shift;
+ my $event = shift;
my $timer = getDataById($args->{TimerId}, 'TIMERS', 'Id');
- my $desc = getDataById($timer->{eventid}, 'EPG', 'eventid') if($timer->{eventid});
- my $autotimer = getDataById($timer->{AutotimerId}, 'AUTOTIMER', 'Id');
- my $title = sprintf(gettext("Autotimer('%s') found: %s"),
- $autotimer->{Search}, $timer->{File});
+ my $desc = getDataById($timer->{eventid}, 'EPG', 'eventid') if($timer->{eventid});
+ my $autotimer = getDataById($timer->{AutotimerId}, 'AUTOTIMER', 'Id');
+ my $title = sprintf(gettext("Autotimer('%s') found: %s"),
+ $autotimer->{Search}, $timer->{File});
my $description = sprintf(gettext("At: %s to %s\nDescription: %s"),
$timer->{NextStartTime},
fmttime($timer->{Stop}),
$desc && $desc->{description} ? $desc->{description} : ''
);
-
- main::getModule('REPORT')->news($title, $description, "display", $timer->{eventid}, "interesting");
- }
- |,
- ],
-
- },
- },
- };
- return $args;
-}
-
-# ------------------
-# Name: status
-# Descr: Standardsubroutine to report statistical data for Report Plugin.
-# Usage: my $report = $obj->status([$watcher, $console]);
-# ------------------
-sub status {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift;
- my $console = shift;
- my $lastReportTime = shift || 0;
-
- my $sql = qq|
-SELECT
- t.Id as __Id,
- t.File,
- t.Status as __Status,
- c.Name as Channel,
- c.Pos as __Pos,
- DATE_FORMAT(t.Day, '%e.%c.%Y') as Day,
- t.Start,
- t.Stop,
- t.Priority,
- UNIX_TIMESTAMP(t.NextStartTime) as __Day,
- t.Collision as __Collision,
- t.eventid as __NextEpgId,
- t.AutotimerId as __AutotimerId
-FROM
- TIMERS as t,
- CHANNELS as c
-WHERE
- t.ChannelID = c.Id
- and UNIX_TIMESTAMP(t.addtime) > ?
- and t.AutotimerId > 0
-ORDER BY
- t.NextStartTime|;
-
+
+ main::getModule('REPORT')->news($title, $description, "display", $timer->{eventid}, "interesting");
+ }
+ |,
+ ],
+
+ },
+ },
+ };
+ return $args;
+}
+
+# ------------------
+# Name: status
+# Descr: Standardsubroutine to report statistical data for Report Plugin.
+# Usage: my $report = $obj->status([$watcher, $console]);
+# ------------------
+sub status {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift;
+ my $console = shift;
+ my $lastReportTime = shift || 0;
+
+ my $sql = qq|
+SELECT
+ t.Id as __Id,
+ t.File,
+ t.Status as __Status,
+ c.Name as Channel,
+ c.Pos as __Pos,
+ DATE_FORMAT(t.Day, '%e.%c.%Y') as Day,
+ t.Start,
+ t.Stop,
+ t.Priority,
+ UNIX_TIMESTAMP(t.NextStartTime) as __Day,
+ t.Collision as __Collision,
+ t.eventid as __NextEpgId,
+ t.AutotimerId as __AutotimerId
+FROM
+ TIMERS as t,
+ CHANNELS as c
+WHERE
+ t.ChannelID = c.Id
+ and UNIX_TIMESTAMP(t.addtime) > ?
+ and t.AutotimerId > 0
+ORDER BY
+ t.NextStartTime|;
+
my $fields = fields($obj->{dbh}, $sql);
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($lastReportTime)
or return error "Can't execute query: $sth->errstr.";
- my $erg = $sth->fetchall_arrayref();
- for(@$erg) {
- $_->[6] = fmttime($_->[6]);
- $_->[7] = fmttime($_->[7]);
- }
-
- unshift(@$erg, $fields);
- return {
- message => sprintf(gettext('Autotimer has %d new timer programmed, since last report at %s'),
- (scalar @$erg - 1), scalar localtime($lastReportTime)),
- table => $erg,
- };
-}
-
-
-# ------------------
-sub new {
-# ------------------
- my($class, %attr) = @_;
- my $self = {};
- bless($self, $class);
-
- # paths
- $self->{paths} = delete $attr{'-paths'};
-
- # who am I
- $self->{MOD} = $self->module;
-
- # all configvalues to $self without parents (important for ConfigModule)
- map {
- $self->{$_} = $attr{'-config'}->{$self->{MOD}->{Name}}->{$_};
+ my $erg = $sth->fetchall_arrayref();
+ for(@$erg) {
+ $_->[6] = fmttime($_->[6]);
+ $_->[7] = fmttime($_->[7]);
+ }
+
+ unshift(@$erg, $fields);
+ return {
+ message => sprintf(gettext('Autotimer has %d new timer programmed, since last report at %s'),
+ (scalar @$erg - 1), scalar localtime($lastReportTime)),
+ table => $erg,
+ };
+}
+
+
+# ------------------
+sub new {
+# ------------------
+ my($class, %attr) = @_;
+ my $self = {};
+ bless($self, $class);
+
+ # paths
+ $self->{paths} = delete $attr{'-paths'};
+
+ # who am I
+ $self->{MOD} = $self->module;
+
+ # all configvalues to $self without parents (important for ConfigModule)
+ map {
+ $self->{$_} = $attr{'-config'}->{$self->{MOD}->{Name}}->{$_};
$self->{$_} = $self->{MOD}->{Preferences}->{$_}->{default} unless($self->{$_});
- } keys %{$self->{MOD}->{Preferences}};
-
- # Try to use the Requirments
- map {
- eval "use $_";
- return panic("\nCan not load Module: $_\nPlease install this module on your System:\nperl -MCPAN -e 'install $_'") if($@);
- } keys %{$self->{MOD}->{Prereq}};
-
- # read the DB Handle
- $self->{dbh} = delete $attr{'-dbh'};
-
- # file
- $self->{file} = $self->{config}->{file};
-
- # The Initprocess
- my $erg = $self->_init or return error('Problem to initialize module');
-
- return $self;
-}
-
-# ------------------
-sub _init {
-# ------------------
- my $obj = shift || return error ('No Object!' );
+ } keys %{$self->{MOD}->{Preferences}};
+
+ # Try to use the Requirments
+ map {
+ eval "use $_";
+ return panic("\nCan not load Module: $_\nPlease install this module on your System:\nperl -MCPAN -e 'install $_'") if($@);
+ } keys %{$self->{MOD}->{Prereq}};
+
+ # read the DB Handle
+ $self->{dbh} = delete $attr{'-dbh'};
+
+ # file
+ $self->{file} = $self->{config}->{file};
+
+ # The Initprocess
+ my $erg = $self->_init or return error('Problem to initialize module');
+
+ return $self;
+}
+
+# ------------------
+sub _init {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
return 0, panic("Session to database is'nt connected")
unless($obj->{dbh});
# don't remove old table, if updated rows => warn only
tableUpdated($obj->{dbh},'AUTOTIMER',19,0);
-
- # Look for table or create this table
- my $version = main::getVersion;
- $obj->{dbh}->do(qq|
- CREATE TABLE IF NOT EXISTS AUTOTIMER (
- Id int(11) unsigned auto_increment NOT NULL,
- Activ enum('y', 'n') default 'y',
- Done set('timer', 'recording', 'chronicle' ) NOT NULL default 'timer',
- Search text NOT NULL default '',
- InFields set('title', 'subtitle', 'description' ) NOT NULL,
- Channels text default '',
- Start char(4) default '0000',
- Stop char(4) default '0000',
- MinLength tinyint default NULL,
- Priority tinyint(2) default NULL,
- Lifetime tinyint(2) default NULL,
- Dir text,
- VPS enum('y', 'n') default 'n',
- prevminutes tinyint default NULL,
- afterminutes tinyint default NULL,
+
+ # Look for table or create this table
+ my $version = main::getVersion;
+ $obj->{dbh}->do(qq|
+ CREATE TABLE IF NOT EXISTS AUTOTIMER (
+ Id int(11) unsigned auto_increment NOT NULL,
+ Activ enum('y', 'n') default 'y',
+ Done set('timer', 'recording', 'chronicle' ) NOT NULL default 'timer',
+ Search text NOT NULL default '',
+ InFields set('title', 'subtitle', 'description' ) NOT NULL,
+ Channels text default '',
+ Start char(4) default '0000',
+ Stop char(4) default '0000',
+ MinLength tinyint default NULL,
+ Priority tinyint(2) default NULL,
+ Lifetime tinyint(2) default NULL,
+ Dir text,
+ VPS enum('y', 'n') default 'n',
+ prevminutes tinyint default NULL,
+ afterminutes tinyint default NULL,
Weekdays set('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'),
startdate datetime default NULL,
- stopdate datetime default NULL,
- count int(11) default NULL,
- PRIMARY KEY (Id)
- ) COMMENT = '$version'
+ stopdate datetime default NULL,
+ count int(11) default NULL,
+ PRIMARY KEY (Id)
+ ) COMMENT = '$version'
|);
main::after(sub{
@@ -287,29 +287,29 @@ sub _init {
$m->updated(sub{
return 0 if($obj->{active} ne 'y');
- lg 'Start autotimer callback to find new events!';
+ lg 'Start autotimer callback to find new events!';
return $obj->autotimer();
});
return 1;
}, "AUTOTIMER: Install callback at update epg data ...", 30);
- return 1;
-}
-
-# ------------------
-# Name: autotimer
-# Descr: Routine to parse the EPG Data for users Autotimer.
-# If Autotimerid given, then will this search only
-# for this Autotimer else for all.
-# Usage: $obj->autotimer([$autotimerid]);
-# ------------------
-sub autotimer {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift;
- my $console = shift;
- my $autotimerid = shift;
-
+ return 1;
+}
+
+# ------------------
+# Name: autotimer
+# Descr: Routine to parse the EPG Data for users Autotimer.
+# If Autotimerid given, then will this search only
+# for this Autotimer else for all.
+# Usage: $obj->autotimer([$autotimerid]);
+# ------------------
+sub autotimer {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift;
+ my $console = shift;
+ my $autotimerid = shift;
+
# Get Autotimer
my $sth;
if($autotimerid) {
@@ -322,40 +322,40 @@ sub autotimer {
or return error sprintf("Can't execute query: %s.",$sth->errstr);
}
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("Look for autotimer ..."), 0, ++$zaehler, 'no');
- }
-
- my $l = 0; # Lines for Waiter
- my $C = 0; # Total of created and modifed timers
- my $M = 0;
- my $log;
-
- my $vdrVersion = main::getVdrVersion();
-
- # Get Timersmodule
- my $timermod = main::getModule('TIMERS');
- foreach my $id (sort keys %$att) {
- my $a = $att->{$id};
-
- $waiter->next(++$l, undef, sprintf(gettext("Look for autotimer with ID(%d) with search '%s'"), $id, $a->{Search}))
- if(ref $waiter);
-
- if(ref $console && $autotimerid) {
- $console->message(' ') if($console->{TYP} eq 'HTML');
- $console->message(sprintf(gettext("Look for autotimer with ID(%d) with search '%s'"), $id, $a->{Search}));
- }
-
- # Build SQL Command and run it ....
- my $events = $obj->_eventsearch($a, $timermod) || next;
-
- # Only search for one at?
- if(ref $console && $autotimerid) {
- $console->message(sprintf(gettext("Found %d entries for '%s' in EPG database."), scalar keys %$events, $a->{Search}));
- foreach my $Id (sort keys %$events) {
+
+ my $waiter;
+ if(ref $console && !$autotimerid && $console->typ eq 'HTML') {
+ my $zaehler = scalar keys %$att;
+ $waiter = $console->wait(gettext("Look for autotimer ..."), 0, ++$zaehler, 'no');
+ }
+
+ my $l = 0; # Lines for Waiter
+ my $C = 0; # Total of created and modifed timers
+ my $M = 0;
+ my $log;
+
+ my $vdrVersion = main::getVdrVersion();
+
+ # Get Timersmodule
+ my $timermod = main::getModule('TIMERS');
+ foreach my $id (sort keys %$att) {
+ my $a = $att->{$id};
+
+ $waiter->next(++$l, undef, sprintf(gettext("Look for autotimer with ID(%d) with search '%s'"), $id, $a->{Search}))
+ if(ref $waiter);
+
+ if(ref $console && $autotimerid) {
+ $console->message(' ') if($console->{TYP} eq 'HTML');
+ $console->message(sprintf(gettext("Look for autotimer with ID(%d) with search '%s'"), $id, $a->{Search}));
+ }
+
+ # Build SQL Command and run it ....
+ my $events = $obj->_eventsearch($a, $timermod) || next;
+
+ # Only search for one at?
+ if(ref $console && $autotimerid) {
+ $console->message(sprintf(gettext("Found %d entries for '%s' in EPG database."), scalar keys %$events, $a->{Search}));
+ foreach my $Id (sort keys %$events) {
my $output = {
gettext("Channel") => $events->{$Id}->{Channel},
gettext("Title") => $events->{$Id}->{Title},
@@ -366,521 +366,521 @@ sub autotimer {
gettext("Description") => $events->{$Id}->{Summary},
};
$console->table($output);
- };
- }
-
- # Every found and save this as timer
- my $c = 0;
- my $m = 0;
- foreach my $Id (sort keys %$events) {
- $events->{$Id}->{Activ} = 'y';
- $events->{$Id}->{VPS} = ($events->{$Id}->{VpsStart} && $a->{VPS} eq 'y') ? 'y' : '';
- $events->{$Id}->{Priority} = $a->{Priority};
- $events->{$Id}->{Lifetime} = $a->{Lifetime};
-
- $events->{$Id}->{File} = $obj->_placeholder($events->{$Id}, $a);
-
- if($events->{$Id}->{VPS} eq 'y') {
- $events->{$Id}->{Start} = $events->{$Id}->{VpsStart};
- $events->{$Id}->{Stop} = $events->{$Id}->{VpsStop};
+ };
+ }
+
+ # Every found and save this as timer
+ my $c = 0;
+ my $m = 0;
+ foreach my $Id (sort keys %$events) {
+ $events->{$Id}->{Activ} = 'y';
+ $events->{$Id}->{VPS} = ($events->{$Id}->{VpsStart} && $a->{VPS} eq 'y') ? 'y' : '';
+ $events->{$Id}->{Priority} = $a->{Priority};
+ $events->{$Id}->{Lifetime} = $a->{Lifetime};
+
+ $events->{$Id}->{File} = $obj->_placeholder($events->{$Id}, $a);
+
+ if($events->{$Id}->{VPS} eq 'y') {
+ $events->{$Id}->{Start} = $events->{$Id}->{VpsStart};
+ $events->{$Id}->{Stop} = $events->{$Id}->{VpsStop};
}
- my $nexttime = $timermod->getNextTime( $events->{$Id}->{Day} , $events->{$Id}->{Start},$events->{$Id}->{Stop} )
- or error(sprintf("Can't get the nexttime for this autotimer: %d", $events->{$Id}->{eventid}));
-
- # Add anchor for reidentify timer
- my $aidcomment = sprintf('#~AT[%d]', $id);
-
- if($vdrVersion >= 10344){
- $events->{$Id}->{Summary} = $aidcomment;
- } else {
- $events->{$Id}->{Summary} .= $aidcomment;
- }
-
- my @parameters = ($events->{$Id}, $nexttime, $aidcomment);
-
- # Wished timer already exist with same data from autotimer ?
+ my $nexttime = $timermod->getNextTime( $events->{$Id}->{Day} , $events->{$Id}->{Start},$events->{$Id}->{Stop} )
+ or error(sprintf("Can't get the nexttime for this autotimer: %d", $events->{$Id}->{eventid}));
+
+ # Add anchor for reidentify timer
+ my $aidcomment = sprintf('#~AT[%d]', $id);
+
+ if($vdrVersion >= 10344){
+ $events->{$Id}->{Summary} = $aidcomment;
+ } else {
+ $events->{$Id}->{Summary} .= $aidcomment;
+ }
+
+ my @parameters = ($events->{$Id}, $nexttime, $aidcomment);
+
+ # Wished timer already exist with same data from autotimer ?
next if($obj->_timerexists(@parameters));
- # Adjust timers set by the autotimer
- my $timerID = $obj->_timerexistsfuzzy(@parameters);
-
- if(!$timerID && $a->{Done}) {
+ # Adjust timers set by the autotimer
+ my $timerID = $obj->_timerexistsfuzzy(@parameters);
+
+ if(!$timerID && $a->{Done}) {
my @done = split(',', $a->{Done});
- # Ignore timer if it already with same title recorded
+ # Ignore timer if it already with same title recorded
if(grep(/^chronicle$/, @done) && $obj->_chronicleexists(@parameters)) {
lg sprintf("Don't create timer from AT(%d) '%s', because found same data on chronicle", $id, $events->{$Id}->{File});
next;
- }
+ }
- # Ignore timer if it already with same title recorded
+ # Ignore timer if it already with same title recorded
if(grep(/^recording$/, @done) && $obj->_recordexists(@parameters)){
lg sprintf("Don't create timer from AT(%d) '%s', because found same data on recordings", $id, $events->{$Id}->{File});
next;
- }
- # Ignore timer if it already a timer with same title programmed, on other place
+ }
+ # Ignore timer if it already a timer with same title programmed, on other place
if(grep(/^timer$/, @done) && $obj->_timerexiststitle(@parameters)){
lg sprintf("Don't create timer from AT(%d) '%s', because found same data on other timers", $id, $events->{$Id}->{File});
next;
- }
- }
-
- my $error = 0;
- my $erg = $timermod->saveTimer($events->{$Id}, $timerID ? $timerID : undef);
- foreach my $zeile (@$erg) {
- if($zeile =~ /^(\d{3})\s+(.+)/) {
- $error = $2 if(int($1) >= 500);
- }
- }
- if($error) {
- $console->err(sprintf(gettext("Can't save timer for '%s' : %s"), $events->{$Id}->{File}, $error))
- if(ref $console && $autotimerid);
- } else {
- if($timerID) {
- ++$m;
- $console->message(sprintf(gettext("Modify timer for '%s'."), $events->{$Id}->{File}))
- if(ref $console && $autotimerid);
- } else {
- ++$c;
- $console->message(sprintf(gettext("Create timer for '%s'."), $events->{$Id}->{File}))
- if(ref $console && $autotimerid);
- }
- }
- }
- $C += $c;
- $M += $m;
- if($c) {
- my $msg = sprintf(gettext("Create %d timer for '%s'."), $c, $a->{Search});
- if(ref $console && $autotimerid) {
- $console->message($msg);
- }
- else {
- push(@{$log},$msg);
- }
- }
- if($m) {
- my $msg = sprintf(gettext("Modify %d timer for '%s'."), $m, $a->{Search});
- if(ref $console && $autotimerid) {
- $console->message($msg);
- }
- else {
- push(@{$log},$msg);
- }
- }
- }
-
- $waiter->next(undef,undef,gettext('Read new timer in data base.'))
- if(ref $waiter);
-
- sleep 1;
-
- $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 has %d timers created and %d timers modified."), $C, $M));
- lg join("\n", @$log);
- $console->message($log);
- $console->link({
- text => gettext("Back to autotimer list"),
- url => "?cmd=alist",
- }) if($console->typ eq 'HTML');
+ }
+ }
+
+ my $error = 0;
+ my $erg = $timermod->saveTimer($events->{$Id}, $timerID ? $timerID : undef);
+ foreach my $zeile (@$erg) {
+ if($zeile =~ /^(\d{3})\s+(.+)/) {
+ $error = $2 if(int($1) >= 500);
+ }
+ }
+ if($error) {
+ $console->err(sprintf(gettext("Can't save timer for '%s' : %s"), $events->{$Id}->{File}, $error))
+ if(ref $console && $autotimerid);
+ } else {
+ if($timerID) {
+ ++$m;
+ $console->message(sprintf(gettext("Modify timer for '%s'."), $events->{$Id}->{File}))
+ if(ref $console && $autotimerid);
+ } else {
+ ++$c;
+ $console->message(sprintf(gettext("Create timer for '%s'."), $events->{$Id}->{File}))
+ if(ref $console && $autotimerid);
+ }
+ }
+ }
+ $C += $c;
+ $M += $m;
+ if($c) {
+ my $msg = sprintf(gettext("Create %d timer for '%s'."), $c, $a->{Search});
+ if(ref $console && $autotimerid) {
+ $console->message($msg);
+ }
+ else {
+ push(@{$log},$msg);
+ }
+ }
+ if($m) {
+ my $msg = sprintf(gettext("Modify %d timer for '%s'."), $m, $a->{Search});
+ if(ref $console && $autotimerid) {
+ $console->message($msg);
+ }
+ else {
+ push(@{$log},$msg);
+ }
+ }
+ }
+
+ $waiter->next(undef,undef,gettext('Read new timer in data base.'))
+ if(ref $waiter);
+
+ sleep 1;
+
+ $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 has %d timers created and %d timers modified."), $C, $M));
+ lg join("\n", @$log);
+ $console->message($log);
+ $console->link({
+ text => gettext("Back to autotimer list"),
+ url => "?cmd=alist",
+ }) if($console->typ eq 'HTML');
}
- return 1;
-}
-
-# ------------------
-# Name: autotimerCreate
-# Descr: Routine to display the create form for Autotimer.
-# Usage: $obj->autotimerCreate($watcher, $console, [$userdata]);
-# ------------------
-sub autotimerCreate {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $timerid = shift || 0;
- my $data = shift || 0;
-
- $obj->autotimerEdit($watcher, $console, $timerid, $data);
-}
-
-# ------------------
-# Name: autotimerEdit
-# Descr: Routine to display the edit form for Autotimer.
-# Usage: $obj->autotimerEdit($watcher, $console, [$atid], [$userdata]);
-# ------------------
-sub autotimerEdit {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $timerid = shift || 0;
- my $data = shift || 0;
-
- my $mod = main::getModule('CHANNELS');
- my $modT = main::getModule('TIMERS');
-
- my $epg;
+ return 1;
+}
+
+# ------------------
+# Name: autotimerCreate
+# Descr: Routine to display the create form for Autotimer.
+# Usage: $obj->autotimerCreate($watcher, $console, [$userdata]);
+# ------------------
+sub autotimerCreate {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $timerid = shift || 0;
+ my $data = shift || 0;
+
+ $obj->autotimerEdit($watcher, $console, $timerid, $data);
+}
+
+# ------------------
+# Name: autotimerEdit
+# Descr: Routine to display the edit form for Autotimer.
+# Usage: $obj->autotimerEdit($watcher, $console, [$atid], [$userdata]);
+# ------------------
+sub autotimerEdit {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $timerid = shift || 0;
+ my $data = shift || 0;
+
+ my $mod = main::getModule('CHANNELS');
+ my $modT = main::getModule('TIMERS');
+
+ my $epg;
if($timerid and not ref $data) {
my $sth = $obj->{dbh}->prepare("select * from AUTOTIMER where Id = ?");
$sth->execute($timerid)
- or return $console->err(sprintf(gettext("Autotimer with ID '%s' does not exist in the database!"),$timerid));
+ or return $console->err(sprintf(gettext("Autotimer with ID '%s' does not exist in the database!"),$timerid));
$epg = $sth->fetchrow_hashref();
-
- # Channels Ids in Namen umwandeln
- my @channels = map { $_ = $mod->ChannelToPos($_) } split(/[\s|,]+/, $epg->{Channels});
- $epg->{Channels} = \@channels;
-
- # question erwartet ein Array
- my @done = split(/\s*,\s*/, $epg->{Done});
- $epg->{Done} = \@done;
- my @infields = split(/\s*,\s*/, $epg->{InFields});
- $epg->{InFields} = \@infields;
- my @weekdays = split(/\s*,\s*/, $epg->{Weekdays});
- $epg->{Weekdays} = \@weekdays;
-
- } elsif (ref $data eq 'HASH') {
- $epg = $data;
- }
-
- my %wd = (
- 'Mon' => gettext('Mon'),
- 'Tue' => gettext('Tue'),
- 'Wed' => gettext('Wed'),
- 'Thu' => gettext('Thu'),
- 'Fri' => gettext('Fri'),
- 'Sat' => gettext('Sat'),
- 'Sun' => gettext('Sun')
- );
-
- my %in = (
- 'title' => gettext('Title'),
- 'subtitle' => gettext('Subtitle'),
- 'description' => gettext('Description')
- );
-
- my %do = (
- 'timer' => gettext('Timer'),
- 'recording' => gettext('Exist recording'),
- 'chronicle' => gettext('Recording chronicle')
+
+ # Channels Ids in Namen umwandeln
+ my @channels = map { $_ = $mod->ChannelToPos($_) } split(/[\s|,]+/, $epg->{Channels});
+ $epg->{Channels} = \@channels;
+
+ # question erwartet ein Array
+ my @done = split(/\s*,\s*/, $epg->{Done});
+ $epg->{Done} = \@done;
+ my @infields = split(/\s*,\s*/, $epg->{InFields});
+ $epg->{InFields} = \@infields;
+ my @weekdays = split(/\s*,\s*/, $epg->{Weekdays});
+ $epg->{Weekdays} = \@weekdays;
+
+ } elsif (ref $data eq 'HASH') {
+ $epg = $data;
+ }
+
+ my %wd = (
+ 'Mon' => gettext('Mon'),
+ 'Tue' => gettext('Tue'),
+ 'Wed' => gettext('Wed'),
+ 'Thu' => gettext('Thu'),
+ 'Fri' => gettext('Fri'),
+ 'Sat' => gettext('Sat'),
+ 'Sun' => gettext('Sun')
+ );
+
+ my %in = (
+ 'title' => gettext('Title'),
+ 'subtitle' => gettext('Subtitle'),
+ 'description' => gettext('Description')
+ );
+
+ my %do = (
+ 'timer' => gettext('Timer'),
+ 'recording' => gettext('Exist recording'),
+ 'chronicle' => gettext('Recording chronicle')
);
my $DoneChoices = [$do{'timer'}, $do{'recording'}];
# Enable option "chronicle" only if activated.
- my $cm = main::getModule('CHRONICLE');
+ my $cm = main::getModule('CHRONICLE');
push(@$DoneChoices, $do{'chronicle'})
if($cm and $cm->{active} eq 'y');
- my $questions = [
- 'Id' => {
- typ => 'hidden',
- def => $epg->{Id} || 0,
- },
- 'Activ' => {
- typ => 'confirm',
- def => $epg->{Activ} || 'y',
- msg => gettext('Switch this autotimer on?'),
- },
- 'Search' => {
- req => gettext('This is required!'),
+ my $questions = [
+ 'Id' => {
+ typ => 'hidden',
+ def => $epg->{Id} || 0,
+ },
+ 'Activ' => {
+ typ => 'confirm',
+ def => $epg->{Activ} || 'y',
+ msg => gettext('Switch this autotimer on?'),
+ },
+ 'Search' => {
+ req => gettext('This is required!'),
msg => gettext(
"Search terms to look for EPG entries.\nYou can also improve your searches :\n* by adding 'operators' to your search terms like 'AND', 'OR', 'AND NOT' e.g. 'today AND NOT tomorrow'\n* by comma seperated multiply search terms e.g. 'today,tomorrow'\n* by minus sign to exclude search terms e.g. 'today,-tomorrow'"
-),
- def => $epg->{Search} || '',
- },
- 'InFields' => {
- msg => gettext('Search in this EPG fields'),
- typ => 'checkbox',
- choices => [$in{'title'}, $in{'subtitle'}, $in{'description'}],
- req => gettext('This is required!'),
- def => sub {
- my $value = $epg->{InFields} || ['title','subtitle'];
- my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
- my @ret;
- foreach my $v (@vals) {
- push(@ret,$in{$v});
- }
- return @ret;
- },
- check => sub{
- my $value = shift || return;
- my $data = shift || return error('No Data in CB');
- my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
- my @ret;
- foreach my $v (@vals) {
- unless(grep($_ eq $v, @{$data->{choices}})) {
- my $ch = join(' ', @{$data->{choices}});
- return undef, sprintf(gettext("You can choose: %s!"),$ch);
- }
- foreach my $k (keys %in) {
- push(@ret,$k)
- if($v eq $in{$k});
- }
- }
- return join(',', @ret);
- },
- },
- 'Channels' => {
- typ => 'list',
- def => $epg->{Channels},
- choices => $mod->ChannelArray('Name', sprintf(' NOT (%s)', $obj->{exclude})),
- options => 'multi',
- msg => gettext('Restrict search to this channels'),
- check => sub{
- my $value = shift || return;
- my @vals;
- foreach my $chname ((ref $value eq 'ARRAY' ? @$value : split(/\s*,\s*/, $value))) {
- if( my $chid = $mod->PosToChannel($chname) || $mod->NameToChannel($chname)) {
- push(@vals, $chid);
- } else {
- return undef, sprintf(gettext("The channel '%s' does not exist!"),$chname);
- }
- }
- return join(',', @vals);
- },
- },
- 'Done' => {
- msg => gettext('Ignore retries with same title?'),
- typ => 'checkbox',
- choices => $DoneChoices,
- def => sub {
- my $value = $epg->{Done};
- my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
- my @ret;
- foreach my $v (@vals) {
- push(@ret,$do{$v});
- }
- return @ret;
- },
- check => sub{
- my $value = shift || '';
- my $data = shift || return error('No Data in CB');
- my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
- my @ret;
- foreach my $v (@vals) {
- unless(grep($_ eq $v, @{$data->{choices}})) {
- my $ch = join(' ', @{$data->{choices}});
- return undef, sprintf(gettext("You can choose: %s!"),$ch);
- }
- foreach my $k (keys %do) {
- push(@ret,$k)
- if($v eq $do{$k});
- }
- }
- return join(',', @ret);
- },
- },
- 'Start' => {
- typ => 'string',
- def => sub{
- my $value = $epg->{Start} || return "";
- return fmttime($value);
- },
- msg => gettext("Starttime in format 'HH:MM'"),
- check => sub{
- my $value = shift || 0;
- return undef, gettext('You set a start-time without a stop-time!')
- if(not $data->{Stop} and $value);
- return "" if(not $value);
- $value = fmttime($value) if($value =~ /^\d+$/sig);
- return undef, gettext('No right time!') if($value !~ /^\d+:\d+$/sig);
- my @v = split(':', $value);
- $value = sprintf('%02d%02d',$v[0],$v[1]);
- if(int($value) < 2400 and int($value) >= 0) {
- return sprintf('%04d',$value);
- } else {
- return undef, gettext('No right time!');
- }
- },
- },
- 'Stop' => {
- typ => 'string',
- def => sub{
- my $value = $epg->{Stop} || return "";
- return fmttime($value);
- },
- msg => gettext("Endtime in format 'HH:MM'"),
- check => sub{
- my $value = shift || 0;
- return undef, gettext('You set a stop-time without a start-time!')
- if(not $data->{Start} and $value);
- return "" if(not $value);
- $value = fmttime($value) if($value =~ /^\d+$/sig);
- return undef, gettext('No right time!') if($value !~ /^\d+:\d+$/sig);
- my @v = split(':', $value);
- $value = sprintf('%02d%02d',$v[0],$v[1]);
- if(int($value) < 2400 and int($value) >= 0) {
- return sprintf('%04d',$value);
- } else {
- return undef, gettext('No right time!');
- }
- },
- },
- 'Weekdays' => {
- msg => gettext('Search only on this weekdays'),
- typ => 'checkbox',
- choices => [$wd{'Mon'}, $wd{'Tue'}, $wd{'Wed'}, $wd{'Thu'}, $wd{'Fri'}, $wd{'Sat'}, $wd{'Sun'}],
- def => sub {
- my $value = $epg->{Weekdays} || ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
- my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
- my @ret;
- foreach my $v (@vals) {
- push(@ret,$wd{$v});
- }
- return @ret;
- },
- check => sub{
- my $value = shift || [$wd{'Mon'}, $wd{'Tue'}, $wd{'Wed'}, $wd{'Thu'}, $wd{'Fri'}, $wd{'Sat'}, $wd{'Sun'}];
- my $data = shift || return error('No Data in CB');
- my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
- my @ret;
- foreach my $v (@vals) {
- unless(grep($_ eq $v, @{$data->{choices}})) {
- my $ch = join(' ', @{$data->{choices}});
- return undef, sprintf(gettext("You can choose: %s!"),$ch);
- }
- foreach my $k (keys %wd) {
- push(@ret,$k)
- if($v eq $wd{$k});
- }
- }
- return join(',', @ret);
- },
- },
- 'VPS' => {
- typ => 'confirm',
- def => $epg->{VPS} || 'n',
- msg => gettext('Activate VPS for new timer?'),
- },
- 'prevminutes' => {
- typ => 'integer',
- msg => gettext('Buffer time in minutes before the scheduled end of the recorded program.'),
- def => $epg->{prevminutes},
- check => sub{
+),
+ def => $epg->{Search} || '',
+ },
+ 'InFields' => {
+ msg => gettext('Search in this EPG fields'),
+ typ => 'checkbox',
+ choices => [$in{'title'}, $in{'subtitle'}, $in{'description'}],
+ req => gettext('This is required!'),
+ def => sub {
+ my $value = $epg->{InFields} || ['title','subtitle'];
+ my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
+ my @ret;
+ foreach my $v (@vals) {
+ push(@ret,$in{$v});
+ }
+ return @ret;
+ },
+ check => sub{
+ my $value = shift || return;
+ my $data = shift || return error('No Data in CB');
+ my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
+ my @ret;
+ foreach my $v (@vals) {
+ unless(grep($_ eq $v, @{$data->{choices}})) {
+ my $ch = join(' ', @{$data->{choices}});
+ return undef, sprintf(gettext("You can choose: %s!"),$ch);
+ }
+ foreach my $k (keys %in) {
+ push(@ret,$k)
+ if($v eq $in{$k});
+ }
+ }
+ return join(',', @ret);
+ },
+ },
+ 'Channels' => {
+ typ => 'list',
+ def => $epg->{Channels},
+ choices => $mod->ChannelArray('Name', sprintf(' NOT (%s)', $obj->{exclude})),
+ options => 'multi',
+ msg => gettext('Restrict search to this channels'),
+ check => sub{
+ my $value = shift || return;
+ my @vals;
+ foreach my $chname ((ref $value eq 'ARRAY' ? @$value : split(/\s*,\s*/, $value))) {
+ if( my $chid = $mod->PosToChannel($chname) || $mod->NameToChannel($chname)) {
+ push(@vals, $chid);
+ } else {
+ return undef, sprintf(gettext("The channel '%s' does not exist!"),$chname);
+ }
+ }
+ return join(',', @vals);
+ },
+ },
+ 'Done' => {
+ msg => gettext('Ignore retries with same title?'),
+ typ => 'checkbox',
+ choices => $DoneChoices,
+ def => sub {
+ my $value = $epg->{Done};
+ my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
+ my @ret;
+ foreach my $v (@vals) {
+ push(@ret,$do{$v});
+ }
+ return @ret;
+ },
+ check => sub{
+ my $value = shift || '';
+ my $data = shift || return error('No Data in CB');
+ my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
+ my @ret;
+ foreach my $v (@vals) {
+ unless(grep($_ eq $v, @{$data->{choices}})) {
+ my $ch = join(' ', @{$data->{choices}});
+ return undef, sprintf(gettext("You can choose: %s!"),$ch);
+ }
+ foreach my $k (keys %do) {
+ push(@ret,$k)
+ if($v eq $do{$k});
+ }
+ }
+ return join(',', @ret);
+ },
+ },
+ 'Start' => {
+ typ => 'string',
+ def => sub{
+ my $value = $epg->{Start} || return "";
+ return fmttime($value);
+ },
+ msg => gettext("Starttime in format 'HH:MM'"),
+ check => sub{
+ my $value = shift || 0;
+ return undef, gettext('You set a start-time without a stop-time!')
+ if(not $data->{Stop} and $value);
+ return "" if(not $value);
+ $value = fmttime($value) if($value =~ /^\d+$/sig);
+ return undef, gettext('No right time!') if($value !~ /^\d+:\d+$/sig);
+ my @v = split(':', $value);
+ $value = sprintf('%02d%02d',$v[0],$v[1]);
+ if(int($value) < 2400 and int($value) >= 0) {
+ return sprintf('%04d',$value);
+ } else {
+ return undef, gettext('No right time!');
+ }
+ },
+ },
+ 'Stop' => {
+ typ => 'string',
+ def => sub{
+ my $value = $epg->{Stop} || return "";
+ return fmttime($value);
+ },
+ msg => gettext("Endtime in format 'HH:MM'"),
+ check => sub{
+ my $value = shift || 0;
+ return undef, gettext('You set a stop-time without a start-time!')
+ if(not $data->{Start} and $value);
+ return "" if(not $value);
+ $value = fmttime($value) if($value =~ /^\d+$/sig);
+ return undef, gettext('No right time!') if($value !~ /^\d+:\d+$/sig);
+ my @v = split(':', $value);
+ $value = sprintf('%02d%02d',$v[0],$v[1]);
+ if(int($value) < 2400 and int($value) >= 0) {
+ return sprintf('%04d',$value);
+ } else {
+ return undef, gettext('No right time!');
+ }
+ },
+ },
+ 'Weekdays' => {
+ msg => gettext('Search only on this weekdays'),
+ typ => 'checkbox',
+ choices => [$wd{'Mon'}, $wd{'Tue'}, $wd{'Wed'}, $wd{'Thu'}, $wd{'Fri'}, $wd{'Sat'}, $wd{'Sun'}],
+ def => sub {
+ my $value = $epg->{Weekdays} || ['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
+ my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
+ my @ret;
+ foreach my $v (@vals) {
+ push(@ret,$wd{$v});
+ }
+ return @ret;
+ },
+ check => sub{
+ my $value = shift || [$wd{'Mon'}, $wd{'Tue'}, $wd{'Wed'}, $wd{'Thu'}, $wd{'Fri'}, $wd{'Sat'}, $wd{'Sun'}];
+ my $data = shift || return error('No Data in CB');
+ my @vals = (ref $value eq 'ARRAY') ? @$value : split(/\s*,\s*/, $value);
+ my @ret;
+ foreach my $v (@vals) {
+ unless(grep($_ eq $v, @{$data->{choices}})) {
+ my $ch = join(' ', @{$data->{choices}});
+ return undef, sprintf(gettext("You can choose: %s!"),$ch);
+ }
+ foreach my $k (keys %wd) {
+ push(@ret,$k)
+ if($v eq $wd{$k});
+ }
+ }
+ return join(',', @ret);
+ },
+ },
+ 'VPS' => {
+ typ => 'confirm',
+ def => $epg->{VPS} || 'n',
+ msg => gettext('Activate VPS for new timer?'),
+ },
+ 'prevminutes' => {
+ typ => 'integer',
+ msg => gettext('Buffer time in minutes before the scheduled end of the recorded program.'),
+ def => $epg->{prevminutes},
+ check => sub{
my $value = shift;
- return if($value eq "");
- if($value =~ /^\d+$/sig and $value >= 0) {
- return int($value);
- } else {
- return undef, gettext('No right Value!');
- }
- },
- },
- 'afterminutes' => {
- typ => 'integer',
- msg => gettext('Buffer time in minutes after the scheduled end of the recorded program.'),
- def => $epg->{afterminutes},
- check => sub{
+ return if($value eq "");
+ if($value =~ /^\d+$/sig and $value >= 0) {
+ return int($value);
+ } else {
+ return undef, gettext('No right Value!');
+ }
+ },
+ },
+ 'afterminutes' => {
+ typ => 'integer',
+ msg => gettext('Buffer time in minutes after the scheduled end of the recorded program.'),
+ def => $epg->{afterminutes},
+ check => sub{
my $value = shift;
- return if($value eq "");
- if($value =~ /^\d+$/sig and $value >= 0) {
- return int($value);
- } else {
- return undef, gettext('No right Value!');
- }
- },
- },
- 'MinLength' => {
- typ => 'integer',
- msg => gettext('Minimum length in minutes'),
- def => $epg->{MinLength} || 0,
- check => sub{
- my $value = shift || return;
- if($value =~ /^\d+$/sig and $value > 0) {
- return int($value);
- } else {
- return undef, gettext('No right Value!');
- }
- },
- },
- 'Priority' => {
- typ => 'integer',
- msg => sprintf(gettext('Priority (0 .. %d)'),$console->{USER}->{MaxPriority} ? $console->{USER}->{MaxPriority} : 99 ),
- def => (defined $epg->{Priority} ? $epg->{Priority} : $modT->{Priority}),
- check => sub{
- my $value = shift || 0;
- if($value =~ /^\d+$/sig and $value >= 0 and $value < 100) {
- if($console->{USER}->{MaxPriority} and $value > $console->{USER}->{MaxPriority}) {
- return undef, sprintf(gettext('Sorry, but maximum priority is limited on %d!'), $console->{USER}->{MaxPriority});
- }
- return int($value);
- } else {
- return undef, gettext('No right Value!');
- }
- },
- },
- 'Lifetime' => {
- typ => 'integer',
- msg => sprintf(gettext('Lifetime (0 .. %d)'),$console->{USER}->{MaxLifeTime} ? $console->{USER}->{MaxLifeTime} : 99 ),
- def => (defined $epg->{Lifetime} ? $epg->{Lifetime} : $modT->{Lifetime}),
- check => sub{
- my $value = shift || 0;
- if($value =~ /^\d+$/sig and $value >= 0 and $value < 100) {
- if($console->{USER}->{MaxLifeTime} and $value > $console->{USER}->{MaxLifeTime}) {
- return undef, sprintf(gettext('Sorry, but maximum lifetime is limited on %d!'), $console->{USER}->{MaxLifeTime});
- }
- return int($value);
- } else {
- return undef, gettext('No right Value!');
- }
- },
- },
- 'Dir' => {
- typ => 'string',
- msg => gettext('Group all recordings on a directory'),
- def => $epg->{Dir},
- # choices => main::getModule('TIMERS')->getRootDirs,
- },
- ];
-
- # Ask Questions
- $data = $console->question(($timerid ? gettext('Edit autotimer')
- : gettext('Create a new autotimer')), $questions, $data);
-
- if(ref $data eq 'HASH') {
- delete $data->{Channel};
-
- # Last chance ;)
- return $console->err(gettext('Nothing to search defined!'))
- unless($data->{Search});
-
- $obj->_insert($data);
-
- $data->{Id} = $obj->{dbh}->selectrow_arrayref('SELECT max(ID) FROM AUTOTIMER')->[0]
- if(not $data->{Id});
-
- $console->message(gettext('Autotimer saved!'));
- debug sprintf('%s autotimer with search "%s" is saved%s',
- ($timerid ? 'Changed' : 'New'),
- $data->{Search},
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
- );
- $obj->autotimer($watcher, $console, $data->{Id});
-
- $console->link({
- text => gettext("Back to referred side"),
- url => $console->{browser}->{Referer},
- }) if($console->typ eq 'HTML');
-
- }
- return 1;
-}
-
-# ------------------
-# Name: autotimerDelete
-# Descr: Routine to display the delete form for Autotimer.
-# Usage: $obj->autotimerDelete($watcher, $console, $atid);
-# ------------------
-sub autotimerDelete {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $timerid = shift || return $console->err(gettext("No ID for autotimer to delete! Please use adelete 'aid'")); # If timerid the edittimer
+ return if($value eq "");
+ if($value =~ /^\d+$/sig and $value >= 0) {
+ return int($value);
+ } else {
+ return undef, gettext('No right Value!');
+ }
+ },
+ },
+ 'MinLength' => {
+ typ => 'integer',
+ msg => gettext('Minimum length in minutes'),
+ def => $epg->{MinLength} || 0,
+ check => sub{
+ my $value = shift || return;
+ if($value =~ /^\d+$/sig and $value > 0) {
+ return int($value);
+ } else {
+ return undef, gettext('No right Value!');
+ }
+ },
+ },
+ 'Priority' => {
+ typ => 'integer',
+ msg => sprintf(gettext('Priority (0 .. %d)'),$console->{USER}->{MaxPriority} ? $console->{USER}->{MaxPriority} : 99 ),
+ def => (defined $epg->{Priority} ? $epg->{Priority} : $modT->{Priority}),
+ check => sub{
+ my $value = shift || 0;
+ if($value =~ /^\d+$/sig and $value >= 0 and $value < 100) {
+ if($console->{USER}->{MaxPriority} and $value > $console->{USER}->{MaxPriority}) {
+ return undef, sprintf(gettext('Sorry, but maximum priority is limited on %d!'), $console->{USER}->{MaxPriority});
+ }
+ return int($value);
+ } else {
+ return undef, gettext('No right Value!');
+ }
+ },
+ },
+ 'Lifetime' => {
+ typ => 'integer',
+ msg => sprintf(gettext('Lifetime (0 .. %d)'),$console->{USER}->{MaxLifeTime} ? $console->{USER}->{MaxLifeTime} : 99 ),
+ def => (defined $epg->{Lifetime} ? $epg->{Lifetime} : $modT->{Lifetime}),
+ check => sub{
+ my $value = shift || 0;
+ if($value =~ /^\d+$/sig and $value >= 0 and $value < 100) {
+ if($console->{USER}->{MaxLifeTime} and $value > $console->{USER}->{MaxLifeTime}) {
+ return undef, sprintf(gettext('Sorry, but maximum lifetime is limited on %d!'), $console->{USER}->{MaxLifeTime});
+ }
+ return int($value);
+ } else {
+ return undef, gettext('No right Value!');
+ }
+ },
+ },
+ 'Dir' => {
+ typ => 'string',
+ msg => gettext('Group all recordings on a directory'),
+ def => $epg->{Dir},
+ # choices => main::getModule('TIMERS')->getRootDirs,
+ },
+ ];
+
+ # Ask Questions
+ $data = $console->question(($timerid ? gettext('Edit autotimer')
+ : gettext('Create a new autotimer')), $questions, $data);
+
+ if(ref $data eq 'HASH') {
+ delete $data->{Channel};
+
+ # Last chance ;)
+ return $console->err(gettext('Nothing to search defined!'))
+ unless($data->{Search});
+
+ $obj->_insert($data);
+
+ $data->{Id} = $obj->{dbh}->selectrow_arrayref('SELECT max(ID) FROM AUTOTIMER')->[0]
+ if(not $data->{Id});
+
+ $console->message(gettext('Autotimer saved!'));
+ debug sprintf('%s autotimer with search "%s" is saved%s',
+ ($timerid ? 'Changed' : 'New'),
+ $data->{Search},
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ );
+ $obj->autotimer($watcher, $console, $data->{Id});
+
+ $console->link({
+ text => gettext("Back to referred side"),
+ url => $console->{browser}->{Referer},
+ }) if($console->typ eq 'HTML');
+
+ }
+ return 1;
+}
+
+# ------------------
+# Name: autotimerDelete
+# Descr: Routine to display the delete form for Autotimer.
+# Usage: $obj->autotimerDelete($watcher, $console, $atid);
+# ------------------
+sub autotimerDelete {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $timerid = shift || return $console->err(gettext("No ID for autotimer to delete! Please use adelete 'aid'")); # If timerid the edittimer
my @timers = reverse sort{ $a <=> $b } split(/[^0-9]/, $timerid);
@@ -892,25 +892,25 @@ sub autotimerDelete {
return 0;
}
- $console->message(sprintf gettext("Autotimer %s is deleted."), join(',', @timers));
- debug sprintf('autotimer with id "%s" is deleted%s',
- join(',', @timers),
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
- );
- $console->redirect({url => $console->{browser}->{Referer}, wait => 1})
- if($console->typ eq 'HTML');
-}
-
-# ------------------
-# Name: autotimerToogle
-# Descr: Switch the Autotimer on or off.
-# Usage: $obj->autotimerToogle($watcher, $console, $atid);
-# ------------------
-sub autotimerToggle {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $timerid = shift || return $console->err(gettext("No ID for autotimer to toggle! Please use atoggle 'aid'"));
+ $console->message(sprintf gettext("Autotimer %s is deleted."), join(',', @timers));
+ debug sprintf('autotimer with id "%s" is deleted%s',
+ join(',', @timers),
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ );
+ $console->redirect({url => $console->{browser}->{Referer}, wait => 1})
+ if($console->typ eq 'HTML');
+}
+
+# ------------------
+# Name: autotimerToogle
+# Descr: Switch the Autotimer on or off.
+# Usage: $obj->autotimerToogle($watcher, $console, $atid);
+# ------------------
+sub autotimerToggle {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $timerid = shift || return $console->err(gettext("No ID for autotimer to toggle! Please use atoggle 'aid'"));
my @timers = reverse sort{ $a <=> $b } split(/[^0-9]/, $timerid);
@@ -941,23 +941,23 @@ sub autotimerToggle {
next;
}
- debug sprintf('autotimer with id "%s" is %s%s',
- $timer,
- ($status eq 'n' ? 'disabled' : 'activated'),
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
- );
-
+ debug sprintf('autotimer with id "%s" is %s%s',
+ $timer,
+ ($status eq 'n' ? 'disabled' : 'activated'),
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ );
+
if($console->typ ne 'AJAX') {
- my $text = ($status eq 'n') ? gettext('disabled')
- : gettext('activated');
+ my $text = ($status eq 'n') ? gettext('disabled')
+ : gettext('activated');
$console->message(sprintf gettext("Autotimer %s is %s."), $timer, $text);
- }
+ }
# AJAX
push(@$erg,[$timer,($status eq 'n' ? 0 : 1),0,0]);
}
- $console->redirect({url => $console->{browser}->{Referer}, wait => 2})
+ $console->redirect({url => $console->{browser}->{Referer}, wait => 2})
if($console->typ eq 'HTML');
if($console->typ eq 'AJAX') {
@@ -965,18 +965,18 @@ sub autotimerToggle {
# { "data" : [ [ 5, 1, 0, 0 ], .... ] }
$console->table($erg);
}
-
-}
-
-# ------------------
-# Name: list
-# Descr: List Autotimers in a table display.
-# Usage: $obj->list($watcher, $console, [$atid], [$params]);
-# ------------------
-sub list {
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
+
+}
+
+# ------------------
+# Name: list
+# Descr: List Autotimers in a table display.
+# Usage: $obj->list($watcher, $console, [$atid], [$params]);
+# ------------------
+sub list {
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
my $text = shift || '';
my $params = shift;
@@ -987,167 +987,167 @@ sub list {
} elsif($text) {
$where = 'WHERE '.buildsearch("Search,Dir",$text);
}
- }
-
- my %f = (
- 'Id' => umlaute(gettext('Service')),
- 'Act' => umlaute(gettext('Act')),
- 'Search' => umlaute(gettext('Search')),
- 'Channels' => umlaute(gettext('Channels')),
- 'Start' => umlaute(gettext('Start')),
- 'Stop' => umlaute(gettext('Stop')),
- 'Dir' => umlaute(gettext('Dir')),
- 'Min' => umlaute(gettext('Min')),
- );
-
- my $sql = qq|
- select
- Id as $f{'Id'},
- Activ as $f{'Act'},
- Search as $f{'Search'},
- Channels as $f{'Channels'},
- Dir as $f{'Dir'},
- Start as $f{'Start'},
- Stop as $f{'Stop'},
- MinLength as $f{'Min'}
- FROM
- AUTOTIMER
- $where
+ }
+
+ my %f = (
+ 'Id' => umlaute(gettext('Service')),
+ 'Act' => umlaute(gettext('Act')),
+ 'Search' => umlaute(gettext('Search')),
+ 'Channels' => umlaute(gettext('Channels')),
+ 'Start' => umlaute(gettext('Start')),
+ 'Stop' => umlaute(gettext('Stop')),
+ 'Dir' => umlaute(gettext('Dir')),
+ 'Min' => umlaute(gettext('Min')),
+ );
+
+ my $sql = qq|
+ select
+ Id as $f{'Id'},
+ Activ as $f{'Act'},
+ Search as $f{'Search'},
+ Channels as $f{'Channels'},
+ Dir as $f{'Dir'},
+ Start as $f{'Start'},
+ Stop as $f{'Stop'},
+ MinLength as $f{'Min'}
+ FROM
+ AUTOTIMER
+ $where
|;
- my $fields = fields($obj->{dbh}, $sql);
-
- my $sortby = gettext("Search");
- $sortby = $params->{sortby}
- if(exists $params->{sortby} && grep(/^$params->{sortby}$/i,@{$fields}));
- $sql .= " order by $sortby";
- if(exists $params->{desc} && $params->{desc} == 1) {
- $sql .= " desc"; }
- else {
- $sql .= " asc"; }
-
- my $erg = $obj->{dbh}->selectall_arrayref($sql);
- unshift(@$erg, $fields);
-
- my $channels = main::getModule('CHANNELS')->ChannelHash('Id');
- my $timers = main::getModule('TIMERS')->getTimersByAutotimer();
-
- $console->table($erg,
- {
- sortable => 1,
- channels => $channels,
- timers => $timers,
- }
- );
-}
-
-
-# ------------------
-sub _eventsearch {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $a = shift || return error ('No Data from Autotimer!' );
- my $timermod = shift || main::getModule('TIMERS') || return error ("Can't access modul TIMERS!");
-
- # Searchstrings to Paragraphs Changed
- $a->{Search} =~ s/\:/\:\.\*/
- if($a->{InFields} =~ /description/);
-
- my $search = buildsearch($a->{InFields}, $a->{Search});
-
- # Start and Stop
- if($a->{Start} and $a->{Stop}) {
- if($a->{Start} > $a->{Stop}) {
- $search .= "\n AND ((DATE_FORMAT(e.starttime, '%H%i') > $a->{Start} AND DATE_FORMAT(e.starttime, '%H%i') < 2359) OR (DATE_FORMAT(e.starttime, '%H%i') >= 0 and DATE_FORMAT(e.starttime, '%H%i') < $a->{Stop}))";
- } else {
- $search .= "\n AND (DATE_FORMAT(e.starttime, '%H%i') > $a->{Start} AND DATE_FORMAT(e.starttime, '%H%i') < $a->{Stop})";
- }
- }
-
- # Min Length
- if(exists $a->{MinLength} and $a->{MinLength}) {
- $search .= sprintf(" AND e.duration >= %d ", $a->{MinLength} * 60);
- }
-
- # Channels
- if($a->{Channels} and my @channelids = split(',', $a->{Channels})) {
- @channelids = map {$_ = "'$_'"} @channelids;
- $search = sprintf(' %s AND channel_id in (%s)', $search, join(',', @channelids));
- }
-
- # Weekdays
+ my $fields = fields($obj->{dbh}, $sql);
+
+ my $sortby = gettext("Search");
+ $sortby = $params->{sortby}
+ if(exists $params->{sortby} && grep(/^$params->{sortby}$/i,@{$fields}));
+ $sql .= " order by $sortby";
+ if(exists $params->{desc} && $params->{desc} == 1) {
+ $sql .= " desc"; }
+ else {
+ $sql .= " asc"; }
+
+ my $erg = $obj->{dbh}->selectall_arrayref($sql);
+ unshift(@$erg, $fields);
+
+ my $channels = main::getModule('CHANNELS')->ChannelHash('Id');
+ my $timers = main::getModule('TIMERS')->getTimersByAutotimer();
+
+ $console->table($erg,
+ {
+ sortable => 1,
+ channels => $channels,
+ timers => $timers,
+ }
+ );
+}
+
+
+# ------------------
+sub _eventsearch {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $a = shift || return error ('No Data from Autotimer!' );
+ my $timermod = shift || main::getModule('TIMERS') || return error ("Can't access modul TIMERS!");
+
+ # Searchstrings to Paragraphs Changed
+ $a->{Search} =~ s/\:/\:\.\*/
+ if($a->{InFields} =~ /description/);
+
+ my $search = buildsearch($a->{InFields}, $a->{Search});
+
+ # Start and Stop
+ if($a->{Start} and $a->{Stop}) {
+ if($a->{Start} > $a->{Stop}) {
+ $search .= "\n AND ((DATE_FORMAT(e.starttime, '%H%i') > $a->{Start} AND DATE_FORMAT(e.starttime, '%H%i') < 2359) OR (DATE_FORMAT(e.starttime, '%H%i') >= 0 and DATE_FORMAT(e.starttime, '%H%i') < $a->{Stop}))";
+ } else {
+ $search .= "\n AND (DATE_FORMAT(e.starttime, '%H%i') > $a->{Start} AND DATE_FORMAT(e.starttime, '%H%i') < $a->{Stop})";
+ }
+ }
+
+ # Min Length
+ if(exists $a->{MinLength} and $a->{MinLength}) {
+ $search .= sprintf(" AND e.duration >= %d ", $a->{MinLength} * 60);
+ }
+
+ # Channels
+ if($a->{Channels} and my @channelids = split(',', $a->{Channels})) {
+ @channelids = map {$_ = "'$_'"} @channelids;
+ $search = sprintf(' %s AND channel_id in (%s)', $search, join(',', @channelids));
+ }
+
+ # Weekdays
if($a->{Weekdays} and my @weekdays = split(',', $a->{Weekdays})) {
- if(scalar @weekdays != 7 and scalar @weekdays != 0) {
- @weekdays = map {$_ = "'$_'"} @weekdays;
+ if(scalar @weekdays != 7 and scalar @weekdays != 0) {
+ @weekdays = map {$_ = "'$_'"} @weekdays;
$search = sprintf(' %s AND DATE_FORMAT(e.starttime, \'%%a\') in (%s)', $search, join(',', @weekdays));
- }
- }
-
- # Exclude channels, ifn't already lookup for channels
- if($obj->{exclude} && not $a->{Channels}) {
- $search = sprintf(' %s AND NOT (c.%s)', $search, $obj->{exclude});
- }
-
- # Custom time range
- my $after = 0;
- my $prev = 0;
-# if($a->{VPS} ne 'y') {
- if(defined $a->{prevminutes}) {
- $prev = $a->{prevminutes} * 60;
- } else {
- $prev = $timermod->{prevminutes} * 60;
- }
- if(defined $a->{afterminutes}) {
- $after = $a->{afterminutes} * 60;
- } else {
- $after = $timermod->{afterminutes} * 60;
- }
-# }
-
- # Search for events
- my $sql = qq|
-SELECT
- e.eventid as eventid,
- e.channel_id as ChannelID,
- c.Name as Channel,
- c.POS as POS,
- e.title as Title,
- e.subtitle as Subtitle,
- e.description as Summary,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) - $prev ), '%d') as Day,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) - $prev ), '%H%i') as Start,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration + $after ), '%H%i') as Stop,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.vpstime)), '%H%i') as VpsStart,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.vpstime) + e.duration), '%H%i') as VpsStop
-FROM
- EPG as e,
- CHANNELS as c
-WHERE
- ( $search )
- AND ( e.channel_id = c.Id )|;
-
-#dumper $sql;
- my $data = $obj->{dbh}->selectall_hashref($sql, 'eventid');
-
- return $data;
-}
-
-# ------------------
-sub _timerexists {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $eventdata = shift || return error ('No Data from Autotimer!' );
- my ($nexttime, $aidcomment) = @_;
-
- # Avoid Timer already defined (the timer with the same data again do not put on)
- my $sql = "select count(*) as cc from TIMERS where
- ChannelID = ?
- and UNIX_TIMESTAMP(NextStartTime) = ?
- and UNIX_TIMESTAMP(NextStopTime) = ?
- and Priority = ?
- and Lifetime = ?
+ }
+ }
+
+ # Exclude channels, ifn't already lookup for channels
+ if($obj->{exclude} && not $a->{Channels}) {
+ $search = sprintf(' %s AND NOT (c.%s)', $search, $obj->{exclude});
+ }
+
+ # Custom time range
+ my $after = 0;
+ my $prev = 0;
+# if($a->{VPS} ne 'y') {
+ if(defined $a->{prevminutes}) {
+ $prev = $a->{prevminutes} * 60;
+ } else {
+ $prev = $timermod->{prevminutes} * 60;
+ }
+ if(defined $a->{afterminutes}) {
+ $after = $a->{afterminutes} * 60;
+ } else {
+ $after = $timermod->{afterminutes} * 60;
+ }
+# }
+
+ # Search for events
+ my $sql = qq|
+SELECT
+ e.eventid as eventid,
+ e.channel_id as ChannelID,
+ c.Name as Channel,
+ c.POS as POS,
+ e.title as Title,
+ e.subtitle as Subtitle,
+ e.description as Summary,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) - $prev ), '%d') as Day,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) - $prev ), '%H%i') as Start,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration + $after ), '%H%i') as Stop,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.vpstime)), '%H%i') as VpsStart,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.vpstime) + e.duration), '%H%i') as VpsStop
+FROM
+ EPG as e,
+ CHANNELS as c
+WHERE
+ ( $search )
+ AND ( e.channel_id = c.Id )|;
+
+#dumper $sql;
+ my $data = $obj->{dbh}->selectall_hashref($sql, 'eventid');
+
+ return $data;
+}
+
+# ------------------
+sub _timerexists {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $eventdata = shift || return error ('No Data from Autotimer!' );
+ my ($nexttime, $aidcomment) = @_;
+
+ # Avoid Timer already defined (the timer with the same data again do not put on)
+ my $sql = "select count(*) as cc from TIMERS where
+ ChannelID = ?
+ and UNIX_TIMESTAMP(NextStartTime) = ?
+ and UNIX_TIMESTAMP(NextStopTime) = ?
+ and Priority = ?
+ and Lifetime = ?
and (
- ( Status & 1 = '0' )
+ ( Status & 1 = '0' )
or ( File = ? and Summary = ? )
or ( Summary not like ? )
)";
@@ -1156,204 +1156,204 @@ sub _timerexists {
$sth->execute($eventdata->{ChannelID},$nexttime->{start},$nexttime->{stop},
$eventdata->{Priority},$eventdata->{Lifetime},
$eventdata->{File},$eventdata->{Summary},"%".$aidcomment)
- or return error sprintf("Can't execute query: %s.",$sth->errstr);
+ or return error sprintf("Can't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg->{cc}
if($erg);
return 0;
-}
-
-# ------------------
-sub _timerexistsfuzzy {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $eventdata = shift || return error ('No Data from Autotimer!' );
- my ($nexttime, $aidcomment) = @_;
-
- # Adjust timers set by the autotimer
- my $timerID = 0;
- my $sql = "select ID from TIMERS where
- ChannelID = ?
- and UNIX_TIMESTAMP(NextStartTime) = ?
- and UNIX_TIMESTAMP(NextStopTime) = ?
- and Summary like ?
+}
+
+# ------------------
+sub _timerexistsfuzzy {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $eventdata = shift || return error ('No Data from Autotimer!' );
+ my ($nexttime, $aidcomment) = @_;
+
+ # Adjust timers set by the autotimer
+ my $timerID = 0;
+ my $sql = "select ID from TIMERS where
+ ChannelID = ?
+ and UNIX_TIMESTAMP(NextStartTime) = ?
+ and UNIX_TIMESTAMP(NextStopTime) = ?
+ and Summary like ?
order by length(Summary) desc;";
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventdata->{ChannelID},$nexttime->{start},$nexttime->{stop},
"%".$aidcomment)
- or return error sprintf("Can't execute query: %s.",$sth->errstr);
+ or return error sprintf("Can't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg->{ID}
if($erg);
return 0;
-}
-
-# ------------------
-sub _recordexists {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $eventdata = shift || return error ('No Data from Autotimer!' );
- my ($nexttime, $aidcomment) = @_;
-
- # Ignore timer if it already with same title recorded
- my $sql = "SELECT count(*) as cc
- FROM RECORDS as r, OLDEPG as e
- WHERE e.eventid = r.EventId
- AND CONCAT_WS('~',e.title,IF(e.subtitle<>'',e.subtitle,NULL)) = ?";
+}
+
+# ------------------
+sub _recordexists {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $eventdata = shift || return error ('No Data from Autotimer!' );
+ my ($nexttime, $aidcomment) = @_;
+
+ # Ignore timer if it already with same title recorded
+ my $sql = "SELECT count(*) as cc
+ FROM RECORDS as r, OLDEPG as e
+ WHERE e.eventid = r.EventId
+ AND CONCAT_WS('~',e.title,IF(e.subtitle<>'',e.subtitle,NULL)) = ?";
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventdata->{File})
- or return error sprintf("Can't execute query: %s.",$sth->errstr);
+ or return error sprintf("Can't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg->{cc}
if($erg);
return 0;
-}
+}
-# ------------------
-sub _chronicleexists {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $eventdata = shift || return error ('No Data from Autotimer!' );
- my ($nexttime, $aidcomment) = @_;
+# ------------------
+sub _chronicleexists {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $eventdata = shift || return error ('No Data from Autotimer!' );
+ my ($nexttime, $aidcomment) = @_;
- my $chroniclemod = main::getModule('CHRONICLE') || return error ("Can't access modul CHRONICLE!");
+ my $chroniclemod = main::getModule('CHRONICLE') || return error ("Can't access modul CHRONICLE!");
return 0
if(not $chroniclemod or $chroniclemod->{active} ne 'y');
-
- my $sql = "select count(*) as cc from CHRONICLE where title = ?";
+
+ my $sql = "select count(*) as cc from CHRONICLE where title = ?";
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventdata->{File})
- or return error sprintf("Can't execute query: %s.",$sth->errstr);
+ or return error sprintf("Can't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg->{cc}
if($erg);
return 0;
}
-
-# ------------------
-sub _timerexiststitle {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $eventdata = shift || return error ('No Data from Autotimer!' );
- my ($nexttime, $aidcomment) = @_;
-
- my $sql = "select count(*) as cc from TIMERS where File = ?";
+
+# ------------------
+sub _timerexiststitle {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $eventdata = shift || return error ('No Data from Autotimer!' );
+ my ($nexttime, $aidcomment) = @_;
+
+ my $sql = "select count(*) as cc from TIMERS where File = ?";
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventdata->{File})
- or return error sprintf("Can't execute query: %s.",$sth->errstr);
+ or return error sprintf("Can't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg->{cc}
if($erg);
return 0;
-}
-
-
-# ------------------
-sub _insert {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $data = shift || return;
-
- if(ref $data eq 'HASH') {
- my ($names, $vals, $kenn);
- map {
- push(@$names, $_);
- push(@$vals, $data->{$_}),
- push(@$kenn, '?'),
- } sort keys %$data;
-
- my $sql = sprintf("REPLACE INTO AUTOTIMER (%s) VALUES (%s)",
- join(', ', @$names),
- join(', ', @$kenn),
- );
- my $sth = $obj->{dbh}->prepare( $sql );
- $sth->execute( @$vals );
- } else {
- my $sth = $obj->{dbh}->prepare('REPLACE INTO AUTOTIMER VALUES (?,?,?,?,?,?,?,?,?)');
- $sth->execute( @$data );
- }
-}
-
-# ------------------
-# Name: _placeholder
-# Descr: Replace the placeholder with extendet EPG
-# Usage: my $text = $obj->_placeholder($epgdata, $autotimerdata);
-# ------------------
-sub _placeholder {
- my $obj = shift || return error ('No Object!' );
- my $data = shift || return error ('No Data!' );
- my $at = shift || return error ('No AtData!' );
-
- my $file;
-
- if ($at->{Dir}) {
- my $title = $at->{Dir};
- if($title =~ /.*%.*%.*/sig) {
- my %at_details;
- $at_details{'title'} = $data->{Title};
- $at_details{'subtitle'} = $data->{Subtitle} ? $data->{Subtitle} : $data->{Start};
- $at_details{'date'} = $data->{Day};
- $at_details{'regie'} = $1 if $data->{Summary} =~ m/\|Director: (.*?)\|/;
- $at_details{'category'} = $1 if $data->{Summary} =~ m/\|Category: (.*?)\|/;
- $at_details{'genre'} = $1 if $data->{Summary} =~ m/\|Genre: (.*?)\|/;
- $at_details{'year'} = $1 if $data->{Summary} =~ m/\|Year: (.*?)\|/;
- $at_details{'country'} = $1 if $data->{Summary} =~ m/\|Country: (.*?)\|/;
- $at_details{'originaltitle'} = $1 if $data->{Summary} =~ m/\|Originaltitle: (.*?)\|/;
- $at_details{'fsk'} = $1 if $data->{Summary} =~ m/\|FSK: (.*?)\|/;
- $at_details{'episode'} = $1 if $data->{Summary} =~ m/\|Episode: (.*?)\|/;
- $at_details{'rating'} = $1 if $data->{Summary} =~ m/\|Rating: (.*?)\|/;
- $title =~ s/%([\w_-]+)%/$at_details{lc($1)}/sieg;
- $file = $title;
- } else { # Classic mode DIR~TITLE~SUBTILE
- $file = sprintf('%s~%s~%s', $at->{Dir}, $data->{Title},$data->{Subtitle});
- }
- } elsif($data->{Subtitle}) {
+}
+
+
+# ------------------
+sub _insert {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $data = shift || return;
+
+ if(ref $data eq 'HASH') {
+ my ($names, $vals, $kenn);
+ map {
+ push(@$names, $_);
+ push(@$vals, $data->{$_}),
+ push(@$kenn, '?'),
+ } sort keys %$data;
+
+ my $sql = sprintf("REPLACE INTO AUTOTIMER (%s) VALUES (%s)",
+ join(', ', @$names),
+ join(', ', @$kenn),
+ );
+ my $sth = $obj->{dbh}->prepare( $sql );
+ $sth->execute( @$vals );
+ } else {
+ my $sth = $obj->{dbh}->prepare('REPLACE INTO AUTOTIMER VALUES (?,?,?,?,?,?,?,?,?)');
+ $sth->execute( @$data );
+ }
+}
+
+# ------------------
+# Name: _placeholder
+# Descr: Replace the placeholder with extendet EPG
+# Usage: my $text = $obj->_placeholder($epgdata, $autotimerdata);
+# ------------------
+sub _placeholder {
+ my $obj = shift || return error ('No Object!' );
+ my $data = shift || return error ('No Data!' );
+ my $at = shift || return error ('No AtData!' );
+
+ my $file;
+
+ if ($at->{Dir}) {
+ my $title = $at->{Dir};
+ if($title =~ /.*%.*%.*/sig) {
+ my %at_details;
+ $at_details{'title'} = $data->{Title};
+ $at_details{'subtitle'} = $data->{Subtitle} ? $data->{Subtitle} : $data->{Start};
+ $at_details{'date'} = $data->{Day};
+ $at_details{'regie'} = $1 if $data->{Summary} =~ m/\|Director: (.*?)\|/;
+ $at_details{'category'} = $1 if $data->{Summary} =~ m/\|Category: (.*?)\|/;
+ $at_details{'genre'} = $1 if $data->{Summary} =~ m/\|Genre: (.*?)\|/;
+ $at_details{'year'} = $1 if $data->{Summary} =~ m/\|Year: (.*?)\|/;
+ $at_details{'country'} = $1 if $data->{Summary} =~ m/\|Country: (.*?)\|/;
+ $at_details{'originaltitle'} = $1 if $data->{Summary} =~ m/\|Originaltitle: (.*?)\|/;
+ $at_details{'fsk'} = $1 if $data->{Summary} =~ m/\|FSK: (.*?)\|/;
+ $at_details{'episode'} = $1 if $data->{Summary} =~ m/\|Episode: (.*?)\|/;
+ $at_details{'rating'} = $1 if $data->{Summary} =~ m/\|Rating: (.*?)\|/;
+ $title =~ s/%([\w_-]+)%/$at_details{lc($1)}/sieg;
+ $file = $title;
+ } else { # Classic mode DIR~TITLE~SUBTILE
+ $file = sprintf('%s~%s~%s', $at->{Dir}, $data->{Title},$data->{Subtitle});
+ }
+ } elsif($data->{Subtitle}) {
$file = sprintf('%s~%s', $data->{Title},$data->{Subtitle});
- } else {
- $file = $data->{Title};
- }
-
- # sind irgendweche Tags verwendet worden, die leer waren und die doppelte Verzeichnisse erzeugten?
- $file =~s#~+#~#g;
- $file =~s#^~##g;
- $file =~s#~$##g;
-
- return $file;
-}
-
-# ------------------
-sub suggest { # ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
+ } else {
+ $file = $data->{Title};
+ }
+
+ # sind irgendweche Tags verwendet worden, die leer waren und die doppelte Verzeichnisse erzeugten?
+ $file =~s#~+#~#g;
+ $file =~s#^~##g;
+ $file =~s#~$##g;
+
+ return $file;
+}
+
+# ------------------
+sub suggest {# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
my $search = shift;
my $params = shift;
if($search) {
my $sql = qq|
- SELECT
- Search
+ SELECT
+ Search
FROM
AUTOTIMER
WHERE
- ( Search LIKE ? )
+ ( Search LIKE ? )
GROUP BY
Search
ORDER BY
Search
LIMIT 25
- |;
+ |;
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute('%'.$search.'%')
or return error "Can't execute query: $sth->errstr.";
- my $result = $sth->fetchall_arrayref();
- $console->table($result)
+ my $result = $sth->fetchall_arrayref();
+ $console->table($result)
if(ref $console && $result);
}
}
-
-1;
+
+1;
diff --git a/lib/XXV/MODULES/CHANNELS.pm b/lib/XXV/MODULES/CHANNELS.pm
index c90b5e3..02bad7f 100644
--- a/lib/XXV/MODULES/CHANNELS.pm
+++ b/lib/XXV/MODULES/CHANNELS.pm
@@ -858,7 +858,7 @@ sub editChannel {
debug sprintf('%s channel with name "%s" is saved%s',
($cid ? 'Changed' : 'New'),
$data->{Name},
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
);
$console->message($erg);
} else {
@@ -954,7 +954,7 @@ sub deleteChannel {
debug sprintf('Channel with name "%s" is deleted%s',
$data->{$pos}->{Name},
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
);
$self->{svdrp}->queue_cmds("delc $pos"); # Sammeln der Kommandos
diff --git a/lib/XXV/MODULES/CHRONICLE.pm b/lib/XXV/MODULES/CHRONICLE.pm
index e54c4b2..81ac5ad 100644
--- a/lib/XXV/MODULES/CHRONICLE.pm
+++ b/lib/XXV/MODULES/CHRONICLE.pm
@@ -12,19 +12,19 @@ sub module {
my $args = {
Name => 'CHRONICLE',
- Prereq => {
- # 'Perl::Module' => 'Description',
+ Prereq => {
+ # 'Perl::Module' => 'Description',
},
Description => gettext('This module store recordings at chronicle.'),
Version => '0.95',
Date => '2007-08-14',
- Author => 'Andreas Brachold <vdr07 at deltab.de>',
+ Author => 'Andreas Brachold <vdr07 at deltab.de>',
Preferences => {
- active => {
- description => gettext('Activate this service'),
- default => 'y',
- type => 'confirm',
- required => gettext('This is required!'),
+ active => {
+ description => gettext('Activate this service'),
+ default => 'y',
+ type => 'confirm',
+ required => gettext('This is required!'),
},
},
Commands => {
@@ -102,10 +102,10 @@ sub _init {
$self->{dbh}->do(qq|
CREATE TABLE IF NOT EXISTS CHRONICLE (
id int unsigned auto_increment not NULL,
- hash varchar(16) NOT NULL default '',
- title text NOT NULL default '',
- channel_id varchar(100) NOT NULL default '',
- starttime datetime NOT NULL default '0000-00-00 00:00:00',
+ hash varchar(16) NOT NULL default '',
+ title text NOT NULL default '',
+ channel_id varchar(100) NOT NULL default '',
+ starttime datetime NOT NULL default '0000-00-00 00:00:00',
duration int NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY (hash)
@@ -117,7 +117,7 @@ sub _init {
$m->updated(sub{
return 0 if($self->{active} ne 'y');
- lg 'Start chronicle callback to store recordings!';
+ lg 'Start chronicle callback to store recordings!';
return $self->_insertData();
});
@@ -132,7 +132,7 @@ sub _insertData {
# ------------------
my $self = shift || return error ('No Object!' );
- my $sql = qq|
+ my $sql = qq|
INSERT IGNORE INTO CHRONICLE
SELECT
0, PASSWORD(CONCAT(e.channel_id,e.starttime,title)),
@@ -143,7 +143,7 @@ INSERT IGNORE INTO CHRONICLE
FROM OLDEPG as e,RECORDS as r
WHERE r.eventid = e.eventid
|;
- $self->{dbh}->do($sql);
+ $self->{dbh}->do($sql);
return 1;
}
@@ -155,17 +155,17 @@ sub list {
my $watcher = shift || return error ('No Watcher!');
my $console = shift || return error ('No Console');
- my %f = (
- 'id' => umlaute(gettext('Service')),
- 'title' => umlaute(gettext('Title')),
- 'subtitle' => umlaute(gettext('Subtitle')),
- 'channel' => umlaute(gettext('Channel')),
- 'day' => umlaute(gettext('Day')),
- 'start' => umlaute(gettext('Start')),
- 'stop' => umlaute(gettext('Stop'))
+ my %f = (
+ 'id' => umlaute(gettext('Service')),
+ 'title' => umlaute(gettext('Title')),
+ 'subtitle' => umlaute(gettext('Subtitle')),
+ 'channel' => umlaute(gettext('Channel')),
+ 'day' => umlaute(gettext('Day')),
+ 'start' => umlaute(gettext('Start')),
+ 'stop' => umlaute(gettext('Stop'))
);
- my $sql = qq|
+ my $sql = qq|
SELECT
CHRONICLE.id as $f{'id'},
CHRONICLE.title as $f{'title'},
@@ -177,7 +177,7 @@ FROM CHRONICLE
ORDER BY CHRONICLE.starttime
|;
my $fields = fields($self->{dbh}, $sql);
- my $erg = $self->{dbh}->selectall_arrayref($sql);
+ my $erg = $self->{dbh}->selectall_arrayref($sql);
unshift(@$erg, $fields);
$console->table($erg);
@@ -195,17 +195,17 @@ sub search {
$quest =~ s/\'/\./sg;
$quest =~ s/\+/\\\\\+/sg;
- my %f = (
- 'id' => umlaute(gettext('Service')),
- 'title' => umlaute(gettext('Title')),
- 'subtitle' => umlaute(gettext('Subtitle')),
- 'channel' => umlaute(gettext('Channel')),
- 'day' => umlaute(gettext('Day')),
- 'start' => umlaute(gettext('Start')),
- 'stop' => umlaute(gettext('Stop'))
+ my %f = (
+ 'id' => umlaute(gettext('Service')),
+ 'title' => umlaute(gettext('Title')),
+ 'subtitle' => umlaute(gettext('Subtitle')),
+ 'channel' => umlaute(gettext('Channel')),
+ 'day' => umlaute(gettext('Day')),
+ 'start' => umlaute(gettext('Start')),
+ 'stop' => umlaute(gettext('Stop'))
);
- my $sql = qq|
+ my $sql = qq|
SELECT
CHRONICLE.id as $f{'id'},
CHRONICLE.title as $f{'title'},
diff --git a/lib/XXV/MODULES/EPG.pm b/lib/XXV/MODULES/EPG.pm
index 70cda39..a796f4c 100644
--- a/lib/XXV/MODULES/EPG.pm
+++ b/lib/XXV/MODULES/EPG.pm
@@ -1,133 +1,133 @@
-package XXV::MODULES::EPG;
-use strict;
-
-use Tools;
-use File::Basename;
-use Locale::gettext;
-
-
-# This module method must exist for XXV
-# ------------------
-sub module {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $args = {
- Name => 'EPG',
- Prereq => {
- 'Date::Manip' => 'date manipulation routines',
- 'Time::Local' => 'efficiently compute time from local and GMT time ',
- },
- Description => gettext('This module reads new EPG Data and stores them in the database.'),
+package XXV::MODULES::EPG;
+use strict;
+
+use Tools;
+use File::Basename;
+use Locale::gettext;
+
+
+# This module method must exist for XXV
+# ------------------
+sub module {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $args = {
+ Name => 'EPG',
+ Prereq => {
+ 'Date::Manip' => 'date manipulation routines',
+ 'Time::Local' => 'efficiently compute time from local and GMT time ',
+ },
+ Description => gettext('This module reads new EPG Data and stores them in the database.'),
Version => '0.95',
Date => '2007-08-14',
- Author => 'xpix',
- Status => sub{ $obj->status(@_) },
- Preferences => {
- epgimages => {
- description => gettext('Location of additional EPG images.'),
- default => '/var/cache/vdr/epgimages',
- type => 'dir',
- },
- interval => {
- description => gettext('How often EPG data are to be analyzed (in seconds)'),
- default => 60 * 60,
- type => 'integer',
- required => gettext('This is required!'),
- },
- periods => {
- description => gettext("Pre-defined list for the 'Running Now' view (comma separated list)"),
- default => '12:00,18:00,20:15,22:00',
- type => 'string',
- required => gettext('This is required!'),
- },
- timeframe => {
- description => gettext("How much hours to display in schema"),
- default => 2,
- type => 'integer',
- required => gettext('This is required!'),
- },
- },
- Commands => {
- search => {
- description => gettext('Search in EPG Data'),
- short => 's',
- callback => sub{ $obj->search(@_) },
- },
- program => {
- description => gettext("List program for channel 'channel name'"),
- short => 'p',
- callback => sub{ $obj->program(@_) },
- },
- display => {
- description => gettext("Show program event 'eventid'"),
- short => 'd',
- callback => sub{ $obj->display(@_) },
- },
- now => {
- description => gettext('Display events is running now'),
- short => 'n',
- callback => sub{ $obj->runningNow(@_) },
- },
- next => {
- description => gettext('Display events is running next'),
- short => 'nx',
- callback => sub{ $obj->runningNext(@_) },
- },
- schema => {
- description => gettext('Display events in a schematic way'),
- short => 'sch',
- callback => sub{ $obj->schema(@_) },
- },
- erestart => {
- description => gettext('Reload EPG data'),
- short => 'er',
- callback => sub{
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
-
- debug sprintf('Start reload EPG data%s',
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
- );
-
- $obj->startReadEpgData($watcher,$console);
- },
- Level => 'admin',
- },
- erun => {
- description => gettext('Display the epg event running in vdr'),
- short => 'en',
- callback => sub{ $obj->NowOnChannel(@_) },
+ Author => 'xpix',
+ Status => sub{ $obj->status(@_) },
+ Preferences => {
+ epgimages => {
+ description => gettext('Location of additional EPG images.'),
+ default => '/var/cache/vdr/epgimages',
+ type => 'dir',
+ },
+ interval => {
+ description => gettext('How often EPG data are to be analyzed (in seconds)'),
+ default => 60 * 60,
+ type => 'integer',
+ required => gettext('This is required!'),
+ },
+ periods => {
+ description => gettext("Pre-defined list for the 'Running Now' view (comma separated list)"),
+ default => '12:00,18:00,20:15,22:00',
+ type => 'string',
+ required => gettext('This is required!'),
+ },
+ timeframe => {
+ description => gettext("How much hours to display in schema"),
+ default => 2,
+ type => 'integer',
+ required => gettext('This is required!'),
+ },
+ },
+ Commands => {
+ search => {
+ description => gettext('Search in EPG Data'),
+ short => 's',
+ callback => sub{ $obj->search(@_) },
+ },
+ program => {
+ description => gettext("List program for channel 'channel name'"),
+ short => 'p',
+ callback => sub{ $obj->program(@_) },
+ },
+ display => {
+ description => gettext("Show program event 'eventid'"),
+ short => 'd',
+ callback => sub{ $obj->display(@_) },
+ },
+ now => {
+ description => gettext('Display events is running now'),
+ short => 'n',
+ callback => sub{ $obj->runningNow(@_) },
+ },
+ next => {
+ description => gettext('Display events is running next'),
+ short => 'nx',
+ callback => sub{ $obj->runningNext(@_) },
+ },
+ schema => {
+ description => gettext('Display events in a schematic way'),
+ short => 'sch',
+ callback => sub{ $obj->schema(@_) },
+ },
+ erestart => {
+ description => gettext('Reload EPG data'),
+ short => 'er',
+ callback => sub{
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+
+ debug sprintf('Start reload EPG data%s',
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ );
+
+ $obj->startReadEpgData($watcher,$console);
+ },
+ Level => 'admin',
+ },
+ erun => {
+ description => gettext('Display the epg event running in vdr'),
+ short => 'en',
+ callback => sub{ $obj->NowOnChannel(@_) },
Level => 'user',
DenyClass => 'remote',
- },
- conflict => {
- hidden => 'yes',
- callback => sub{ $obj->checkOnTimer(@_) },
- },
- edescription => {
- hidden => 'yes',
- short => 'ed',
+ },
+ conflict => {
+ hidden => 'yes',
+ callback => sub{ $obj->checkOnTimer(@_) },
+ },
+ edescription => {
+ hidden => 'yes',
+ short => 'ed',
callback => sub { $obj->getDescription(@_) },
},
esuggest => {
- hidden => 'yes',
+ hidden => 'yes',
callback => sub{ $obj->suggest(@_) },
},
- },
- };
- return $args;
-}
-
-# ------------------
-sub status {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift;
- my $console = shift;
- my $lastReportTime = shift || 0;
+ },
+ };
+ return $args;
+}
+
+# ------------------
+sub status {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift;
+ my $console = shift;
+ my $lastReportTime = shift || 0;
my $total = 0;
- my $newEntrys = 0;
+ my $newEntrys = 0;
{
my $sth = $obj->{dbh}->prepare("select count(*) as count from EPG");
@@ -136,9 +136,9 @@ sub status {
error sprintf("Can't execute query: %s.",$sth->errstr);
} else {
my $erg = $sth->fetchrow_hashref();
- $total = $erg->{count} if($erg && $erg->{count});
+ $total = $erg->{count} if($erg && $erg->{count});
}
- }
+ }
{
my $sth = $obj->{dbh}->prepare("select count(*) as count from EPG where UNIX_TIMESTAMP(addtime) > ?");
@@ -147,91 +147,91 @@ sub status {
error sprintf("Can't execute query: %s.",$sth->errstr);
} else {
my $erg = $sth->fetchrow_hashref();
- $newEntrys = $erg->{count} if($erg && $erg->{count});
+ $newEntrys = $erg->{count} if($erg && $erg->{count});
}
}
-
- return {
- message => sprintf(gettext('EPG table contains %d entries and since the last login at %s %d new entries'),
- $total, scalar localtime($lastReportTime), $newEntrys),
- };
-}
-
-# ------------------
-sub new {
-# ------------------
- my($class, %attr) = @_;
- my $self = {};
- bless($self, $class);
-
- # paths
- $self->{paths} = delete $attr{'-paths'};
-
- # who am I
- $self->{MOD} = $self->module;
-
- # all configvalues to $self without parents (important for ConfigModule)
- map {
- $self->{$_} = $attr{'-config'}->{$self->{MOD}->{Name}}->{$_};
- $self->{$_} = $self->{MOD}->{Preferences}->{$_}->{default} unless($self->{$_});
- } keys %{$self->{MOD}->{Preferences}};
-
- # Try to use the Requirments
- map {
- eval "use $_";
- return panic("\nCan not load Module: $_\nPlease install this module on your System:\nperl -MCPAN -e 'install $_'") if($@);
- } keys %{$self->{MOD}->{Prereq}};
-
- # read the DB Handle
- $self->{dbh} = delete $attr{'-dbh'};
-
- # The Initprocess
- $self->_init or return error('Problem to initialize module');
-
- return $self;
-}
-
-# ------------------
-sub _init {
-# ------------------
- my $obj = shift || return error ('No Object!' );
-
- return 0, panic("Session to database is'nt connected")
- unless($obj->{dbh});
-
- # Look for table or create this table
- foreach my $table (qw/EPG OLDEPG/) {
+
+ return {
+ message => sprintf(gettext('EPG table contains %d entries and since the last login at %s %d new entries'),
+ $total, scalar localtime($lastReportTime), $newEntrys),
+ };
+}
+
+# ------------------
+sub new {
+# ------------------
+ my($class, %attr) = @_;
+ my $self = {};
+ bless($self, $class);
+
+ # paths
+ $self->{paths} = delete $attr{'-paths'};
+
+ # who am I
+ $self->{MOD} = $self->module;
+
+ # all configvalues to $self without parents (important for ConfigModule)
+ map {
+ $self->{$_} = $attr{'-config'}->{$self->{MOD}->{Name}}->{$_};
+ $self->{$_} = $self->{MOD}->{Preferences}->{$_}->{default} unless($self->{$_});
+ } keys %{$self->{MOD}->{Preferences}};
+
+ # Try to use the Requirments
+ map {
+ eval "use $_";
+ return panic("\nCan not load Module: $_\nPlease install this module on your System:\nperl -MCPAN -e 'install $_'") if($@);
+ } keys %{$self->{MOD}->{Prereq}};
+
+ # read the DB Handle
+ $self->{dbh} = delete $attr{'-dbh'};
+
+ # The Initprocess
+ $self->_init or return error('Problem to initialize module');
+
+ return $self;
+}
+
+# ------------------
+sub _init {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+
+ return 0, panic("Session to database is'nt connected")
+ unless($obj->{dbh});
+
+ # Look for table or create this table
+ foreach my $table (qw/EPG OLDEPG/) {
# remove old table, if updated rows
- tableUpdated($obj->{dbh},$table,14,1);
-
- my $version = main::getVersion;
- $obj->{dbh}->do(qq|
- CREATE TABLE IF NOT EXISTS $table (
- eventid bigint unsigned NOT NULL default '0',
- title text NOT NULL default '',
- subtitle text default '',
- description text,
- channel_id varchar(100) NOT NULL default '',
- starttime datetime NOT NULL default '0000-00-00 00:00:00',
- duration int(11) NOT NULL default '0',
- tableid tinyint(4) default 0,
- image text default '',
- version tinyint(3) default 0,
- video varchar(100) default '',
- audio varchar(255) default '',
- addtime datetime NOT NULL default '0000-00-00 00:00:00',
- vpstime datetime default '0000-00-00 00:00:00',
- PRIMARY KEY (eventid),
- INDEX (starttime),
- INDEX (channel_id)
- ) COMMENT = '$version'
- |);
- }
+ tableUpdated($obj->{dbh},$table,14,1);
+
+ my $version = main::getVersion;
+ $obj->{dbh}->do(qq|
+ CREATE TABLE IF NOT EXISTS $table (
+ eventid bigint unsigned NOT NULL default '0',
+ title text NOT NULL default '',
+ subtitle text default '',
+ description text,
+ channel_id varchar(100) NOT NULL default '',
+ starttime datetime NOT NULL default '0000-00-00 00:00:00',
+ duration int(11) NOT NULL default '0',
+ tableid tinyint(4) default 0,
+ image text default '',
+ version tinyint(3) default 0,
+ video varchar(100) default '',
+ audio varchar(255) default '',
+ addtime datetime NOT NULL default '0000-00-00 00:00:00',
+ vpstime datetime default '0000-00-00 00:00:00',
+ PRIMARY KEY (eventid),
+ INDEX (starttime),
+ INDEX (channel_id)
+ ) COMMENT = '$version'
+ |);
+ }
$obj->{after_updated} = [];
-
- # Repair later Data ...
+
+ # Repair later Data ...
main::after(sub{
$obj->{svdrp} = main::getModule('SVDRP');
unless($obj->{svdrp}) {
@@ -239,68 +239,68 @@ sub _init {
return 0;
}
- $obj->startReadEpgData();
-
- # Restart watcher every x hours
- Event->timer(
- interval => $obj->{interval},
- prio => 6, # -1 very hard ... 6 very low
- cb => sub{
- lg sprintf('The read on epg data is restarted!');
- $obj->startReadEpgData();
+ $obj->startReadEpgData();
+
+ # Restart watcher every x hours
+ Event->timer(
+ interval => $obj->{interval},
+ prio => 6, # -1 very hard ... 6 very low
+ cb => sub{
+ lg sprintf('The read on epg data is restarted!');
+ $obj->startReadEpgData();
},
- );
+ );
return 1;
- }, "EPG: Start read epg data and repair ...", 40);
-
- return 1;
-}
-
-# ------------------
-sub startReadEpgData {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift;
- my $console = shift;
-
- my $waiter;
- if(ref $console && $console->typ eq 'HTML') {
- $waiter = $console->wait(gettext("Read EPG data ..."),0,1000,'no');
- }
-
- # Read data over SVDRP
- my $vdata = $obj->{svdrp}->command('LSTE');
- map {
- $_ =~ s/^\d{3}.//;
- $_ =~ s/[\r|\n]$//;
- } @$vdata;
- debug sprintf('The read on epg data start now!');
-
-
- # Adjust waiter max value now.
- $waiter->max(scalar @$vdata)
- if(ref $console && ref $waiter);
-
- $obj->moveOldEPGEntrys();
-
- # Read file row by row
- my $updated = $obj->compareEpgData($vdata,$watcher,$console,$waiter);
-
- $obj->deleteDoubleEPGEntrys();
+ }, "EPG: Start read epg data and repair ...", 40);
+
+ return 1;
+}
+
+# ------------------
+sub startReadEpgData {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift;
+ my $console = shift;
+
+ my $waiter;
+ if(ref $console && $console->typ eq 'HTML') {
+ $waiter = $console->wait(gettext("Read EPG data ..."),0,1000,'no');
+ }
+
+ # Read data over SVDRP
+ my $vdata = $obj->{svdrp}->command('LSTE');
+ map {
+ $_ =~ s/^\d{3}.//;
+ $_ =~ s/[\r|\n]$//;
+ } @$vdata;
+ debug sprintf('The read on epg data start now!');
+
+
+ # Adjust waiter max value now.
+ $waiter->max(scalar @$vdata)
+ if(ref $console && ref $waiter);
+
+ $obj->moveOldEPGEntrys();
+
+ # Read file row by row
+ my $updated = $obj->compareEpgData($vdata,$watcher,$console,$waiter);
+
+ $obj->deleteDoubleEPGEntrys();
$obj->updated() if($updated);
-
- # last call of waiter
- $waiter->end() if(ref $waiter);
-
- if(ref $console) {
- $console->start() if(ref $waiter);
- $console->message(sprintf(gettext("%d events in database updated."), $updated));
-
- $console->redirect({url => $console->{browser}->{Referer}, wait => 2})
- if($console->typ eq 'HTML');
- }
-}
+
+ # last call of waiter
+ $waiter->end() if(ref $waiter);
+
+ if(ref $console) {
+ $console->start() if(ref $waiter);
+ $console->message(sprintf(gettext("%d events in database updated."), $updated));
+
+ $console->redirect({url => $console->{browser}->{Referer}, wait => 2})
+ if($console->typ eq 'HTML');
+ }
+}
# Routine um Callbacks zu registrieren und
# diese nach dem Aktualisieren der EPG Daten zu starten
@@ -322,73 +322,73 @@ sub updated {
if(ref $CB->[0] eq 'CODE');
}
}
-}
-# This Routine will compare data from epg.data
-# and EPG Database row by row
-# ------------------
-sub compareEpgData {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $vdata = shift || return error('No data');
- my $watcher = shift;
- my $console = shift;
- my $waiter = shift;
-
- my $changedData = 0;
- my $updatedData = 0;
- my $deleteData = 0;
-
- # Second - read data
- my $count = 0;
-
- my $vdrData;
- my $channel;
- my $channelname;
- while($count < scalar $vdata) {
- ($vdrData,$channel,$channelname,$count) = $obj->readEpgData($vdata,$count);
- last if(not $channel);
-
- $waiter->next($count,undef, sprintf(gettext("Analyze channel '%s'"), $channelname))
- if(ref $waiter);
-
- # First - read database
+}
+# This Routine will compare data from epg.data
+# and EPG Database row by row
+# ------------------
+sub compareEpgData {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $vdata = shift || return error('No data');
+ my $watcher = shift;
+ my $console = shift;
+ my $waiter = shift;
+
+ my $changedData = 0;
+ my $updatedData = 0;
+ my $deleteData = 0;
+
+ # Second - read data
+ my $count = 0;
+
+ my $vdrData;
+ my $channel;
+ my $channelname;
+ while($count < scalar $vdata) {
+ ($vdrData,$channel,$channelname,$count) = $obj->readEpgData($vdata,$count);
+ last if(not $channel);
+
+ $waiter->next($count,undef, sprintf(gettext("Analyze channel '%s'"), $channelname))
+ if(ref $waiter);
+
+ # First - read database
my $sql = qq|select eventid, title, subtitle, length(description) as ldescription, duration, UNIX_TIMESTAMP(starttime) as starttime, UNIX_TIMESTAMP(vpstime) as vpstime, video, audio from EPG where channel_id = ? |;
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($channel)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $db_data = $sth->fetchall_hashref('eventid');
-
- lg sprintf( 'Compare EPG Database with data from vdr : %d / %d for channel %s', scalar keys %$db_data,scalar keys %$vdrData, $channel);
- # Compare this Hashes
- foreach my $eid (keys %{$vdrData}) {
- my $row = $vdrData->{$eid};
-
- # Exists in DB .. update
- if(exists $db_data->{$eid}) {
- # Compare fields
- foreach my $field (qw/title subtitle ldescription duration starttime vpstime video audio/) {
- next if(not exists $row->{$field} or not $row->{$field});
- if((not exists $db_data->{$eid}->{$field})
- or (not $db_data->{$eid}->{$field})
- or ($db_data->{$eid}->{$field} ne $row->{$field})) {
- $obj->replace($eid, $row);
- $updatedData++;
- last;
- }
- }
-
- # delete updated rows from hash
+ my $db_data = $sth->fetchall_hashref('eventid');
+
+ lg sprintf( 'Compare EPG Database with data from vdr : %d / %d for channel %s', scalar keys %$db_data,scalar keys %$vdrData, $channel);
+ # Compare this Hashes
+ foreach my $eid (keys %{$vdrData}) {
+ my $row = $vdrData->{$eid};
+
+ # Exists in DB .. update
+ if(exists $db_data->{$eid}) {
+ # Compare fields
+ foreach my $field (qw/title subtitle ldescription duration starttime vpstime video audio/) {
+ next if(not exists $row->{$field} or not $row->{$field});
+ if((not exists $db_data->{$eid}->{$field})
+ or (not $db_data->{$eid}->{$field})
+ or ($db_data->{$eid}->{$field} ne $row->{$field})) {
+ $obj->replace($eid, $row);
+ $updatedData++;
+ last;
+ }
+ }
+
+ # delete updated rows from hash
delete $db_data->{$eid};
-
- } else {
- # Not exists in DB .. insert
- $obj->replace($eid, $row);
- $changedData++;
- }
- }
-
- # Delete unused EpgEntrys in DB
- $deleteData += scalar keys %$db_data;
+
+ } else {
+ # Not exists in DB .. insert
+ $obj->replace($eid, $row);
+ $changedData++;
+ }
+ }
+
+ # Delete unused EpgEntrys in DB
+ $deleteData += scalar keys %$db_data;
if(scalar keys %$db_data > 0) {
my $sth = $obj->{dbh}->prepare('DELETE FROM EPG WHERE eventid IN (?)');
foreach my $eventid (keys %$db_data) {
@@ -396,799 +396,799 @@ sub compareEpgData {
error sprintf("Can't execute query: %s.",$sth->errstr);
}
}
- }
- }
- debug 'Finish .. %d events created, %d events replaced, %d events deleted', $changedData, $updatedData, $deleteData;
-
- return ($changedData + $updatedData + $deleteData);
-}
-
-# ------------------
-sub moveOldEPGEntrys {
-# ------------------
- my $obj = shift || return error ('No Object!' );
-
- # Copy and delete old EPG Entrys
- $obj->{dbh}->do('REPLACE INTO OLDEPG SELECT * FROM EPG WHERE (UNIX_TIMESTAMP(EPG.starttime) + EPG.duration) < UNIX_TIMESTAMP()');
- $obj->{dbh}->do('DELETE FROM EPG WHERE (UNIX_TIMESTAMP(EPG.starttime) + EPG.duration) < UNIX_TIMESTAMP()');
-}
-
-# ------------------
-sub deleteDoubleEPGEntrys {
-# ------------------
- my $obj = shift || return error ('No Object!' );
-
- # Delete double EPG Entrys
- my $erg = $obj->{dbh}->selectall_arrayref('SELECT eventid FROM EPG GROUP BY starttime, channel_id having count(*) > 1');
+ }
+ }
+ debug 'Finish .. %d events created, %d events replaced, %d events deleted', $changedData, $updatedData, $deleteData;
+
+ return ($changedData + $updatedData + $deleteData);
+}
+
+# ------------------
+sub moveOldEPGEntrys {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+
+ # Copy and delete old EPG Entrys
+ $obj->{dbh}->do('REPLACE INTO OLDEPG SELECT * FROM EPG WHERE (UNIX_TIMESTAMP(EPG.starttime) + EPG.duration) < UNIX_TIMESTAMP()');
+ $obj->{dbh}->do('DELETE FROM EPG WHERE (UNIX_TIMESTAMP(EPG.starttime) + EPG.duration) < UNIX_TIMESTAMP()');
+}
+
+# ------------------
+sub deleteDoubleEPGEntrys {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+
+ # Delete double EPG Entrys
+ my $erg = $obj->{dbh}->selectall_arrayref('SELECT eventid FROM EPG GROUP BY starttime, channel_id having count(*) > 1');
if(scalar @$erg > 0) {
- lg sprintf('Repair data found %d wrong events!', scalar @$erg);
- my $sth = $obj->{dbh}->prepare('DELETE FROM EPG WHERE eventid = ?');
- foreach my $row (@$erg) {
- $sth->execute($row->[0]);
+ lg sprintf('Repair data found %d wrong events!', scalar @$erg);
+ my $sth = $obj->{dbh}->prepare('DELETE FROM EPG WHERE eventid = ?');
+ foreach my $row (@$erg) {
+ $sth->execute($row->[0]);
}
- }
-}
-
-# ------------------
-sub replace {
-# ------------------
- my $obj = shift || return error ('No Object!');
- my $eventid = shift || return error ('No eventid to insert!');;
- my $attr = shift || return error ('No data to insert!');
-
- my $sth = $obj->{dbh}->prepare('REPLACE INTO EPG(eventid, title, subtitle, description, channel_id, duration, tableid, image, version, video, audio, starttime, addtime, vpstime) VALUES (?,?,?,?,?,?,?,?,?,?,?,FROM_UNIXTIME(?),FROM_UNIXTIME(?),FROM_UNIXTIME(?))');
- $sth->execute(
- $eventid,
- $attr->{title},
- $attr->{subtitle},
- $attr->{description},
- $attr->{channel},
- $attr->{duration},
- $attr->{tableid},
- $attr->{image} || '',
- hex($attr->{version}),
- $attr->{video} || '1 01 deu 4:3',
- $attr->{audio} || "2 03 deu stereo",
- $attr->{starttime},
- time,
- $attr->{vpstime}
- ) if($attr->{channel});
-}
-
-# ------------------
-sub encodeEpgId {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $epgid = shift || return error('No EPG Id!');
- my $channel = shift || return error('No Channel!');
-
- # look for NID-TID-SID for unique eventids (SID 0-30000 / TID 0 - 1000 / NID 0 - 10000
- my @id = split('-', $channel);
-
- # Make a fix format 0xCCCCEEEE : C-Channelid (high-word), E-Eventid(low-word) => real-eventid = uniqueid & FFFF
- my $eventid = ((($id[-3] + $id[-2] + $id[-1]) & 0x3FFF) << 16) | ($epgid & 0xFFFF);
-
- return $eventid;
-}
-
-# ------------------
-sub readEpgData {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $vdata = shift || return error('Problem to read Data!');
- my $count = shift || 0;
- my $dataHash = {};
-
- my $cmod = main::getModule ('CHANNELS');
- my $channels = $cmod->ChannelArray ('Id,Name');
- my $channel;
- my $channelname;
- my $event;
-
- #debug 'Read %d lines in EPG Database from %d', scalar @$vdata,$offset;
- for(;$count < scalar (@$vdata);$count++) {
- my $line = @{$vdata}[$count];
-
- # Ok, Datarow complete...
- if($line eq 'e' and $event->{eventid} and $event->{channel}) {
- if(-e sprintf('%s/%d.png', $obj->{epgimages}, $event->{eventid})) {
- my $firstimage = sprintf('%d.png',$event->{eventid});
- $event->{image} = $firstimage."\n";
- my $imgpath = sprintf('%s/%d_?.png',$obj->{epgimages},$event->{eventid});
- foreach my $img (glob($imgpath)) {
- $event->{image} .= sprintf("%s.png\n", basename($img, '.png'));
- }
- }
-
- $channel = $event->{channel};
- my $eventid = $obj->encodeEpgId($event->{eventid}, $channel);
-
- $event->{title} = gettext("No Title")
- unless($event->{title});
- $event->{description} = ""
- unless($event->{description});
-
- %{$dataHash->{$eventid}} = %{$event};
-
- $event = undef;
- $event->{channel} = $channel;
- next;
- }
- elsif($line eq 'c') {
- # Finish this channel
- return ($dataHash,$channel,$channelname,$count+1)
- if(scalar keys %$dataHash);
-
- undef $event->{channel};
- undef $channel;
- undef $channelname;
- }
-
- my ($mark, $data) = $line =~ /^(\S)\s+(.+)/g;
- next unless($mark and $data);
-
- # Next channel
- if($mark eq 'C') {
- if($channel) {
- debug 'Missing channel endtag c at line %d',$count;
- return ($dataHash,$channel,$channelname,$count) if(scalar keys %$dataHash);
- }
- undef $event->{channel};
- my $channel = (split(/\s+/, $data))[0];
- # import only known channels
- foreach my $ch (@{$channels}) {
- if($ch->[0] eq $channel) {
- $event->{channel} = $channel;
- $channelname = $ch->[1];
- last;
- }
- }
- } elsif($mark eq 'E') {
- ($event->{eventid}, $event->{starttime}, $event->{duration}, $event->{tableid}, $event->{version}) = split(/\s+/, $data);
- } elsif($mark eq 'T') {
- $event->{title} = $data;
- } elsif($mark eq 'S') {
- $event->{subtitle} = $data;
- } elsif($mark eq 'D') {
- $event->{description} = $data;
- $event->{description} =~ s/\|/\r\n/g; # pipe used from vdr as linebreak
- $event->{description} =~ s/^\s+//; # no leading white space
- $event->{description} =~ s/\s+$//; # no trailing white space
- $event->{ldescription} = length($event->{description});
- } elsif($mark eq 'X') {
- my @d = split(/\s+/, $data);
- if($d[0] eq '1') {
- $event->{video} .= $data;
- } else {
- $event->{audio} .= $data."\n";
- }
- } elsif($mark eq 'V') {
- $event->{vpstime} = $data;
- }
- }
-# debug 'Finish Read %d lines in EPG Database at %d', scalar @$vdata,$count;
- return ($dataHash,$channel,$channelname,$count);
-}
-
-# ------------------
-sub search {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $data = shift;
- my $params = shift;
-
- my $tim = main::getModule('TIMERS');
-
- # Textsearch
- my $search;
- if($data) {
- if($params->{Where} && $params->{Where} eq 'title') {
- $search = buildsearch("e.title",$data);
- } elsif($params->{Where} && $params->{Where} eq 'titlesubtitle') {
- $search = buildsearch("e.title,e.subtitle",$data);
- } else {
- $search = buildsearch("e.title,e.subtitle,e.description",$data);
- }
- }
-
- # Channelsearch
- if($params->{channel}) {
- $search .= ' AND '
- if($search);
- $search .= sprintf('c.POS = %lu ', $params->{channel});
- }
-
- # Videoformat search
- if($params->{Videoformat} && $params->{Videoformat} eq 'widescreen') {
- $search .= ' AND '
- if($search);
- $search .= 'e.video like "%%16:9%%" ';
- }
-
- # Audioformat search
- # XXX: Leider kann man an den Audioeintrag nicht richtig erkennnen
- # hab erst zu spät erkannt das diese Info aus dem tvm2vdr kommen ;(
-# if($params->{Audioformat} eq 'dts') {
-# $search .= ' AND '
-# if($search);
-# $search .= 'e.audio like "%%Digital%%" ';
-# }
-
- # MinLength search
- if($params->{MinLength}) {
- $search .= ' AND '
- if($search);
- $search .= sprintf('e.duration >= %d ', ($params->{MinLength}*60));
- }
-
-
- my $erg = [];
- if($search) {
- my $sql = qq|
- select
- e.eventid as Service,
- e.title as Title,
- e.subtitle as __Subtitle,
- c.Name as Channel,
- c.POS as __Pos,
- DATE_FORMAT(e.starttime, '%H:%i') as Start,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration), '%H:%i') as Stop,
- UNIX_TIMESTAMP(e.starttime) as Day,
- e.description,
- IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
- from
- EPG as e,
- CHANNELS as c
- where
- e.channel_id = c.Id
- AND ( $search )
- order by
- starttime
- |;
- #dumper($sql);
- my $fields = fields($obj->{dbh}, $sql);
-
- $erg = $obj->{dbh}->selectall_arrayref($sql);
- unshift(@$erg, $fields);
- }
- $console->table($erg, {
- timers => $tim->getEpgIds,
- runningTimer => $tim->getRunningTimer('eventid'),
- }
- );
-}
-
-# ------------------
-sub program {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $channel = shift || $obj->{dbh}->selectrow_arrayref("select POS from CHANNELS limit 1")->[0];
-
- my $mod = main::getModule('CHANNELS');
- my $tim = main::getModule('TIMERS');
-
- my $cid;
- if($channel =~ /^\d+$/sig) {
- $cid = $mod->PosToChannel($channel)
- or return $console->err(sprintf(gettext("This channel '%s' does not exist in the database!"),$channel));
- } else {
- $cid = $mod->NameToChannel($channel)
- or return $console->err(sprintf(gettext("This channel '%s' does not exist in the database!"),$channel));
- }
-
- my $sql = qq|
-select
- e.eventid as Service,
- e.title as Title,
- e.subtitle as __Subtitle,
- DATE_FORMAT(e.starttime, '%H:%i') as Start,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration), '%H:%i') as Stop,
- UNIX_TIMESTAMP(e.starttime) as Day,
- e.description as __Description,
- e.video as __Video,
- e.audio as __Audio,
- IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
-from
- EPG as e, CHANNELS as c
-where
- e.channel_id = c.Id and
- e.channel_id = ?
-order by
- starttime
-|;
- my $fields = fields($obj->{dbh}, $sql);
- my $sth = $obj->{dbh}->prepare($sql);
+ }
+}
+
+# ------------------
+sub replace {
+# ------------------
+ my $obj = shift || return error ('No Object!');
+ my $eventid = shift || return error ('No eventid to insert!');;
+ my $attr = shift || return error ('No data to insert!');
+
+ my $sth = $obj->{dbh}->prepare('REPLACE INTO EPG(eventid, title, subtitle, description, channel_id, duration, tableid, image, version, video, audio, starttime, addtime, vpstime) VALUES (?,?,?,?,?,?,?,?,?,?,?,FROM_UNIXTIME(?),FROM_UNIXTIME(?),FROM_UNIXTIME(?))');
+ $sth->execute(
+ $eventid,
+ $attr->{title},
+ $attr->{subtitle},
+ $attr->{description},
+ $attr->{channel},
+ $attr->{duration},
+ $attr->{tableid},
+ $attr->{image} || '',
+ hex($attr->{version}),
+ $attr->{video} || '1 01 deu 4:3',
+ $attr->{audio} || "2 03 deu stereo",
+ $attr->{starttime},
+ time,
+ $attr->{vpstime}
+ ) if($attr->{channel});
+}
+
+# ------------------
+sub encodeEpgId {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $epgid = shift || return error('No EPG Id!');
+ my $channel = shift || return error('No Channel!');
+
+ # look for NID-TID-SID for unique eventids (SID 0-30000 / TID 0 - 1000 / NID 0 - 10000
+ my @id = split('-', $channel);
+
+ # Make a fix format 0xCCCCEEEE : C-Channelid (high-word), E-Eventid(low-word) => real-eventid = uniqueid & FFFF
+ my $eventid = ((($id[-3] + $id[-2] + $id[-1]) & 0x3FFF) << 16) | ($epgid & 0xFFFF);
+
+ return $eventid;
+}
+
+# ------------------
+sub readEpgData {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $vdata = shift || return error('Problem to read Data!');
+ my $count = shift || 0;
+ my $dataHash = {};
+
+ my $cmod = main::getModule ('CHANNELS');
+ my $channels = $cmod->ChannelArray ('Id,Name');
+ my $channel;
+ my $channelname;
+ my $event;
+
+ #debug 'Read %d lines in EPG Database from %d', scalar @$vdata,$offset;
+ for(;$count < scalar (@$vdata);$count++) {
+ my $line = @{$vdata}[$count];
+
+ # Ok, Datarow complete...
+ if($line eq 'e' and $event->{eventid} and $event->{channel}) {
+ if(-e sprintf('%s/%d.png', $obj->{epgimages}, $event->{eventid})) {
+ my $firstimage = sprintf('%d.png',$event->{eventid});
+ $event->{image} = $firstimage."\n";
+ my $imgpath = sprintf('%s/%d_?.png',$obj->{epgimages},$event->{eventid});
+ foreach my $img (glob($imgpath)) {
+ $event->{image} .= sprintf("%s.png\n", basename($img, '.png'));
+ }
+ }
+
+ $channel = $event->{channel};
+ my $eventid = $obj->encodeEpgId($event->{eventid}, $channel);
+
+ $event->{title} = gettext("No Title")
+ unless($event->{title});
+ $event->{description} = ""
+ unless($event->{description});
+
+ %{$dataHash->{$eventid}} = %{$event};
+
+ $event = undef;
+ $event->{channel} = $channel;
+ next;
+ }
+ elsif($line eq 'c') {
+ # Finish this channel
+ return ($dataHash,$channel,$channelname,$count+1)
+ if(scalar keys %$dataHash);
+
+ undef $event->{channel};
+ undef $channel;
+ undef $channelname;
+ }
+
+ my ($mark, $data) = $line =~ /^(\S)\s+(.+)/g;
+ next unless($mark and $data);
+
+ # Next channel
+ if($mark eq 'C') {
+ if($channel) {
+ debug 'Missing channel endtag c at line %d',$count;
+ return ($dataHash,$channel,$channelname,$count) if(scalar keys %$dataHash);
+ }
+ undef $event->{channel};
+ my $channel = (split(/\s+/, $data))[0];
+ # import only known channels
+ foreach my $ch (@{$channels}) {
+ if($ch->[0] eq $channel) {
+ $event->{channel} = $channel;
+ $channelname = $ch->[1];
+ last;
+ }
+ }
+ } elsif($mark eq 'E') {
+ ($event->{eventid}, $event->{starttime}, $event->{duration}, $event->{tableid}, $event->{version}) = split(/\s+/, $data);
+ } elsif($mark eq 'T') {
+ $event->{title} = $data;
+ } elsif($mark eq 'S') {
+ $event->{subtitle} = $data;
+ } elsif($mark eq 'D') {
+ $event->{description} = $data;
+ $event->{description} =~ s/\|/\r\n/g; # pipe used from vdr as linebreak
+ $event->{description} =~ s/^\s+//; # no leading white space
+ $event->{description} =~ s/\s+$//; # no trailing white space
+ $event->{ldescription} = length($event->{description});
+ } elsif($mark eq 'X') {
+ my @d = split(/\s+/, $data);
+ if($d[0] eq '1') {
+ $event->{video} .= $data;
+ } else {
+ $event->{audio} .= $data."\n";
+ }
+ } elsif($mark eq 'V') {
+ $event->{vpstime} = $data;
+ }
+ }
+# debug 'Finish Read %d lines in EPG Database at %d', scalar @$vdata,$count;
+ return ($dataHash,$channel,$channelname,$count);
+}
+
+# ------------------
+sub search {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $data = shift;
+ my $params = shift;
+
+ my $tim = main::getModule('TIMERS');
+
+ # Textsearch
+ my $search;
+ if($data) {
+ if($params->{Where} && $params->{Where} eq 'title') {
+ $search = buildsearch("e.title",$data);
+ } elsif($params->{Where} && $params->{Where} eq 'titlesubtitle') {
+ $search = buildsearch("e.title,e.subtitle",$data);
+ } else {
+ $search = buildsearch("e.title,e.subtitle,e.description",$data);
+ }
+ }
+
+ # Channelsearch
+ if($params->{channel}) {
+ $search .= ' AND '
+ if($search);
+ $search .= sprintf('c.POS = %lu ', $params->{channel});
+ }
+
+ # Videoformat search
+ if($params->{Videoformat} && $params->{Videoformat} eq 'widescreen') {
+ $search .= ' AND '
+ if($search);
+ $search .= 'e.video like "%%16:9%%" ';
+ }
+
+ # Audioformat search
+ # XXX: Leider kann man an den Audioeintrag nicht richtig erkennnen
+ # hab erst zu spät erkannt das diese Info aus dem tvm2vdr kommen ;(
+# if($params->{Audioformat} eq 'dts') {
+# $search .= ' AND '
+# if($search);
+# $search .= 'e.audio like "%%Digital%%" ';
+# }
+
+ # MinLength search
+ if($params->{MinLength}) {
+ $search .= ' AND '
+ if($search);
+ $search .= sprintf('e.duration >= %d ', ($params->{MinLength}*60));
+ }
+
+
+ my $erg = [];
+ if($search) {
+ my $sql = qq|
+ select
+ e.eventid as Service,
+ e.title as Title,
+ e.subtitle as __Subtitle,
+ c.Name as Channel,
+ c.POS as __Pos,
+ DATE_FORMAT(e.starttime, '%H:%i') as Start,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration), '%H:%i') as Stop,
+ UNIX_TIMESTAMP(e.starttime) as Day,
+ e.description,
+ IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
+ from
+ EPG as e,
+ CHANNELS as c
+ where
+ e.channel_id = c.Id
+ AND ( $search )
+ order by
+ starttime
+ |;
+ #dumper($sql);
+ my $fields = fields($obj->{dbh}, $sql);
+
+ $erg = $obj->{dbh}->selectall_arrayref($sql);
+ unshift(@$erg, $fields);
+ }
+ $console->table($erg, {
+ timers => $tim->getEpgIds,
+ runningTimer => $tim->getRunningTimer('eventid'),
+ }
+ );
+}
+
+# ------------------
+sub program {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $channel = shift || $obj->{dbh}->selectrow_arrayref("select POS from CHANNELS limit 1")->[0];
+
+ my $mod = main::getModule('CHANNELS');
+ my $tim = main::getModule('TIMERS');
+
+ my $cid;
+ if($channel =~ /^\d+$/sig) {
+ $cid = $mod->PosToChannel($channel)
+ or return $console->err(sprintf(gettext("This channel '%s' does not exist in the database!"),$channel));
+ } else {
+ $cid = $mod->NameToChannel($channel)
+ or return $console->err(sprintf(gettext("This channel '%s' does not exist in the database!"),$channel));
+ }
+
+ my $sql = qq|
+select
+ e.eventid as Service,
+ e.title as Title,
+ e.subtitle as __Subtitle,
+ DATE_FORMAT(e.starttime, '%H:%i') as Start,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration), '%H:%i') as Stop,
+ UNIX_TIMESTAMP(e.starttime) as Day,
+ e.description as __Description,
+ e.video as __Video,
+ e.audio as __Audio,
+ IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
+from
+ EPG as e, CHANNELS as c
+where
+ e.channel_id = c.Id and
+ e.channel_id = ?
+order by
+ starttime
+|;
+ my $fields = fields($obj->{dbh}, $sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($cid)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $erg = $sth->fetchall_arrayref();
- unshift(@$erg, $fields);
-
- $console->table($erg, {
- channels => $mod->ChannelArray('Name'),
- current => $mod->ChannelToPos($cid),
- timers => $tim->getEpgIds,
- runningTimer => $tim->getRunningTimer('eventid'),
- }
- );
-}
-
-# ------------------
-sub display {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $eventid = shift || return $console->err(gettext("No EventID to display the Event Programm! Please use display 'eventid'"));
-
- my %f = (
- 'Id' => umlaute(gettext('Service')),
- 'Title' => umlaute(gettext('Title')),
- 'Subtitle' => umlaute(gettext('Subtitle')),
- 'Channel' => umlaute(gettext('Channel')),
- 'Start' => umlaute(gettext('Start')),
- 'Stop' => umlaute(gettext('Stop')),
- 'Description' => umlaute(gettext('Description')),
- 'Percent' => umlaute(gettext('Percent')),
- );
-
- my $fields;
- my $erg;
-
- my $start = "e.starttime";
- my $stopp = "FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration)";
- my $vps = "e.vpstime";
-
- $start = "UNIX_TIMESTAMP(e.starttime)" if($console->typ eq "HTML");
- $stopp = "UNIX_TIMESTAMP(e.starttime) + e.duration" if($console->typ eq "HTML");
- $vps = "UNIX_TIMESTAMP(e.vpstime)" if($console->typ eq "HTML");
-
- foreach my $table (qw/EPG OLDEPG/) {
- my $sql = qq|
-select
- e.eventid as $f{'Id'},
- e.title as $f{'Title'},
- e.subtitle as $f{'Subtitle'},
- $start as $f{'Start'},
- $stopp as $f{'Stop'},
- c.Name as $f{'Channel'},
- e.description as $f{'Description'},
- e.image as __Image,
- (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/duration*100 as $f{'Percent'},
- e.video as __Video,
- e.audio as __Audio,
- IF(e.vpstime!=0,$vps,'') as __VPS
-from
- $table as e,CHANNELS as c
-where
- e.channel_id = c.Id
- and eventid = ?
-|;
- $fields = fields($obj->{dbh}, $sql);
- my $sth = $obj->{dbh}->prepare($sql);
+ my $erg = $sth->fetchall_arrayref();
+ unshift(@$erg, $fields);
+
+ $console->table($erg, {
+ channels => $mod->ChannelArray('Name'),
+ current => $mod->ChannelToPos($cid),
+ timers => $tim->getEpgIds,
+ runningTimer => $tim->getRunningTimer('eventid'),
+ }
+ );
+}
+
+# ------------------
+sub display {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $eventid = shift || return $console->err(gettext("No EventID to display the Event Programm! Please use display 'eventid'"));
+
+ my %f = (
+ 'Id' => umlaute(gettext('Service')),
+ 'Title' => umlaute(gettext('Title')),
+ 'Subtitle' => umlaute(gettext('Subtitle')),
+ 'Channel' => umlaute(gettext('Channel')),
+ 'Start' => umlaute(gettext('Start')),
+ 'Stop' => umlaute(gettext('Stop')),
+ 'Description' => umlaute(gettext('Description')),
+ 'Percent' => umlaute(gettext('Percent')),
+ );
+
+ my $fields;
+ my $erg;
+
+ my $start = "e.starttime";
+ my $stopp = "FROM_UNIXTIME(UNIX_TIMESTAMP(e.starttime) + e.duration)";
+ my $vps = "e.vpstime";
+
+ $start = "UNIX_TIMESTAMP(e.starttime)" if($console->typ eq "HTML");
+ $stopp = "UNIX_TIMESTAMP(e.starttime) + e.duration" if($console->typ eq "HTML");
+ $vps = "UNIX_TIMESTAMP(e.vpstime)" if($console->typ eq "HTML");
+
+ foreach my $table (qw/EPG OLDEPG/) {
+ my $sql = qq|
+select
+ e.eventid as $f{'Id'},
+ e.title as $f{'Title'},
+ e.subtitle as $f{'Subtitle'},
+ $start as $f{'Start'},
+ $stopp as $f{'Stop'},
+ c.Name as $f{'Channel'},
+ e.description as $f{'Description'},
+ e.image as __Image,
+ (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/duration*100 as $f{'Percent'},
+ e.video as __Video,
+ e.audio as __Audio,
+ IF(e.vpstime!=0,$vps,'') as __VPS
+from
+ $table as e,CHANNELS as c
+where
+ e.channel_id = c.Id
+ and eventid = ?
+|;
+ $fields = fields($obj->{dbh}, $sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventid)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- $erg = $sth->fetchall_arrayref();
-
- last
- if(scalar @{$erg} != 0 );
- }
-
- return $console->err(sprintf(gettext("No data for event '%d' present to display!"),$eventid))
- if(scalar @{$erg} == 0 );
-
- unshift(@$erg, $fields);
-
- my $tim = main::getModule('TIMERS');
- $console->table($erg,{timers => $tim->getEpgIds});
-}
-
-# ------------------
-sub runningNext {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $data = shift;
- my $param = shift || {};
- my $cgroups = main::getModule('CHANNELS')->ChannelGroupsArray('Name');
- my $cgrp = $param->{cgrp} || $cgroups->[0][1]; # Erster GroupEintrag
-
- # Create temporary table
- $obj->{dbh}->do(qq|
-CREATE TEMPORARY TABLE IF NOT EXISTS NEXTEPG (
- channel_id varchar(100) NOT NULL default '',
- nexttime datetime NOT NULL default '0000-00-00 00:00:00'
- )
-|);
- # Remove old data
- $obj->{dbh}->do('delete from NEXTEPG');
-
- # Get channelid and starttime of next broadcasting
- my $sqltemp = qq|
-INSERT INTO NEXTEPG select
- c.Id as channel_id,
- MIN(e.starttime) as nexttime
- FROM EPG as e, CHANNELS as c
- WHERE e.channel_id = c.Id
-AND UNIX_TIMESTAMP(e.starttime) > UNIX_TIMESTAMP(NOW())
-AND c.GRP = ?
-
-GROUP BY c.Id
-|;
- my $sthtemp = $obj->{dbh}->prepare($sqltemp);
+ $erg = $sth->fetchall_arrayref();
+
+ last
+ if(scalar @{$erg} != 0 );
+ }
+
+ return $console->err(sprintf(gettext("No data for event '%d' present to display!"),$eventid))
+ if(scalar @{$erg} == 0 );
+
+ unshift(@$erg, $fields);
+
+ my $tim = main::getModule('TIMERS');
+ $console->table($erg,{timers => $tim->getEpgIds});
+}
+
+# ------------------
+sub runningNext {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $data = shift;
+ my $param = shift || {};
+ my $cgroups = main::getModule('CHANNELS')->ChannelGroupsArray('Name');
+ my $cgrp = $param->{cgrp} || $cgroups->[0][1]; # Erster GroupEintrag
+
+ # Create temporary table
+ $obj->{dbh}->do(qq|
+CREATE TEMPORARY TABLE IF NOT EXISTS NEXTEPG (
+ channel_id varchar(100) NOT NULL default '',
+ nexttime datetime NOT NULL default '0000-00-00 00:00:00'
+ )
+|);
+ # Remove old data
+ $obj->{dbh}->do('delete from NEXTEPG');
+
+ # Get channelid and starttime of next broadcasting
+ my $sqltemp = qq|
+INSERT INTO NEXTEPG select
+ c.Id as channel_id,
+ MIN(e.starttime) as nexttime
+ FROM EPG as e, CHANNELS as c
+ WHERE e.channel_id = c.Id
+AND UNIX_TIMESTAMP(e.starttime) > UNIX_TIMESTAMP(NOW())
+AND c.GRP = ?
+
+GROUP BY c.Id
+|;
+ my $sthtemp = $obj->{dbh}->prepare($sqltemp);
$sthtemp->execute($cgrp)
or return error sprintf("Can't execute query: %s.",$sthtemp->errstr);
-
- my %f = (
- 'Service' => umlaute(gettext('Service')),
- 'Title' => umlaute(gettext('Title')),
- 'Channel' => umlaute(gettext('Channel')),
- 'Start' => umlaute(gettext('Start')),
- 'Stop' => umlaute(gettext('Stop'))
- );
- my $sql =
-qq|
-select
- e.eventid as $f{'Service'},
- e.title as $f{'Title'},
- e.subtitle as __Subtitle,
- c.Name as $f{'Channel'},
- c.POS as __POS,
- g.Name as __Channelgroup,
- DATE_FORMAT(e.starttime, "%H:%i") as $f{'Start'},
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as $f{'Stop'},
+
+ my %f = (
+ 'Service' => umlaute(gettext('Service')),
+ 'Title' => umlaute(gettext('Title')),
+ 'Channel' => umlaute(gettext('Channel')),
+ 'Start' => umlaute(gettext('Start')),
+ 'Stop' => umlaute(gettext('Stop'))
+ );
+ my $sql =
+qq|
+select
+ e.eventid as $f{'Service'},
+ e.title as $f{'Title'},
+ e.subtitle as __Subtitle,
+ c.Name as $f{'Channel'},
+ c.POS as __POS,
+ g.Name as __Channelgroup,
+ DATE_FORMAT(e.starttime, "%H:%i") as $f{'Start'},
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as $f{'Stop'},
e.description as __Description,
- 999 as __Percent,
+ 999 as __Percent,
IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
-FROM
- EPG as e, CHANNELS as c, NEXTEPG as n, CHANNELGROUPS as g
-WHERE
- e.channel_id = c.Id
- AND n.channel_id = c.Id
- AND c.GRP = g.Id
- AND e.starttime = n.nexttime
- AND c.GRP = ?
-ORDER BY
- c.POS|;
- my $fields = fields($obj->{dbh}, $sql);
- my $sth = $obj->{dbh}->prepare($sql);
+FROM
+ EPG as e, CHANNELS as c, NEXTEPG as n, CHANNELGROUPS as g
+WHERE
+ e.channel_id = c.Id
+ AND n.channel_id = c.Id
+ AND c.GRP = g.Id
+ AND e.starttime = n.nexttime
+ AND c.GRP = ?
+ORDER BY
+ c.POS|;
+ my $fields = fields($obj->{dbh}, $sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($cgrp)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $erg = $sth->fetchall_arrayref();
- unshift(@$erg, $fields);
-
- my $tim = main::getModule('TIMERS');
-
- $console->table($erg,
- {
- timers => $tim->getEpgIds,
- runningTimer => $tim->getRunningTimer('eventid'),
- periods => $obj->{periods},
- cgroups => $cgroups,
- channelgroup => $cgrp,
- }
- );
-}
-
-# ------------------
-sub runningNow {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $zeit = shift || time;
- my $param = shift || {};
- my $cgroups = main::getModule('CHANNELS')->ChannelGroupsArray('Name');
- my $cgrp = $param->{cgrp} || $cgroups->[0][1]; # Erster GroupEintrag
-
- # i.e.: 635 --> 06:35
- $zeit = fmttime($zeit)
- if(length($zeit) <= 4);
-
- # i.e.: 06:35 --> timeinsecs
- if($zeit =~ /^\d+:\d+$/sig) {
- $zeit = UnixDate(ParseDate($zeit),"%s") || time;
- }
-
- $zeit += 86400 if($zeit < time);
- $zeit++;
-
- my %f = (
- 'Service' => umlaute(gettext('Service')),
- 'Title' => umlaute(gettext('Title')),
- 'Channel' => umlaute(gettext('Channel')),
- 'Start' => umlaute(gettext('Start')),
- 'Stop' => umlaute(gettext('Stop')),
- 'Percent' => umlaute(gettext('Percent')),
- );
- my $sql =
-qq|
-select
- e.eventid as $f{'Service'},
- e.title as $f{'Title'},
- e.subtitle as __Subtitle,
- c.Name as $f{'Channel'},
- c.POS as __POS,
- g.Name as __Channelgroup,
- DATE_FORMAT(e.starttime, "%H:%i") as $f{'Start'},
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as $f{'Stop'},
- e.description as __Description,
- (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as $f{'Percent'},
- IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
-FROM
- EPG as e, CHANNELS as c, CHANNELGROUPS as g
-WHERE
- e.channel_id = c.Id
- AND c.GRP = g.Id
- AND ? BETWEEN UNIX_TIMESTAMP(e.starttime)
- AND (UNIX_TIMESTAMP(e.starttime) + e.duration)
- AND c.GRP = ?
-ORDER BY
- c.POS|;
-
- my $fields = fields($obj->{dbh}, $sql);
- my $sth = $obj->{dbh}->prepare($sql);
+ my $erg = $sth->fetchall_arrayref();
+ unshift(@$erg, $fields);
+
+ my $tim = main::getModule('TIMERS');
+
+ $console->table($erg,
+ {
+ timers => $tim->getEpgIds,
+ runningTimer => $tim->getRunningTimer('eventid'),
+ periods => $obj->{periods},
+ cgroups => $cgroups,
+ channelgroup => $cgrp,
+ }
+ );
+}
+
+# ------------------
+sub runningNow {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $zeit = shift || time;
+ my $param = shift || {};
+ my $cgroups = main::getModule('CHANNELS')->ChannelGroupsArray('Name');
+ my $cgrp = $param->{cgrp} || $cgroups->[0][1]; # Erster GroupEintrag
+
+ # i.e.: 635 --> 06:35
+ $zeit = fmttime($zeit)
+ if(length($zeit) <= 4);
+
+ # i.e.: 06:35 --> timeinsecs
+ if($zeit =~ /^\d+:\d+$/sig) {
+ $zeit = UnixDate(ParseDate($zeit),"%s") || time;
+ }
+
+ $zeit += 86400 if($zeit < time);
+ $zeit++;
+
+ my %f = (
+ 'Service' => umlaute(gettext('Service')),
+ 'Title' => umlaute(gettext('Title')),
+ 'Channel' => umlaute(gettext('Channel')),
+ 'Start' => umlaute(gettext('Start')),
+ 'Stop' => umlaute(gettext('Stop')),
+ 'Percent' => umlaute(gettext('Percent')),
+ );
+ my $sql =
+qq|
+select
+ e.eventid as $f{'Service'},
+ e.title as $f{'Title'},
+ e.subtitle as __Subtitle,
+ c.Name as $f{'Channel'},
+ c.POS as __POS,
+ g.Name as __Channelgroup,
+ DATE_FORMAT(e.starttime, "%H:%i") as $f{'Start'},
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as $f{'Stop'},
+ e.description as __Description,
+ (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as $f{'Percent'},
+ IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
+FROM
+ EPG as e, CHANNELS as c, CHANNELGROUPS as g
+WHERE
+ e.channel_id = c.Id
+ AND c.GRP = g.Id
+ AND ? BETWEEN UNIX_TIMESTAMP(e.starttime)
+ AND (UNIX_TIMESTAMP(e.starttime) + e.duration)
+ AND c.GRP = ?
+ORDER BY
+ c.POS|;
+
+ my $fields = fields($obj->{dbh}, $sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($zeit, $cgrp)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchall_arrayref();
- unshift(@$erg, $fields);
-
- my $tim = main::getModule('TIMERS');
- $console->table($erg,
- {
- timers => $tim->getEpgIds,
- runningTimer => $tim->getRunningTimer('eventid'),
- zeit => $zeit,
- periods => $obj->{periods},
- cgroups => $cgroups,
- channelgroup => $cgrp,
- }
- );
-}
-
-# ------------------
-sub NowOnChannel {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $channel = shift || $obj->_actualChannel || return error('No Channel!');
- my $zeit = time;
-
- my $sql =
-qq|
-select
- e.eventid as Service,
- e.title as Title,
- e.subtitle as Subtitle,
- c.Name as Channel,
- c.POS as POS,
- e.video as __video,
- e.audio as __audio,
- DATE_FORMAT(e.starttime, "%a %d.%m") as StartDay,
- DATE_FORMAT(e.starttime, "%H:%i") as StartTime,
- (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as __Percent,
- e.description as Description,
- IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
-FROM
- EPG as e, CHANNELS as c
-WHERE
- e.channel_id = c.Id
- AND ? BETWEEN UNIX_TIMESTAMP(e.starttime)
- AND (UNIX_TIMESTAMP(e.starttime) + e.duration)
- AND c.POS = ?
-ORDER BY
- starttime
-LIMIT 1
-|;
+ unshift(@$erg, $fields);
+
+ my $tim = main::getModule('TIMERS');
+ $console->table($erg,
+ {
+ timers => $tim->getEpgIds,
+ runningTimer => $tim->getRunningTimer('eventid'),
+ zeit => $zeit,
+ periods => $obj->{periods},
+ cgroups => $cgroups,
+ channelgroup => $cgrp,
+ }
+ );
+}
+
+# ------------------
+sub NowOnChannel {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $channel = shift || $obj->_actualChannel || return error('No Channel!');
+ my $zeit = time;
+
+ my $sql =
+qq|
+select
+ e.eventid as Service,
+ e.title as Title,
+ e.subtitle as Subtitle,
+ c.Name as Channel,
+ c.POS as POS,
+ e.video as __video,
+ e.audio as __audio,
+ DATE_FORMAT(e.starttime, "%a %d.%m") as StartDay,
+ DATE_FORMAT(e.starttime, "%H:%i") as StartTime,
+ (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as __Percent,
+ e.description as Description,
+ IF(e.vpstime!=0,DATE_FORMAT(e.vpstime, '%H:%i'),'') as __VPS
+FROM
+ EPG as e, CHANNELS as c
+WHERE
+ e.channel_id = c.Id
+ AND ? BETWEEN UNIX_TIMESTAMP(e.starttime)
+ AND (UNIX_TIMESTAMP(e.starttime) + e.duration)
+ AND c.POS = ?
+ORDER BY
+ starttime
+LIMIT 1
+|;
#dumper($sql);
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($zeit, $channel)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $erg = $sth->fetchrow_hashref();
-
- if(ref $console) {
- return $console->table($erg);
- } else {
- return $erg;
- }
-}
-
-# ------------------
-sub _actualChannel {
-# ------------------
- my $obj = shift || return error ('No Object!' );
-
- my $erg = $obj->{svdrp}->command('chan');
- my ($chanpos, $channame) = $erg->[1] =~ /^250\s+(\d+)\s+(\S+)/sig;
- return $chanpos;
-}
-
-# ------------------
-sub schema {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $zeit = shift || time;
- my $param = shift || {};
-
-
- # i.e.: 635 --> 06:35
- $zeit = fmttime($zeit)
- if(length($zeit) <= 4);
-
- # i.e.: 06:35 --> timeinsecs
- if($zeit =~ /^\d+:\d+$/sig) {
- $zeit = UnixDate(ParseDate($zeit),"%s") || time;
- }
-
- $zeit += 86400 if($zeit < time - ($obj->{timeframe} * 3600));
- $zeit++;
- my $zeitvon = $obj->toFullHour($zeit);
-
- my $zeitbis = $zeitvon + ($obj->{timeframe}*3600);
- my $cgroups = main::getModule('CHANNELS')->ChannelGroupsArray('Name');
- my $cgrp = $param->{cgrp} || $cgroups->[0][1]; # Erster GroupEintrag
-
- my $sql =
-qq|
-select
- e.eventid as Service,
- e.title as Title,
- e.subtitle as __Subtitle,
- c.Name as Channel,
- c.POS as __POS,
- DATE_FORMAT(e.starttime, "%H:%i") as Start,
- DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as Stop,
- (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as Percent,
- e.description as __Description,
- UNIX_TIMESTAMP(starttime) as second_start,
- UNIX_TIMESTAMP(starttime) + e.duration as second_stop,
- e.video as __video,
- e.audio as __audio,
- e.image as __image
-FROM
- EPG as e, CHANNELS as c
-WHERE
- e.channel_id = c.Id
- AND
- (
- ( UNIX_TIMESTAMP(e.starttime) >= ? AND UNIX_TIMESTAMP(e.starttime) <= ? )
- OR
- ( UNIX_TIMESTAMP(e.starttime) + e.duration >= ? AND UNIX_TIMESTAMP(e.starttime) + e.duration <= ? )
- OR
- ( UNIX_TIMESTAMP(e.starttime) <= ? AND UNIX_TIMESTAMP(e.starttime) + e.duration >= ? )
- )
- AND
- c.GRP = ?
-ORDER BY
- c.POS,e.starttime
-|;
-
+ my $erg = $sth->fetchrow_hashref();
+
+ if(ref $console) {
+ return $console->table($erg);
+ } else {
+ return $erg;
+ }
+}
+
+# ------------------
+sub _actualChannel {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+
+ my $erg = $obj->{svdrp}->command('chan');
+ my ($chanpos, $channame) = $erg->[1] =~ /^250\s+(\d+)\s+(\S+)/sig;
+ return $chanpos;
+}
+
+# ------------------
+sub schema {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $zeit = shift || time;
+ my $param = shift || {};
+
+
+ # i.e.: 635 --> 06:35
+ $zeit = fmttime($zeit)
+ if(length($zeit) <= 4);
+
+ # i.e.: 06:35 --> timeinsecs
+ if($zeit =~ /^\d+:\d+$/sig) {
+ $zeit = UnixDate(ParseDate($zeit),"%s") || time;
+ }
+
+ $zeit += 86400 if($zeit < time - ($obj->{timeframe} * 3600));
+ $zeit++;
+ my $zeitvon = $obj->toFullHour($zeit);
+
+ my $zeitbis = $zeitvon + ($obj->{timeframe}*3600);
+ my $cgroups = main::getModule('CHANNELS')->ChannelGroupsArray('Name');
+ my $cgrp = $param->{cgrp} || $cgroups->[0][1]; # Erster GroupEintrag
+
+ my $sql =
+qq|
+select
+ e.eventid as Service,
+ e.title as Title,
+ e.subtitle as __Subtitle,
+ c.Name as Channel,
+ c.POS as __POS,
+ DATE_FORMAT(e.starttime, "%H:%i") as Start,
+ DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + e.duration), "%H:%i") as Stop,
+ (unix_timestamp(e.starttime) + e.duration - unix_timestamp())/e.duration*100 as Percent,
+ e.description as __Description,
+ UNIX_TIMESTAMP(starttime) as second_start,
+ UNIX_TIMESTAMP(starttime) + e.duration as second_stop,
+ e.video as __video,
+ e.audio as __audio,
+ e.image as __image
+FROM
+ EPG as e, CHANNELS as c
+WHERE
+ e.channel_id = c.Id
+ AND
+ (
+ ( UNIX_TIMESTAMP(e.starttime) >= ? AND UNIX_TIMESTAMP(e.starttime) <= ? )
+ OR
+ ( UNIX_TIMESTAMP(e.starttime) + e.duration >= ? AND UNIX_TIMESTAMP(e.starttime) + e.duration <= ? )
+ OR
+ ( UNIX_TIMESTAMP(e.starttime) <= ? AND UNIX_TIMESTAMP(e.starttime) + e.duration >= ? )
+ )
+ AND
+ c.GRP = ?
+ORDER BY
+ c.POS,e.starttime
+|;
+
my $fields = fields($obj->{dbh}, $sql);
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($zeitvon,$zeitbis,$zeitvon,$zeitbis,$zeitvon,$zeitbis,$cgrp)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $erg = $sth->fetchall_arrayref();
-
- my $data = {};
- foreach my $c (@$erg) {
- push(@{$data->{$c->[4]}}, $c);
- }
-
- my $tim = main::getModule('TIMERS');
- $console->table($data,
- {
- timers => $tim->getEpgIds,
- runningTimer => $tim->getRunningTimer('eventid'),
- zeitvon => $zeitvon,
- zeitbis => $zeitbis,
- periods => $obj->{periods},
- cgroups => $cgroups,
- channelgroup => $cgrp,
- HouresProSite => $obj->{timeframe}
- }
- );
-}
-
-# ------------------
-sub checkOnTimer {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $eid = shift || return error('No Id');
- my $tim = main::getModule('TIMERS');
-
- my $sql = qq|
-SELECT
- e.starttime as NextStartTime,
- ADDDATE(e.starttime, INTERVAL e.duration SECOND) as NextStopTime,
- LEFT(c.Source,1) as source,
- c.TID as transponderid
-FROM
- EPG as e, CHANNELS as c
-WHERE
- e.eventid = ?
- and
- e.channel_id = c.Id
+ my $erg = $sth->fetchall_arrayref();
+
+ my $data = {};
+ foreach my $c (@$erg) {
+ push(@{$data->{$c->[4]}}, $c);
+ }
+
+ my $tim = main::getModule('TIMERS');
+ $console->table($data,
+ {
+ timers => $tim->getEpgIds,
+ runningTimer => $tim->getRunningTimer('eventid'),
+ zeitvon => $zeitvon,
+ zeitbis => $zeitbis,
+ periods => $obj->{periods},
+ cgroups => $cgroups,
+ channelgroup => $cgrp,
+ HouresProSite => $obj->{timeframe}
+ }
+ );
+}
+
+# ------------------
+sub checkOnTimer {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $eid = shift || return error('No Id');
+ my $tim = main::getModule('TIMERS');
+
+ my $sql = qq|
+SELECT
+ e.starttime as NextStartTime,
+ ADDDATE(e.starttime, INTERVAL e.duration SECOND) as NextStopTime,
+ LEFT(c.Source,1) as source,
+ c.TID as transponderid
+FROM
+ EPG as e, CHANNELS as c
+WHERE
+ e.eventid = ?
+ and
+ e.channel_id = c.Id
|;
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eid)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $data = $sth->fetchrow_hashref();
- my $erg = $tim->checkOverlapping($data) || ['ok'];
- my $tmod = main::getModule('TIMERS');
- # Zeige den Title des Timers
- foreach (@$erg) {
- $_ = $tmod->getTimerById((split(':', $_))[0])->{File}
- unless($_ eq 'ok');
- }
-
- $console->message(join(',',@$erg))
- if(ref $console);
-
-}
-
-# ------------------
-sub getDescription { # ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $eid = shift || 0;
+ my $data = $sth->fetchrow_hashref();
+ my $erg = $tim->checkOverlapping($data) || ['ok'];
+ my $tmod = main::getModule('TIMERS');
+ # Zeige den Title des Timers
+ foreach (@$erg) {
+ $_ = $tmod->getTimerById((split(':', $_))[0])->{File}
+ unless($_ eq 'ok');
+ }
+
+ $console->message(join(',',@$erg))
+ if(ref $console);
+
+}
+
+# ------------------
+sub getDescription {# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $eid = shift || 0;
my $event = $obj->getId($eid,"description");
- $console->message($event && $event->{description} ? $event->{description} : "")
- if(ref $console);
-}
-
-# ------------------
-sub toFullHour {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $zeit = shift || return error ('No Time to convert!' );
-
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
- localtime($zeit);
- my $retzeit = timelocal(0, 0, $hour, $mday, $mon, $year);
- return $retzeit;
-}
-
-
-# ------------------
-sub getId {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $id = shift || return error ('No Id!' );
- my $fields = shift || '*';
-
- foreach my $table (qw/EPG OLDEPG/) {
- # EPG
+ $console->message($event && $event->{description} ? $event->{description} : "")
+ if(ref $console);
+}
+
+# ------------------
+sub toFullHour {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $zeit = shift || return error ('No Time to convert!' );
+
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
+ localtime($zeit);
+ my $retzeit = timelocal(0, 0, $hour, $mday, $mon, $year);
+ return $retzeit;
+}
+
+
+# ------------------
+sub getId {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $id = shift || return error ('No Id!' );
+ my $fields = shift || '*';
+
+ foreach my $table (qw/EPG OLDEPG/) {
+ # EPG
my $sql = sprintf('select %s from %s WHERE eventid = ?',$fields, $table);
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($id)
or return error "Can't execute query: $sth->errstr.";
- my $erg = $sth->fetchrow_hashref();
- return $erg
+ my $erg = $sth->fetchrow_hashref();
+ return $erg
if($erg);
- }
+ }
debug("Event %d not exist!", $id);
- return {};
+ return {};
}
-# ------------------
-sub suggest { # ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
+# ------------------
+sub suggest {# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
my $search = shift;
my $params = shift;
@@ -1199,33 +1199,33 @@ sub suggest { # ------------------
}
my $sql = qq|
- SELECT
- e.title as title
+ SELECT
+ e.title as title
FROM
- EPG as e,
+ EPG as e,
CHANNELS as c
WHERE
channel_id = c.Id
- AND ( e.title LIKE ? )
- $ch
+ AND ( e.title LIKE ? )
+ $ch
GROUP BY
title
UNION
- SELECT
- e.subtitle as title
+ SELECT
+ e.subtitle as title
FROM
- EPG as e,
+ EPG as e,
CHANNELS as c
WHERE
channel_id = c.Id
- AND ( e.subtitle LIKE ? )
- $ch
+ AND ( e.subtitle LIKE ? )
+ $ch
GROUP BY
title
ORDER BY
title
LIMIT 25
- |;
+ |;
my $sth = $obj->{dbh}->prepare($sql);
if($params->{channel}) {
$sth->execute('%'.$search.'%',$params->{channel},'%'.$search.'%',$params->{channel})
@@ -1234,10 +1234,10 @@ LIMIT 25
$sth->execute('%'.$search.'%','%'.$search.'%')
or return error "Can't execute query: $sth->errstr.";
}
- my $result = $sth->fetchall_arrayref();
- $console->table($result)
+ my $result = $sth->fetchall_arrayref();
+ $console->table($result)
if(ref $console && $result);
}
-}
-
-1;
+}
+
+1;
diff --git a/lib/XXV/MODULES/MEDIALIB.pm b/lib/XXV/MODULES/MEDIALIB.pm
index 6ecda2a..5bf8a0e 100644
--- a/lib/XXV/MODULES/MEDIALIB.pm
+++ b/lib/XXV/MODULES/MEDIALIB.pm
@@ -771,7 +771,7 @@ sub deleteMedia {
$console->message(sprintf gettext("Media %s is deleted."), join(',', @media));
debug sprintf('media with id "%s" is deleted%s',
join(',', @media),
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
);
$console->redirect({url => '?cmd=mllist', wait => 1})
if($console->typ eq 'HTML');
diff --git a/lib/XXV/MODULES/MUSIC.pm b/lib/XXV/MODULES/MUSIC.pm
index a6ac698..6c54560 100644
--- a/lib/XXV/MODULES/MUSIC.pm
+++ b/lib/XXV/MODULES/MUSIC.pm
@@ -142,7 +142,7 @@ sub module {
DenyClass => 'mlist',
},
msuggest => {
- hidden => 'yes',
+ hidden => 'yes',
callback => sub{ $obj->suggest(@_) },
DenyClass => 'mlist',
},
@@ -1323,11 +1323,11 @@ sub getfile {
return 0;
}
-# ------------------
-sub suggest { # ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
+# ------------------
+sub suggest {# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
my $search = shift;
my $params = shift;
@@ -1342,11 +1342,11 @@ sub suggest { # ------------------
$result = ($obj->{mdbh} ? $obj->GroupArray('title', 'tracks', 'id',$search, 25): $obj->GroupArray('TITLE',undef,undef,$search, 25))
if($params->{get} eq 'title');
- $console->table($result)
+ $console->table($result)
if(ref $console && $result);
}
-
-}
+
+}
1;
diff --git a/lib/XXV/MODULES/RECORDS.pm b/lib/XXV/MODULES/RECORDS.pm
index f1f354d..1aa65dd 100644
--- a/lib/XXV/MODULES/RECORDS.pm
+++ b/lib/XXV/MODULES/RECORDS.pm
@@ -155,7 +155,7 @@ sub module {
DenyClass => 'remote',
},
rsuggest => {
- hidden => 'yes',
+ hidden => 'yes',
callback => sub{ $obj->suggest(@_) },
DenyClass => 'rlist',
},
@@ -236,8 +236,8 @@ sub new {
# read the DB Handle
$self->{dbh} = delete $attr{'-dbh'};
- # define framerate PAL 25, NTSC 30
- $self->{framerate} = 25;
+ # define framerate PAL 25, NTSC 30
+ $self->{framerate} = 25;
# The Initprocess
my $erg = $self->_init or return error('Problem to initialize module');
@@ -294,13 +294,13 @@ sub _init {
prio => 6, # -1 very hard ... 6 very low
cb => sub{
$obj->readData();
- $obj->{countReading} += 1;
+ $obj->{countReading} += 1;
},
);
$obj->readData();
- $obj->{countReading} += 1;
+ $obj->{countReading} += 1;
return 1;
- }, "RECORDS: Store records in database ...", 20);
+ }, "RECORDS: Store records in database ...", 20);
1;
}
@@ -313,11 +313,11 @@ sub dot1000 {
return scalar reverse $t;
}
-# ------------------
-sub parseData {
-# ------------------
- my $obj = shift || return error ('No Object!' );
- my $vdata = shift || return error('Problem to read Data!');
+# ------------------
+sub parseData {
+# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $vdata = shift || return error('Problem to read Data!');
my ($event, $hash, $id, $date, $hour, $minute, $state, $duration, $title, $day, $month, $year);
my $dataHash = {};
@@ -356,9 +356,9 @@ sub parseData {
return ($dataHash);
}
-# ------------------
-sub scandirectory { # ------------------
- my $obj = shift || return error ('No Object!');
+# ------------------
+sub scandirectory {# ------------------
+ my $obj = shift || return error ('No Object!');
find(
{
@@ -421,8 +421,8 @@ sub readData {
}
my @merkIds;
- my $insertedData = 0;
- my $updatedState = 0;
+ my $insertedData = 0;
+ my $updatedState = 0;
my $l = 0;
my $err = [];
@@ -434,12 +434,12 @@ sub readData {
$obj->{FILES} = undef;
- my $db_data;
- if($forceUpdate || $obj->{countReading} % ( $obj->{fullreading} * 3600 / $obj->{interval} ) == 0) {
+ my $db_data;
+ if($forceUpdate || $obj->{countReading} % ( $obj->{fullreading} * 3600 / $obj->{interval} ) == 0) {
# Once at day, make full scan
$obj->{dbh}->do('DELETE FROM RECORDS');
} else {
- # read database for compare with vdr data
+ # read database for compare with vdr data
my $sql = qq|select r.eventid as eventid, r.RecordId as id,
UNIX_TIMESTAMP(e.starttime) as starttime,
e.duration as duration, r.State as state,
@@ -455,30 +455,30 @@ sub readData {
$db_data = $obj->{dbh}->selectall_hashref($sql, 'hash');
lg sprintf( 'Compare recording database with data from vdr : %d / %d',
- scalar keys %$db_data,scalar keys %$vdrData );
+ scalar keys %$db_data,scalar keys %$vdrData );
}
- # Compare this Hashes
- foreach my $h (keys %{$vdrData}) {
- my $event = $vdrData->{$h};
+ # Compare this Hashes
+ foreach my $h (keys %{$vdrData}) {
+ my $event = $vdrData->{$h};
- # Exists in DB ... update
- if($db_data && exists $db_data->{$h}) {
+ # Exists in DB ... update
+ if($db_data && exists $db_data->{$h}) {
$waiter->next(++$l,undef, sprintf(gettext("Update recording '%s'"),
$db_data->{$h}->{title}))
- if(ref $waiter);
+ if(ref $waiter);
- # Compare fields
- foreach my $field (qw/id state/) {
- if($db_data->{$h}->{$field} != $event->{$field}) {
+ # Compare fields
+ foreach my $field (qw/id state/) {
+ if($db_data->{$h}->{$field} != $event->{$field}) {
- $obj->_updateState($db_data->{$h}, $event);
+ $obj->_updateState($db_data->{$h}, $event);
$updatedState++;
- last;
- }
- }
+ last;
+ }
+ }
# Update Duration and maybe preview images, if recordings added during timer run
if(($db_data->{$h}->{starttime} + $db_data->{$h}->{duration} + 60) > $db_data->{$h}->{addtime}) {
@@ -508,9 +508,9 @@ sub readData {
push(@merkIds,$db_data->{$h}->{eventid});
- # delete updated rows from hash
+ # delete updated rows from hash
delete $db_data->{$h};
-
+
} else {
$waiter->next(++$l,undef, sprintf(gettext("Analyze recording '%s'"),
$event->{title}))
@@ -528,19 +528,19 @@ sub readData {
if($obj->insert($anahash)) {
push(@merkIds,$anahash->{eventid});
- $insertedData++;
+ $insertedData++;
} else {
push(@{$err},$anahash->{title});
}
} else {
push(@{$err},$event->{title});
- }
- }
- }
-
+ }
+ }
+ }
+
if($db_data && scalar keys %$db_data > 0) {
my @todel;
- foreach my $t (keys %{$db_data}) {
+ foreach my $t (keys %{$db_data}) {
push(@todel,$db_data->{$t}->{RecordMD5});
}
@@ -548,10 +548,10 @@ sub readData {
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute(@todel)
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- }
-
+ }
+
debug sprintf 'Finish .. %d recordings inserted, %d recordings updated, %d recordings removed',
- $insertedData, $updatedState, $db_data ? scalar keys %$db_data : 0;
+ $insertedData, $updatedState, $db_data ? scalar keys %$db_data : 0;
$obj->{CapacityTotal} = $totalDuration;
$obj->{CapacityPercent} = (100.0 / $total) * ($total - $free)
@@ -701,11 +701,11 @@ sub _updateEvent {
return $event;
}
-# ------------------
-sub _updateState { # ------------------
- my $obj = shift || return error ('No Object!');
- my $oldattr = shift || return error ('Missing data');
- my $attr = shift || return error ('No data to replace!');
+# ------------------
+sub _updateState {# ------------------
+ my $obj = shift || return error ('No Object!');
+ my $oldattr = shift || return error ('Missing data');
+ my $attr = shift || return error ('No data to replace!');
my $sth = $obj->{dbh}->prepare('UPDATE RECORDS SET RecordId=?, State=?, addtime=FROM_UNIXTIME(?) where RecordMD5=?');
return $sth->execute($attr->{id},$attr->{state},time,$oldattr->{RecordMD5});
@@ -715,7 +715,7 @@ sub _updateState { # ------------------
sub analyze {
# ------------------
my $obj = shift || return error ('No Object!' );
- my $recattr = shift || return error ('No data to analyze!');
+ my $recattr = shift || return error ('No data to analyze!');
lg sprintf('Analyze record "%s" from system',
$recattr->{title},
@@ -1193,7 +1193,7 @@ sub play {
my $recordid = shift || return $console->err(gettext("No RecordID to play the recording! Please use rplay 'rid'"));
my $sql = qq|SELECT RecordID FROM RECORDS WHERE RecordMD5 = ?|;
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
my $rec;
if(!$sth->execute($recordid)
|| !($rec = $sth->fetchrow_hashref())) {
@@ -1213,7 +1213,7 @@ sub cut {
my $recordid = shift || return $console->err(gettext("No RecordID to play the recording! Please use rplay 'rid'"));
my $sql = qq|SELECT RecordID FROM RECORDS WHERE RecordMD5 = ?|;
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
my $rec;
if(!$sth->execute($recordid)
|| !($rec = $sth->fetchrow_hashref())) {
@@ -1525,7 +1525,7 @@ WHERE
e.eventid = r.eventid
AND ( r.RecordMD5 = ? )
|;
- my $sth = $obj->{dbh}->prepare($sql);
+ my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($recordid)
or return $console->err(sprintf(gettext("RecordID '%s' does not exist in the database!"),$recordid));
$rec = $sth->fetchrow_hashref();
@@ -2089,49 +2089,49 @@ sub converttitle {
return $title;
}
-# ------------------
-sub suggest { # ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
+# ------------------
+sub suggest {# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
my $search = shift;
my $params = shift;
- if($search) {
- my $sql = qq|
- SELECT
- e.title as title
+ if($search) {
+ my $sql = qq|
+ SELECT
+ e.title as title
FROM
RECORDS as r,
OLDEPG as e
WHERE
e.eventid = r.eventid
- AND ( e.title LIKE ? )
+ AND ( e.title LIKE ? )
GROUP BY
title
UNION
- SELECT
- e.subtitle as title
+ SELECT
+ e.subtitle as title
FROM
RECORDS as r,
OLDEPG as e
WHERE
e.eventid = r.eventid
- AND ( e.subtitle LIKE ? )
+ AND ( e.subtitle LIKE ? )
GROUP BY
title
ORDER BY
title
-LIMIT 25
+LIMIT 25
|;
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute('%'.$search.'%','%'.$search.'%')
or return error "Can't execute query: $sth->errstr.";
- my $result = $sth->fetchall_arrayref();
- $console->table($result)
+ my $result = $sth->fetchall_arrayref();
+ $console->table($result)
if(ref $console && $result);
- }
-}
+ }
+}
1;
diff --git a/lib/XXV/MODULES/TIMERS.pm b/lib/XXV/MODULES/TIMERS.pm
index 9501cfd..2df60e6 100644
--- a/lib/XXV/MODULES/TIMERS.pm
+++ b/lib/XXV/MODULES/TIMERS.pm
@@ -117,7 +117,7 @@ sub module {
DenyClass => 'tedit',
},
tsuggest => {
- hidden => 'yes',
+ hidden => 'yes',
callback => sub{ $obj->suggest(@_) },
DenyClass => 'tlist',
},
@@ -311,7 +311,7 @@ sub status {
error sprintf("Can't execute query: %s.",$sth->errstr);
} else {
my $erg = $sth->fetchrow_hashref();
- $total = $erg->{count} if($erg && $erg->{count});
+ $total = $erg->{count} if($erg && $erg->{count});
}
}
@@ -758,7 +758,7 @@ WHERE
debug sprintf('%s timer with title "%s" is saved%s',
($timerid ? 'Changed' : 'New'),
$data->{File},
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
);
$console->message($erg);
} else {
@@ -813,7 +813,7 @@ sub deleteTimer {
debug sprintf('Delete timer with title "%s"%s',
$data->{$tid}->{File},
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
);
$obj->{svdrp}->queue_cmds(sprintf("modt %d off", $tid))
@@ -873,7 +873,7 @@ sub toggleTimer {
debug sprintf('Timer with title "%s" is %s%s',
$data->{$timer}->{File},
($status eq 'on' ? 'activated' : 'deactivated'),
- ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
+ ( $console->{USER} && $console->{USER}->{Name} ? sprintf(' from user: %s', $console->{USER}->{Name}) : "" )
);
$obj->{svdrp}->queue_cmds("modt $data->{$timer}->{Id} $status"); # Sammeln der Kommandos
@@ -1513,7 +1513,7 @@ sub _getNextEpgId {
$timer->{NextStartTime})) {
lg sprintf("Can't find epg event for timer with id %d - %s", $timer->{Id} , $timer->{File} );
return 0;
- }
+ }
$e = $sth->fetchrow_hashref();
} else {
@@ -1532,7 +1532,7 @@ sub _getNextEpgId {
$timer->{NextStartTime})) {
lg sprintf("Can't find epg event for timer with id %d - %s", $timer->{Id} , $timer->{File} );
return 0;
- }
+ }
$e = $sth->fetchrow_hashref();
}
@@ -1684,38 +1684,38 @@ sub my_strftime {
return(strftime($format, localtime($time)));
}
-# ------------------
-sub suggest { # ------------------
- my $obj = shift || return error ('No Object!' );
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
+# ------------------
+sub suggest {# ------------------
+ my $obj = shift || return error ('No Object!' );
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
my $search = shift;
my $params = shift;
if($search) {
my $sql = qq|
- SELECT
- File
+ SELECT
+ File
FROM
TIMERS
WHERE
- ( File LIKE ? )
+ ( File LIKE ? )
GROUP BY
File
ORDER BY
File
LIMIT 25
- |;
+ |;
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute('%'.$search.'%')
or return error sprintf("Can't execute query: %s.",$sth->errstr);
- my $result = $sth->fetchall_arrayref();
- $console->table($result)
+ my $result = $sth->fetchall_arrayref();
+ $console->table($result)
if(ref $console && $result);
}
-}
-
-1;
+}
+
+1;
1;
diff --git a/lib/XXV/MODULES/VTX.pm b/lib/XXV/MODULES/VTX.pm
index a4e7514..3c3f62b 100644
--- a/lib/XXV/MODULES/VTX.pm
+++ b/lib/XXV/MODULES/VTX.pm
@@ -1,324 +1,324 @@
-package XXV::MODULES::VTX;
-
-use strict;
-
-use File::Find;
-use FileHandle;
-use Locale::gettext;
-
-################################################################################
-# This module method must exist for XXV
-sub module {
- my $self = shift || return error ('No Object!' );
- my $args = {
- Name => 'VTX',
- Prereq => {
- # 'Perl::Module' => 'Description',
- },
- Description => gettext('This module display cached teletext pages from osdteletext-plugin.'),
+package XXV::MODULES::VTX;
+
+use strict;
+
+use File::Find;
+use FileHandle;
+use Locale::gettext;
+
+################################################################################
+# This module method must exist for XXV
+sub module {
+ my $self = shift || return error ('No Object!' );
+ my $args = {
+ Name => 'VTX',
+ Prereq => {
+ # 'Perl::Module' => 'Description',
+ },
+ Description => gettext('This module display cached teletext pages from osdteletext-plugin.'),
Version => '0.95',
Date => '2007-08-14',
- Author => 'Andreas Brachold <vdr07 at deltab.de>',
- Preferences => {
+ Author => 'Andreas Brachold <vdr07 at deltab.de>',
+ Preferences => {
active => {
description => gettext('Activate this service'),
default => 'y',
type => 'confirm',
},
- dir => {
- description => gettext('Directory where the teletext files are be located'),
- default => '/vtx',
- type => 'dir',
- required => gettext('This is required!'),
- },
- cache => {
- description => gettext("Used cache system.\nChoose 'legacy' for the traditional one-file-per-page system.\nDefault is 'packed' for the one-file-for-a-few-pages system.\nVDR-osdteletext-Plugin\n'legacy' <= osdteletext-0.3.2 or 'packed' >= osdteletext-0.4.0"),
- default => 'packed',
- type => 'radio',
- required => gettext('This is required!'),
- choices => ['legacy','packed']
- },
- },
- Commands => {
- vtxpage => {
- description => gettext("Display the teletext page 'pagenumber'"),
- short => 'vt',
- callback => sub{ $self->page(@_) },
- },
- vtxchannel => {
- description => gettext("Channel for teletext actions 'cid'"),
- short => 'vc',
- callback => sub{ $self->channel(@_) },
- },
- vtxsearch => {
- description => gettext("Search for text inside teletext pages 'text'"),
- short => 'vs',
- callback => sub{ $self->search(@_) },
- },
- },
- };
- return $args;
-}
-
-################################################################################
-# Ctor
-sub new {
- my($class, %attr) = @_;
- my $self = {};
- bless($self, $class);
-
- # paths
- $self->{paths} = delete $attr{'-paths'};
-
- # who am I
- $self->{MOD} = $self->module;
-
- # all configvalues to $self without parents (important for ConfigModule)
- map {
+ dir => {
+ description => gettext('Directory where the teletext files are be located'),
+ default => '/vtx',
+ type => 'dir',
+ required => gettext('This is required!'),
+ },
+ cache => {
+ description => gettext("Used cache system.\nChoose 'legacy' for the traditional one-file-per-page system.\nDefault is 'packed' for the one-file-for-a-few-pages system.\nVDR-osdteletext-Plugin\n'legacy' <= osdteletext-0.3.2 or 'packed' >= osdteletext-0.4.0"),
+ default => 'packed',
+ type => 'radio',
+ required => gettext('This is required!'),
+ choices => ['legacy','packed']
+ },
+ },
+ Commands => {
+ vtxpage => {
+ description => gettext("Display the teletext page 'pagenumber'"),
+ short => 'vt',
+ callback => sub{ $self->page(@_) },
+ },
+ vtxchannel => {
+ description => gettext("Channel for teletext actions 'cid'"),
+ short => 'vc',
+ callback => sub{ $self->channel(@_) },
+ },
+ vtxsearch => {
+ description => gettext("Search for text inside teletext pages 'text'"),
+ short => 'vs',
+ callback => sub{ $self->search(@_) },
+ },
+ },
+ };
+ return $args;
+}
+
+################################################################################
+# Ctor
+sub new {
+ my($class, %attr) = @_;
+ my $self = {};
+ bless($self, $class);
+
+ # paths
+ $self->{paths} = delete $attr{'-paths'};
+
+ # who am I
+ $self->{MOD} = $self->module;
+
+ # all configvalues to $self without parents (important for ConfigModule)
+ map {
$self->{$_} = $attr{'-config'}->{$self->{MOD}->{Name}}->{$_};
$self->{$_} = $self->{MOD}->{Preferences}->{$_}->{default} unless($self->{$_});
- } keys %{$self->{MOD}->{Preferences}};
-
- # Try to use the Requirments
- map {
- eval "use $_";
- return panic("\nCan not load Module: $_\nPlease install this module on your System:\nperl -MCPAN -e 'install $_'") if($@);
- } keys %{$self->{MOD}->{Prereq}};
-
- return $self;
-}
-
-
-################################################################################
-# Find first usable channel
-sub findfirst {
-
- my $self = shift || return error ('No Object!');
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
-
- my $basedir = $self->{dir}
- || return $self->pagedump($console,gettext("directory is for modul vtx not registered!"),"");
-
- my $mod = main::getModule ('CHANNELS');
- my $channels =[];
-
- my $cache = $self->{cache} ||'packed';
- if ($cache ne 'packed') {
- foreach my $ch (@{$mod->ChannelArray ('Name')}) {
- if (-d $basedir.'/'.$ch->[1]) {
- return $self->channel ($watcher, $console,$ch->[1]);
- }
- }
- } else {
- foreach my $ch (@{$mod->ChannelArray ('Id')}) {
- if (-d $basedir.'/'.$ch->[0]) {
- return $self->channel ($watcher,$console,$ch->[1]);
- }
- }
- }
-}
-
-################################################################################
-# Callback "Channel choice"
-sub channel
-{
- my $self = shift || return error ('No Object!');
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $channel = shift || return $self->findfirst ($watcher, $console);
-
- my $basedir = $self->{dir} || return error ('No Base Directory defined !');
- my $cache = $self->{cache} || 'packed';
-
- my $mod = main::getModule ('CHANNELS');
-
- my $chandir = "";
- my $channelname = "";
-
- # Get ChannelID and channel's Name
- foreach my $ch (@{$mod->ChannelArray ('Name, Id')}) {
- if ($ch->[2] == $channel) {
- $channelname = $ch->[0];
- if ($cache eq 'packed') {
- $chandir = $ch->[1];
- } else {
- $chandir = $channel;
- }
- last;
- }
- }
-
-
- if ($channelname ne ""
- and $chandir ne ""
- and -d "$basedir/$chandir") {
-
- $self->{CHANNEL}= $channel;
- $self->{CHANNELDIR}= $chandir;
- {
- $self->{INDEX} = [];
- my @index;
- if ($cache eq 'packed') {
- find(
- sub{
- if($File::Find::name =~ /\d{3}s.vtx$/sig) {
- push(@index,GetPackedToc($File::Find::name));
- }
- },"$basedir/$chandir");
- } else {
- find(
- sub{
- if($File::Find::name =~ /\d{3}_\d{2}.vtx$/sig) {
- my ($page, $subpage)
- = $File::Find::name =~ /^.*(\d{3})_(\d{2}).*/si;
- if($page and $subpage) {
- my $found = 0;
- foreach my $p (@index) {
- if($p->[0] == $page) {
- $found = 1;
- push(@{$p->[1]},$subpage)
- if($subpage != 0);
- last;
- }
- }
- if ($found == 0) {
- push(@index,[$page, [$subpage] ]);
- }
- }
- }
- },"$basedir/$chandir");
- }
- if (scalar @index == 0) {
- $self->pagedump($console,sprintf(gettext("No data found for \'%s\'!"),$channelname),"");
- return;
- }
- # Seitenindex sortieren
- @{$self->{INDEX}} = sort { $a->[0] <=> $b->[0] } @index;
- # Subseitenindex sortieren
- foreach my $p (@{$self->{INDEX}}) {
- if (scalar @{$p->[1]} > 1) {
- my @tmp = sort { $a <=> $b } @{$p->[1]};
- @{$p->[1]} = @tmp;
- }
- }
- }
-
-# Dump PageIndex
-# foreach my $p (@{$self->{INDEX}}) {
-# my $dump = "Pages $p->[0]";
-# foreach my $s (@{$p->[1]}) {
-# $dump .= ", $s";
-# }
-# warn($dump);
-# }
-
- $console->message(sprintf(gettext("channel \'%s\' for modul vtx registered."),$channelname))
- if ($console->{TYP} ne 'HTML') ;
- } else {
- $self->pagedump($console,sprintf(gettext("No data found for \'%s\'!"),$channelname),"");
- return;
- }
- my $fpage = @{$self->{INDEX}}[0];# First Page on Index
- return $self->page ($watcher, $console,sprintf ("%03d_%02d", $fpage->[0],$fpage->[1]->[0]));
-}
-
-################################################################################
-# Callback "Teletextpage choice"
+ } keys %{$self->{MOD}->{Preferences}};
+
+ # Try to use the Requirments
+ map {
+ eval "use $_";
+ return panic("\nCan not load Module: $_\nPlease install this module on your System:\nperl -MCPAN -e 'install $_'") if($@);
+ } keys %{$self->{MOD}->{Prereq}};
+
+ return $self;
+}
+
+
+################################################################################
+# Find first usable channel
+sub findfirst {
+
+ my $self = shift || return error ('No Object!');
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+
+ my $basedir = $self->{dir}
+ || return $self->pagedump($console,gettext("directory is for modul vtx not registered!"),"");
+
+ my $mod = main::getModule ('CHANNELS');
+ my $channels =[];
+
+ my $cache = $self->{cache} ||'packed';
+ if ($cache ne 'packed') {
+ foreach my $ch (@{$mod->ChannelArray ('Name')}) {
+ if (-d $basedir.'/'.$ch->[1]) {
+ return $self->channel ($watcher, $console,$ch->[1]);
+ }
+ }
+ } else {
+ foreach my $ch (@{$mod->ChannelArray ('Id')}) {
+ if (-d $basedir.'/'.$ch->[0]) {
+ return $self->channel ($watcher,$console,$ch->[1]);
+ }
+ }
+ }
+}
+
+################################################################################
+# Callback "Channel choice"
+sub channel
+{
+ my $self = shift || return error ('No Object!');
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $channel = shift || return $self->findfirst ($watcher, $console);
+
+ my $basedir = $self->{dir} || return error ('No Base Directory defined !');
+ my $cache = $self->{cache} || 'packed';
+
+ my $mod = main::getModule ('CHANNELS');
+
+ my $chandir = "";
+ my $channelname = "";
+
+ # Get ChannelID and channel's Name
+ foreach my $ch (@{$mod->ChannelArray ('Name, Id')}) {
+ if ($ch->[2] == $channel) {
+ $channelname = $ch->[0];
+ if ($cache eq 'packed') {
+ $chandir = $ch->[1];
+ } else {
+ $chandir = $channel;
+ }
+ last;
+ }
+ }
+
+
+ if ($channelname ne ""
+ and $chandir ne ""
+ and -d "$basedir/$chandir") {
+
+ $self->{CHANNEL}= $channel;
+ $self->{CHANNELDIR}= $chandir;
+ {
+ $self->{INDEX} = [];
+ my @index;
+ if ($cache eq 'packed') {
+ find(
+ sub{
+ if($File::Find::name =~ /\d{3}s.vtx$/sig) {
+ push(@index,GetPackedToc($File::Find::name));
+ }
+ },"$basedir/$chandir");
+ } else {
+ find(
+ sub{
+ if($File::Find::name =~ /\d{3}_\d{2}.vtx$/sig) {
+ my ($page, $subpage)
+ = $File::Find::name =~ /^.*(\d{3})_(\d{2}).*/si;
+ if($page and $subpage) {
+ my $found = 0;
+ foreach my $p (@index) {
+ if($p->[0] == $page) {
+ $found = 1;
+ push(@{$p->[1]},$subpage)
+ if($subpage != 0);
+ last;
+ }
+ }
+ if ($found == 0) {
+ push(@index,[$page, [$subpage] ]);
+ }
+ }
+ }
+ },"$basedir/$chandir");
+ }
+ if (scalar @index == 0) {
+ $self->pagedump($console,sprintf(gettext("No data found for \'%s\'!"),$channelname),"");
+ return;
+ }
+ # Seitenindex sortieren
+ @{$self->{INDEX}} = sort { $a->[0] <=> $b->[0] } @index;
+ # Subseitenindex sortieren
+ foreach my $p (@{$self->{INDEX}}) {
+ if (scalar @{$p->[1]} > 1) {
+ my @tmp = sort { $a <=> $b } @{$p->[1]};
+ @{$p->[1]} = @tmp;
+ }
+ }
+ }
+
+# Dump PageIndex
+# foreach my $p (@{$self->{INDEX}}) {
+# my $dump = "Pages $p->[0]";
+# foreach my $s (@{$p->[1]}) {
+# $dump .= ", $s";
+# }
+# warn($dump);
+# }
+
+ $console->message(sprintf(gettext("channel \'%s\' for modul vtx registered."),$channelname))
+ if ($console->{TYP} ne 'HTML') ;
+ } else {
+ $self->pagedump($console,sprintf(gettext("No data found for \'%s\'!"),$channelname),"");
+ return;
+ }
+ my $fpage = @{$self->{INDEX}}[0];# First Page on Index
+ return $self->page ($watcher, $console,sprintf ("%03d_%02d", $fpage->[0],$fpage->[1]->[0]));
+}
+
+################################################################################
+# Callback "Teletextpage choice"
sub page {
- my $self = shift || return error ('No Object!');
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $page = shift || "";
- my $channel = $self->{CHANNEL} || return $self->findfirst ($watcher, $console);
- my $basedir = $self->{dir} || return error ('No Base Directory defined !');
- my $chandir = $self->{CHANNELDIR} || return error ('No CHANNEL');
- my $cache = $self->{cache} || 'packed';
-
- my @pp = split ('_', $page);
- if (scalar @pp == 0) {
- # First Page on Index
- my $fpage = @{$self->{INDEX}}[0];
- $pp[0] = sprintf("%3d",$fpage->[0]);
- $pp[1] = sprintf("%2d",$fpage->[1]->[0]);
- }
- elsif (scalar @pp == 1) {
- # First Subpage on Index
- $pp[1] = "00";
- foreach my $fpage (@{$self->{INDEX}}) {
- if($fpage->[0] == $pp[0]) {
- $pp[1] = sprintf("%2d",$fpage->[1]->[0]);
- last;
- }
- }
- }
- my $bHTML = ($console->{TYP} ne 'HTML')?0:1;
- my $result = $self->realpage($console, $pp[0], $pp[1],$bHTML);
-
- return 0 if($result eq "");
- return $self->pagedump($console,$result,$chandir);
-}
-
-################################################################################
-# Generate Message
-sub pagedump {
- my $self = shift || return error ('No Object!');
- my $console = shift || return error ('No Console');
- my $result = shift;
- my $chandir = shift;
-
- if ($console->{TYP} ne 'HTML') {
- return $console->message ($result);
- } else {
-
- my $charray =[];
- my $chsel = $self->{CHANNELDIR};
- my $cache = $self->{cache};
- my $basedir = $self->{dir};
- my $mod = main::getModule ('CHANNELS');
-
- my @chan = (@{$mod->ChannelArray ('Name, Id')});
- if ($cache ne 'packed') {
- foreach my $ch (@chan) {
- push (@$charray, [$ch->[0], $ch->[2]])
- if (-d $basedir.'/'.$ch->[2]) ; # Lookup /vtx/25/
- }
- } else {
- foreach my $ch (@chan){
- if (-d $basedir.'/'.$ch->[1]) { # Lookup /vtx/S19.2E-1-1101-28108/
- push (@$charray, [$ch->[0], $ch->[2]]);
- $chsel = $ch->[2]
- if ($ch->[1] eq $chandir) ;
- }
- }
- }
-
+ my $self = shift || return error ('No Object!');
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $page = shift || "";
+ my $channel = $self->{CHANNEL} || return $self->findfirst ($watcher, $console);
+ my $basedir = $self->{dir} || return error ('No Base Directory defined !');
+ my $chandir = $self->{CHANNELDIR} || return error ('No CHANNEL');
+ my $cache = $self->{cache} || 'packed';
+
+ my @pp = split ('_', $page);
+ if (scalar @pp == 0) {
+ # First Page on Index
+ my $fpage = @{$self->{INDEX}}[0];
+ $pp[0] = sprintf("%3d",$fpage->[0]);
+ $pp[1] = sprintf("%2d",$fpage->[1]->[0]);
+ }
+ elsif (scalar @pp == 1) {
+ # First Subpage on Index
+ $pp[1] = "00";
+ foreach my $fpage (@{$self->{INDEX}}) {
+ if($fpage->[0] == $pp[0]) {
+ $pp[1] = sprintf("%2d",$fpage->[1]->[0]);
+ last;
+ }
+ }
+ }
+ my $bHTML = ($console->{TYP} ne 'HTML')?0:1;
+ my $result = $self->realpage($console, $pp[0], $pp[1],$bHTML);
+
+ return 0 if($result eq "");
+ return $self->pagedump($console,$result,$chandir);
+}
+
+################################################################################
+# Generate Message
+sub pagedump {
+ my $self = shift || return error ('No Object!');
+ my $console = shift || return error ('No Console');
+ my $result = shift;
+ my $chandir = shift;
+
+ if ($console->{TYP} ne 'HTML') {
+ return $console->message ($result);
+ } else {
+
+ my $charray =[];
+ my $chsel = $self->{CHANNELDIR};
+ my $cache = $self->{cache};
+ my $basedir = $self->{dir};
+ my $mod = main::getModule ('CHANNELS');
+
+ my @chan = (@{$mod->ChannelArray ('Name, Id')});
+ if ($cache ne 'packed') {
+ foreach my $ch (@chan) {
+ push (@$charray, [$ch->[0], $ch->[2]])
+ if (-d $basedir.'/'.$ch->[2]) ; # Lookup /vtx/25/
+ }
+ } else {
+ foreach my $ch (@chan){
+ if (-d $basedir.'/'.$ch->[1]) { # Lookup /vtx/S19.2E-1-1101-28108/
+ push (@$charray, [$ch->[0], $ch->[2]]);
+ $chsel = $ch->[2]
+ if ($ch->[1] eq $chandir) ;
+ }
+ }
+ }
+
my @lines = $self->InsertPageLink($result);
- $self->NavigatePages();
- my $tmpldata =
- {
- channel => $chsel,
- channels => $charray,
- page => $self->{mainpage},
- subpage => $self->{subpage},
+ $self->NavigatePages();
+ my $tmpldata =
+ {
+ channel => $chsel,
+ channels => $charray,
+ page => $self->{mainpage},
+ subpage => $self->{subpage},
toppage => $self->{toppage},
- page_prev => $self->{page_prev},
- page_next => $self->{page_next},
- subpage_prev => $self->{subpage_prev},
- subpage_next => $self->{subpage_next}
+ page_prev => $self->{page_prev},
+ page_next => $self->{page_next},
+ subpage_prev => $self->{subpage_prev},
+ subpage_next => $self->{subpage_next}
};
- $console->{dontparsedData} = 1;
- return $console->vtx(\@lines, $tmpldata);
- }
- return 1;
-}
-
-################################################################################
-# Insert for HTML Pages, Link for other Pages
-sub InsertPageLink {
-
- my $self = shift;
+ $console->{dontparsedData} = 1;
+ return $console->vtx(\@lines, $tmpldata);
+ }
+ return 1;
+}
+
+################################################################################
+# Insert for HTML Pages, Link for other Pages
+sub InsertPageLink {
+
+ my $self = shift;
my $result = shift;
my @lines;
@@ -355,664 +355,664 @@ sub InsertPageLink {
push (@lines, $line);
}
return @lines;
-}
-
-################################################################################
-# Find next and prior Pages, used one HTML View
-sub NavigatePages {
- my $self = shift;
-
- my $mFound = 0;
+}
+
+################################################################################
+# Find next and prior Pages, used one HTML View
+sub NavigatePages {
+ my $self = shift;
+
+ my $mFound = 0;
my $sFound = 0;
- $self->{toppage} = 0;
- $self->{page_prev} = 0;
- $self->{page_next} = 0;
- $self->{subpage_prev} = 0;
- $self->{subpage_next} = 0;
-
- $self->{toppage} = $self->{INDEX}->[0][0] if ($self->{INDEX} && scalar ($self->{INDEX}));
-
-# Outer Mainpages-Loop##########################################################
- foreach my $p (@{$self->{INDEX}}) {
- if($mFound == 1) {
- $self->{page_next} = $p->[0];
- last;
- }
- if($p->[0] && $p->[0] == $self->{mainpage}) {
- $mFound = 1;
- if ($p->[1] && scalar @{$p->[1]} > 1) {
-# Inner Subpages-Loop###########################################################
- foreach my $s (@{$p->[1]}) {
- if($sFound == 1) {
- $self->{subpage_next} = sprintf ("%03d_%02d", $self->{mainpage},$s);
- last;
- }
- if($s == $self->{subpage}) {
- $sFound = 1;
- }
- if($sFound == 0) {
- $self->{subpage_prev} = sprintf ("%03d_%02d", $self->{mainpage},$s);
- }
- }
- if($sFound == 0) {
- $self->{subpage_prev} = 0;
- }
-# Inner Subpages-Loop###########################################################
- }
- }
- if($mFound == 0) {
- $self->{page_prev} = $p->[0];
- }
- }
- if($mFound == 0) {
- $self->{page_prev} = 0;
- }
-# Outer Mainpages-Loop##########################################################
-}
-
-################################################################################
-# Our internal real page deliverer
-sub realpage {
- my $self = shift || return error ('No Object!');
- my $console = shift || return error ('No Console!');
- my $mainpage= shift || return error ('No Page!');
- my $subpage = shift || return error ('No Subpage!');
- my $bHTML = shift;
-
- my $basedir = $self->{dir} || return error ('No directory is defined!');
- my $chandir = $self->{CHANNELDIR} || return error ('No CHANNEL');
- my $cache = $self->{cache} || 'packed';
-################################################################################
-# get filename
- my $filename;
- if ($cache eq 'packed') {
- # Build name /vtx/S19.2E-1-1101-28108/100s.vtx
- my $group = (int ($mainpage / 10)) *10;
- $filename = sprintf ("%s/%s/%03ds.vtx", $basedir, $chandir, $group);
- } else {
- # Build name /vtx/15/100_01.vtx
- $filename = sprintf ("%s/%s/%03d_%02d.vtx", $basedir, $chandir, $mainpage, $subpage);
- }
-################################################################################
-# Now open and read this file
- my $fh = FileHandle->new;
- if(!$fh->open($filename)) {
- $self->pagedump($console,gettext("The page could not be found!"),"");
- return "";
- }
-
- my $result = $self->readpage($console, $fh, $mainpage, $subpage, $bHTML);
- $fh->close();
- return $result;
-}
-
-################################################################################
-# Translation table for ASCII
-# Source - Bytelayout - vdr-plugin osdteletext-0.4.1/txtfont.c
-# Codingrule iso-8859-15
-my @tableascii = (
- ' ', # 0x20
- '!', # 0x21
- '"', # 0x22
- '#', # 0x23
- '$', # 0x24
- '%', # 0x25
- '&', # 0x26
- '\'', # 0x27
- '(', # 0x28
- ')', # 0x29
- '*', # 0x2A
- '+', # 0x2B
- ',', # 0x2C
- '-', # 0x2D
- '.', # 0x2E
- '/', # 0x2E
- '0', # 0x30
- '1', # 0x31
- '2', # 0x32
- '3', # 0x33
- '4', # 0x34
- '5', # 0x35
- '6', # 0x36
- '7', # 0x37
- '8', # 0x38
- '9', # 0x39
- ':', # 0x3A
- ';', # 0x3B
- '<', # 0x3C
- '=', # 0x3D
- '>', # 0x3E
- '?', # 0x3F
- '§', # 0x40
- 'A', # 0x41
- 'B', # 0x42
- 'C', # 0x43
- 'D', # 0x44
- 'E', # 0x45
- 'F', # 0x46
- 'G', # 0x47
- 'H', # 0x48
- 'I', # 0x49
- 'J', # 0x4A
- 'K', # 0x4B
- 'L', # 0x4C
- 'M', # 0x4D
- 'N', # 0x4E
- 'O', # 0x4F
- 'P', # 0x50
- 'Q', # 0x51
- 'R', # 0x52
- 'S', # 0x53
- 'T', # 0x54
- 'U', # 0x55
- 'V', # 0x56
- 'W', # 0x57
- 'X', # 0x58
- 'Y', # 0x59
- 'Z', # 0x5A
- 'Ä', # 0x5B
- 'Ö', # 0x5C
- 'Ü', # 0x5D
- '^', # 0x5E
- '_', # 0x5F
- '°', # 0x60
- 'a', # 0x61
- 'b', # 0x62
- 'c', # 0x63
- 'd', # 0x64
- 'e', # 0x65
- 'f', # 0x66
- 'g', # 0x67
- 'h', # 0x68
- 'i', # 0x69
- 'j', # 0x6A
- 'k', # 0x6B
- 'l', # 0x6C
- 'm', # 0x6D
- 'n', # 0x6E
- 'o', # 0x6F
- 'p', # 0x70
- 'q', # 0x71
- 'r', # 0x72
- 's', # 0x73
- 't', # 0x74
- 'u', # 0x75
- 'v', # 0x76
- 'w', # 0x77
- 'x', # 0x78
- 'y', # 0x79
- 'z', # 0x7A
- 'ä', # 0x7B
- 'ö', # 0x7C
- 'ü', # 0x7D
+ $self->{toppage} = 0;
+ $self->{page_prev} = 0;
+ $self->{page_next} = 0;
+ $self->{subpage_prev} = 0;
+ $self->{subpage_next} = 0;
+
+ $self->{toppage} = $self->{INDEX}->[0][0] if ($self->{INDEX} && scalar ($self->{INDEX}));
+
+# Outer Mainpages-Loop##########################################################
+ foreach my $p (@{$self->{INDEX}}) {
+ if($mFound == 1) {
+ $self->{page_next} = $p->[0];
+ last;
+ }
+ if($p->[0] && $p->[0] == $self->{mainpage}) {
+ $mFound = 1;
+ if ($p->[1] && scalar @{$p->[1]} > 1) {
+# Inner Subpages-Loop###########################################################
+ foreach my $s (@{$p->[1]}) {
+ if($sFound == 1) {
+ $self->{subpage_next} = sprintf ("%03d_%02d", $self->{mainpage},$s);
+ last;
+ }
+ if($s == $self->{subpage}) {
+ $sFound = 1;
+ }
+ if($sFound == 0) {
+ $self->{subpage_prev} = sprintf ("%03d_%02d", $self->{mainpage},$s);
+ }
+ }
+ if($sFound == 0) {
+ $self->{subpage_prev} = 0;
+ }
+# Inner Subpages-Loop###########################################################
+ }
+ }
+ if($mFound == 0) {
+ $self->{page_prev} = $p->[0];
+ }
+ }
+ if($mFound == 0) {
+ $self->{page_prev} = 0;
+ }
+# Outer Mainpages-Loop##########################################################
+}
+
+################################################################################
+# Our internal real page deliverer
+sub realpage {
+ my $self = shift || return error ('No Object!');
+ my $console = shift || return error ('No Console!');
+ my $mainpage= shift || return error ('No Page!');
+ my $subpage = shift || return error ('No Subpage!');
+ my $bHTML = shift;
+
+ my $basedir = $self->{dir} || return error ('No directory is defined!');
+ my $chandir = $self->{CHANNELDIR} || return error ('No CHANNEL');
+ my $cache = $self->{cache} || 'packed';
+################################################################################
+# get filename
+ my $filename;
+ if ($cache eq 'packed') {
+ # Build name /vtx/S19.2E-1-1101-28108/100s.vtx
+ my $group = (int ($mainpage / 10)) *10;
+ $filename = sprintf ("%s/%s/%03ds.vtx", $basedir, $chandir, $group);
+ } else {
+ # Build name /vtx/15/100_01.vtx
+ $filename = sprintf ("%s/%s/%03d_%02d.vtx", $basedir, $chandir, $mainpage, $subpage);
+ }
+################################################################################
+# Now open and read this file
+ my $fh = FileHandle->new;
+ if(!$fh->open($filename)) {
+ $self->pagedump($console,gettext("The page could not be found!"),"");
+ return "";
+ }
+
+ my $result = $self->readpage($console, $fh, $mainpage, $subpage, $bHTML);
+ $fh->close();
+ return $result;
+}
+
+################################################################################
+# Translation table for ASCII
+# Source - Bytelayout - vdr-plugin osdteletext-0.4.1/txtfont.c
+# Codingrule iso-8859-15
+my @tableascii = (
+ ' ', # 0x20
+ '!', # 0x21
+ '"', # 0x22
+ '#', # 0x23
+ '$', # 0x24
+ '%', # 0x25
+ '&', # 0x26
+ '\'', # 0x27
+ '(', # 0x28
+ ')', # 0x29
+ '*', # 0x2A
+ '+', # 0x2B
+ ',', # 0x2C
+ '-', # 0x2D
+ '.', # 0x2E
+ '/', # 0x2E
+ '0', # 0x30
+ '1', # 0x31
+ '2', # 0x32
+ '3', # 0x33
+ '4', # 0x34
+ '5', # 0x35
+ '6', # 0x36
+ '7', # 0x37
+ '8', # 0x38
+ '9', # 0x39
+ ':', # 0x3A
+ ';', # 0x3B
+ '<', # 0x3C
+ '=', # 0x3D
+ '>', # 0x3E
+ '?', # 0x3F
+ '§', # 0x40
+ 'A', # 0x41
+ 'B', # 0x42
+ 'C', # 0x43
+ 'D', # 0x44
+ 'E', # 0x45
+ 'F', # 0x46
+ 'G', # 0x47
+ 'H', # 0x48
+ 'I', # 0x49
+ 'J', # 0x4A
+ 'K', # 0x4B
+ 'L', # 0x4C
+ 'M', # 0x4D
+ 'N', # 0x4E
+ 'O', # 0x4F
+ 'P', # 0x50
+ 'Q', # 0x51
+ 'R', # 0x52
+ 'S', # 0x53
+ 'T', # 0x54
+ 'U', # 0x55
+ 'V', # 0x56
+ 'W', # 0x57
+ 'X', # 0x58
+ 'Y', # 0x59
+ 'Z', # 0x5A
+ 'Ä', # 0x5B
+ 'Ö', # 0x5C
+ 'Ü', # 0x5D
+ '^', # 0x5E
+ '_', # 0x5F
+ '°', # 0x60
+ 'a', # 0x61
+ 'b', # 0x62
+ 'c', # 0x63
+ 'd', # 0x64
+ 'e', # 0x65
+ 'f', # 0x66
+ 'g', # 0x67
+ 'h', # 0x68
+ 'i', # 0x69
+ 'j', # 0x6A
+ 'k', # 0x6B
+ 'l', # 0x6C
+ 'm', # 0x6D
+ 'n', # 0x6E
+ 'o', # 0x6F
+ 'p', # 0x70
+ 'q', # 0x71
+ 'r', # 0x72
+ 's', # 0x73
+ 't', # 0x74
+ 'u', # 0x75
+ 'v', # 0x76
+ 'w', # 0x77
+ 'x', # 0x78
+ 'y', # 0x79
+ 'z', # 0x7A
+ 'ä', # 0x7B
+ 'ö', # 0x7C
+ 'ü', # 0x7D
'ß', #/0x7E
- ' ', # Block 0x7F
- '@', # 0x80
- ' ', # 0x81
- ' ', # 0x82
- '£', # 0x83
- '$', # 0x84
- ' ', # 0x85
- ' ', # 0x86
- ' ', # 0x87
- ' ', # 0x88
- ' ', # 0x89
- ' ', # 0x8A
- ' ', # 0x8B
- ' ', # 0x8C
- ' ', # 0x8D
- ' ', # 0x8E
- '#', # 0x8F
- 'É', # 0x90
- 'é', # 0x91
- 'ä', # 0x92
- '#', # 0x93
- ' ', # 0x94
- ' ', # 0x95
- ' ', # 0x96
- ' ', # 0x97
- 'ö', # 0x98
- 'å', # 0x99
- 'ü', # 0x9A
- 'Ä', # 0x9B
- 'Ö', # 0x9C
- 'Å', # 0x9D
- 'Ü', # 0x9E
- '_', # 0x9F
- ' ', # 0x20a 0xA0
- ' ', # 0x21a 0xA1
- ' ', # 0x22a 0xA2
- ' ', # 0x23a 0xA3
- ' ', # 0x24a 0xA4
- ' ', # 0x25a 0xA5
- ' ', # 0x26a 0xA6
- ' ', # 0x27a 0xA7
- ' ', # 0x28a 0xA8
- ' ', # 0x29a 0xA9
- ' ', # 0x2Aa 0xAA
- ' ', # 0x2Ba 0xAB
- ' ', # 0x2Ca 0xAC
- ' ', # 0x2Da 0xAD
- ' ', # 0x2Ea 0xAE
- ' ', # 0x2Fa 0xAF
- ' ', # 0x30a 0xB0
- ' ', # 0x31a 0xB1
- ' ', # 0x32a 0xB2
- ' ', # 0x33a 0xB3
- ' ', # 0x34a 0xB4
- ' ', # 0x35a 0xB5
- ' ', # 0x36a 0xB6
- ' ', # 0x37a 0xB7
- ' ', # 0x38a 0xB8
- ' ', # 0x39a 0xB9
- ' ', # 0x3Aa 0xBA
- ' ', # 0x3Ba 0xBB
- ' ', # 0x3Ca 0xBC
- ' ', # 0x3Da 0xBD
- ' ', # 0x3Ea 0xBE
- ' ', # 0x3Fa 0xBF
- 'é', # 0xC0
- 'ù', # 0xC1
- 'à', # 0xC2
- '£', # 0xC3
- '$', # 0xC4
- 'ã', # 0xC5
- 'õ', # 0xC6
- ' ', # 0xC7
- 'ò', # 0xC8
- 'è', # 0xC9
- 'ì', # 0xCA
- '°', # 0xCB
- 'ç', # 0xCC
- ' ', # 0xCD
- ' ', # 0xCE
- '#', # 0xCF
- 'à', # 0xD0
- 'è', # 0xD1
- 'â', # 0xD2
- 'é', # 0xD3
- 'ï', # 0xD4
- 'Ã', # 0xD5
- 'Õ', # 0xD6
- 'Ç', # 0xD7
- 'ô', # 0xD8
- 'û', # 0xD9
- 'ç', # 0xDA
- 'ë', # 0xDB
- 'ê', # 0xDC
- 'ù', # 0xDD
- 'î', # 0xDE
- '#', # 0xDF
- '¡', # 0xE0
- '¿', # 0xE1
- 'ü', # 0xE2
- 'ç', # 0xE3
- '$', # 0xE4
- ' ', # 0xE5
- ' ', # 0xE6
- ' ', # 0xE7
- 'ñ', # 0xE8
- 'è', # 0xE9
- 'à', # 0xEA
- 'á', # 0xEB
- 'é', # 0xEC
- 'í', # 0xED
- 'ó', # 0xEE
- 'ú', # 0xEF
- 'Á', # 0xF0
- 'À', # 0xF1
- 'È', # 0xF2
- 'Í', # 0xF3
- 'Ï', # 0xF4
- 'Ó', # 0xF5
- 'Ò', # 0xF6
- 'Ú', # 0xF7
- 'æ', # 0xF8
- 'Æ', # 0xF9
- 'ð', # 0xFA
- ' ', # 0xFB
- 'ø', # 0xFC
- 'Ø', # 0xFD
- ' ', # 0xFE
- ' ', # 0xFF
- ' ', # 0x60a
- ' ', # 0x61a
- ' ', # 0x62a
- ' ', # 0x63a
- ' ', # 0x64a
- ' ', # 0x65a
- ' ', # 0x66a
- ' ', # 0x67a
- ' ', # 0x68a
- ' ', # 0x69a
- ' ', # 0x6Aa
- ' ', # 0x6Ba
- ' ', # 0x6Ca
- ' ', # 0x6Da
- ' ', # 0x6Ea
- ' ', # 0x6Fa
- ' ', # 0x70a
- ' ', # 0x71a
- ' ', # 0x72a
- ' ', # 0x73a
- ' ', # 0x74a
- ' ', # 0x75a
- ' ', # 0x76a
- ' ', # 0x77a
- ' ', # 0x78a
- ' ', # 0x79a
- ' ', # 0x7Aa
- ' ', # 0x7Ba
- ' ', # 0x7Ca
- ' ', # 0x7Da
- ' ', # 0x7Ea
- ' ' # 0x7Fa
-);
-
-################################################################################
-# Translation table for HTML
-my @tablehtml = (
- ' ', # 0x20
- '!', # 0x21
- '"', # 0x22
- '#', # 0x23
- '$', # 0x24
- '%', # 0x25
- '&amp;', # 0x26
- '\'', # 0x27
- '(', # 0x28
- ')', # 0x29
- '*', # 0x2A
- '+', # 0x2B
- ',', # 0x2C
- '-', # 0x2D
- '.', # 0x2E
- '/', # 0x2E
- '0', # 0x30
- '1', # 0x31
- '2', # 0x32
- '3', # 0x33
- '4', # 0x34
- '5', # 0x35
- '6', # 0x36
- '7', # 0x37
- '8', # 0x38
- '9', # 0x39
- ':', # 0x3A
- ';', # 0x3B
- '&lt;', # 0x3C
- '=', # 0x3D
- '&gt;', # 0x3E
- '?', # 0x3F
- '&sect;', # 0x40
- 'A', # 0x41
- 'B', # 0x42
- 'C', # 0x43
- 'D', # 0x44
- 'E', # 0x45
- 'F', # 0x46
- 'G', # 0x47
- 'H', # 0x48
- 'I', # 0x49
- 'J', # 0x4A
- 'K', # 0x4B
- 'L', # 0x4C
- 'M', # 0x4D
- 'N', # 0x4E
- 'O', # 0x4F
- 'P', # 0x50
- 'Q', # 0x51
- 'R', # 0x52
- 'S', # 0x53
- 'T', # 0x54
- 'U', # 0x55
- 'V', # 0x56
- 'W', # 0x57
- 'X', # 0x58
- 'Y', # 0x59
- 'Z', # 0x5A
- '&Auml;', # 0x5B
- '&Ouml;', # 0x5C
- '&Uuml;', # 0x5D
- '^', # 0x5E
- '_', # 0x5F
- '&deg;', # 0x60
- 'a', # 0x61
- 'b', # 0x62
- 'c', # 0x63
- 'd', # 0x64
- 'e', # 0x65
- 'f', # 0x66
- 'g', # 0x67
- 'h', # 0x68
- 'i', # 0x69
- 'j', # 0x6A
- 'k', # 0x6B
- 'l', # 0x6C
- 'm', # 0x6D
- 'n', # 0x6E
- 'o', # 0x6F
- 'p', # 0x70
- 'q', # 0x71
- 'r', # 0x72
- 's', # 0x73
- 't', # 0x74
- 'u', # 0x75
- 'v', # 0x76
- 'w', # 0x77
- 'x', # 0x78
- 'y', # 0x79
- 'z', # 0x7A
- '&auml;', # 0x7B
- '&ouml;', # 0x7C
- '&uuml;', # 0x7D
- '&szlig;', # 0x7E
- 'image-7F', # Block 0x7F
- '@', # 0x80
- '&ndash;', # 0x81
- '&frac14;', # 0x82 1/4
- '&pound;', # 0x83
- '$', # 0x84
- ' ', # 0x85 Taste Teletext (a)
- ' ', # 0x86 Taste Small
- ' ', # 0x87 Taste Hide
- ' ', # 0x88 ||
- '&frac34;', # 0x89 3/4
- '&divide;', # 0x8A
- '&larr;', # 0x8B <-
- '&frac12;', # 0x8C 1/2
- '&rarr;', # 0x8D ->
- '&uarr;', # 0x8E
- '#', # 0x8F
- '&Eacute;', # 0x90
- '&eacute;', # 0x91
- '&auml;', # 0x92
- '#', # 0x93
- '&curren;', # 0x94
- ' ', # 0x95 Taste Teletext (b)
- ' ', # 0x96 Taste
- ' ', # 0x97 Taste Big
- '&ouml;', # 0x98
- '&aring;', # 0x99
- '&uuml;', # 0x9A
- '&Auml;', # 0x9B
- '&Ouml;', # 0x9C
- '&Aring;', # 0x9D
- '&Uuml;', # 0x9E
- '_', # 0x9F
- 'image-20', # 0x20a 0xA0 # image-20 == whitespace
- 'image-21', # 0x21a 0xA1
- 'image-22', # 0x22a 0xA2
- 'image-23', # 0x23a 0xA3
- 'image-24', # 0x24a 0xA4
- 'image-25', # 0x25a 0xA5
- 'image-26', # 0x26a 0xA6
- 'image-27', # 0x27a 0xA7
- 'image-28', # 0x28a 0xA8
- 'image-29', # 0x29a 0xA9
- 'image-2A', # 0x2Aa 0xAA
- 'image-2B', # 0x2Ba 0xAB
- 'image-2C', # 0x2Ca 0xAC
- 'image-2D', # 0x2Da 0xAD
- 'image-2E', # 0x2Ea 0xAE
- 'image-2F', # 0x2Fa 0xAF
- 'image-30', # 0x30a 0xB0
- 'image-31', # 0x31a 0xB1
- 'image-32', # 0x32a 0xB2
- 'image-33', # 0x33a 0xB3
- 'image-34', # 0x34a 0xB4
- 'image-35', # 0x35a 0xB5
- 'image-36', # 0x36a 0xB6
- 'image-37', # 0x37a 0xB7
- 'image-38', # 0x38a 0xB8
- 'image-39', # 0x39a 0xB9
- 'image-3A', # 0x3Aa 0xBA
- 'image-3B', # 0x3Ba 0xBB
- 'image-3C', # 0x3Ca 0xBC
- 'image-3D', # 0x3Da 0xBD
- 'image-3E', # 0x3Ea 0xBE
- 'image-3F', # 0x3Fa 0xBF
- '&eacute;', # 0xC0
- '&ugrave;', # 0xC1
- '&agrave;', # 0xC2
- '&pound;', # 0xC3
- '$', # 0xC4
- '&atilde;', # 0xC5
- '&otilde;', # 0xC6
- '&bull;', # 0xC7
- '&ograve;', # 0xC8
- '&egrave;', # 0xC9
- '&igrave;', # 0xCA
- '&deg;', # 0xCB
- '&ccedil;', # 0xCC
- '&rarr;', # 0xCD
- '&uarr;', # 0xCE
- '#', # 0xCF
- '&agrave;', # 0xD0
- '&egrave;', # 0xD1
- '&acirc;', # 0xD2
- '&eacute;', # 0xD3
- '&iuml;', # 0xD4
- '&Atilde;', # 0xD5
- '&Otilde;', # 0xD6
- '&Ccedil;', # 0xD7
- '&ocirc;', # 0xD8
- '&ucirc;', # 0xD9
- '&ccedil;', # 0xDA
- '&euml;', # 0xDB
- '&ecirc;', # 0xDC
- '&ugrave;', # 0xDD
- '&icirc;', # 0xDE
- '#', # 0xDF
- '&iexcl;', # 0xE0
- '&iquest;', # 0xE1
- '&uuml;', # 0xE2
- '&ccedil;', # 0xE3
- '$', # 0xE4
- ' ', # 0xE5 a mit unterstrich
- ' ', # 0xE6 o mit unterstrich
- '&Ntilde;', # 0xE7
- '&ntilde;', # 0xE8
- '&egrave;', # 0xE9
- '&agrave;', # 0xEA
- '&aacute;', # 0xEB
- '&eacute;', # 0xEC
- '&iacute;', # 0xED
- '&oacute;', # 0xEE
- '&uacute;', # 0xEF
- '&Aacute;', # 0xF0
- '&Agrave;', # 0xF1
- '&Egrave;', # 0xF2
- '&Iacute;', # 0xF3
- '&Iuml;', # 0xF4
- '&Oacute;', # 0xF5
- '&Ograve;', # 0xF6
- '&Uacute;', # 0xF7
- '&aelig;', # 0xF8
- '&AElig;', # 0xF9
- '&eth;', # 0xFA
- '&ETH;', # 0xFB
- '&oslash;', # 0xFC
- '&Oslash;', # 0xFD
- '&thorn;', # 0xFE
- '&THORN;', # 0xFF
- 'image-60', # 0x60a
- 'image-61', # 0x61a
- 'image-62', # 0x62a
- 'image-63', # 0x63a
- 'image-64', # 0x64a
- 'image-65', # 0x65a
- 'image-66', # 0x66a
- 'image-67', # 0x67a
- 'image-68', # 0x68a
- 'image-69', # 0x69a
- 'image-6A', # 0x6Aa
- 'image-6B', # 0x6Ba
- 'image-6C', # 0x6Ca
- 'image-6D', # 0x6Da
- 'image-6E', # 0x6Ea
- 'image-6F', # 0x6Fa
- 'image-70', # 0x70a
- 'image-71', # 0x71a
- 'image-72', # 0x72a
- 'image-73', # 0x73a
- 'image-74', # 0x74a
- 'image-75', # 0x75a
- 'image-76', # 0x76a
- 'image-77', # 0x77a
- 'image-78', # 0x78a
- 'image-79', # 0x79a
- 'image-7A', # 0x7Aa
- 'image-7B', # 0x7Ba
- 'image-7C', # 0x7Ca
- 'image-7D', # 0x7Da
- 'image-7E', # 0x7Ea
- 'image-7F' # 0x7Fa
-);
-
-################################################################################
-# Color table
-my @colors = (
- "black", "red", "green", "yellow",
- "blue", "magenta", "cyan", "white"
-);
-
-################################################################################
-# Translation unpacked bytes to text
-sub translate {
-
- my $self=shift;
- my $bHTML=shift;
- my $c=shift;
- my $graph=shift;
- my $double=shift;
- my $sepgraph=shift;
- my $fg=shift;
- my $bg=shift;
- $c = int($c);
- if ($graph == 1) {
- if (($c>=0x20) and ($c<=0x3F)) { $c += 0x80; }
- elsif (($c>=0x60) and ($c<=0x7F)) { $c += 0xA0; }
- }
- $c -= 0x20;
- if($bHTML == 1) {
- my $result;
-
- if ($fg != $self->{ofg} or $bg != $self->{obg}) {
- if ($self->{ofg} != -1 or $self->{obg} != -1) {
- $result .= "</font>";
- }
- $result .= sprintf("<font style=\"color:%s;background-color:%s;\">",$colors[$fg],$colors[$bg]);
-
- $self->{ofg} = $fg;
- $self->{obg} = $bg;
- }
- if($c < 0 or $c > 256) {
- $result .= '&nbsp;';
- } else {
+ ' ', # Block 0x7F
+ '@', # 0x80
+ ' ', # 0x81
+ ' ', # 0x82
+ '£', # 0x83
+ '$', # 0x84
+ ' ', # 0x85
+ ' ', # 0x86
+ ' ', # 0x87
+ ' ', # 0x88
+ ' ', # 0x89
+ ' ', # 0x8A
+ ' ', # 0x8B
+ ' ', # 0x8C
+ ' ', # 0x8D
+ ' ', # 0x8E
+ '#', # 0x8F
+ 'É', # 0x90
+ 'é', # 0x91
+ 'ä', # 0x92
+ '#', # 0x93
+ ' ', # 0x94
+ ' ', # 0x95
+ ' ', # 0x96
+ ' ', # 0x97
+ 'ö', # 0x98
+ 'å', # 0x99
+ 'ü', # 0x9A
+ 'Ä', # 0x9B
+ 'Ö', # 0x9C
+ 'Å', # 0x9D
+ 'Ü', # 0x9E
+ '_', # 0x9F
+ ' ', # 0x20a 0xA0
+ ' ', # 0x21a 0xA1
+ ' ', # 0x22a 0xA2
+ ' ', # 0x23a 0xA3
+ ' ', # 0x24a 0xA4
+ ' ', # 0x25a 0xA5
+ ' ', # 0x26a 0xA6
+ ' ', # 0x27a 0xA7
+ ' ', # 0x28a 0xA8
+ ' ', # 0x29a 0xA9
+ ' ', # 0x2Aa 0xAA
+ ' ', # 0x2Ba 0xAB
+ ' ', # 0x2Ca 0xAC
+ ' ', # 0x2Da 0xAD
+ ' ', # 0x2Ea 0xAE
+ ' ', # 0x2Fa 0xAF
+ ' ', # 0x30a 0xB0
+ ' ', # 0x31a 0xB1
+ ' ', # 0x32a 0xB2
+ ' ', # 0x33a 0xB3
+ ' ', # 0x34a 0xB4
+ ' ', # 0x35a 0xB5
+ ' ', # 0x36a 0xB6
+ ' ', # 0x37a 0xB7
+ ' ', # 0x38a 0xB8
+ ' ', # 0x39a 0xB9
+ ' ', # 0x3Aa 0xBA
+ ' ', # 0x3Ba 0xBB
+ ' ', # 0x3Ca 0xBC
+ ' ', # 0x3Da 0xBD
+ ' ', # 0x3Ea 0xBE
+ ' ', # 0x3Fa 0xBF
+ 'é', # 0xC0
+ 'ù', # 0xC1
+ 'à', # 0xC2
+ '£', # 0xC3
+ '$', # 0xC4
+ 'ã', # 0xC5
+ 'õ', # 0xC6
+ ' ', # 0xC7
+ 'ò', # 0xC8
+ 'è', # 0xC9
+ 'ì', # 0xCA
+ '°', # 0xCB
+ 'ç', # 0xCC
+ ' ', # 0xCD
+ ' ', # 0xCE
+ '#', # 0xCF
+ 'à', # 0xD0
+ 'è', # 0xD1
+ 'â', # 0xD2
+ 'é', # 0xD3
+ 'ï', # 0xD4
+ 'Ã', # 0xD5
+ 'Õ', # 0xD6
+ 'Ç', # 0xD7
+ 'ô', # 0xD8
+ 'û', # 0xD9
+ 'ç', # 0xDA
+ 'ë', # 0xDB
+ 'ê', # 0xDC
+ 'ù', # 0xDD
+ 'î', # 0xDE
+ '#', # 0xDF
+ '¡', # 0xE0
+ '¿', # 0xE1
+ 'ü', # 0xE2
+ 'ç', # 0xE3
+ '$', # 0xE4
+ ' ', # 0xE5
+ ' ', # 0xE6
+ ' ', # 0xE7
+ 'ñ', # 0xE8
+ 'è', # 0xE9
+ 'à', # 0xEA
+ 'á', # 0xEB
+ 'é', # 0xEC
+ 'í', # 0xED
+ 'ó', # 0xEE
+ 'ú', # 0xEF
+ 'Á', # 0xF0
+ 'À', # 0xF1
+ 'È', # 0xF2
+ 'Í', # 0xF3
+ 'Ï', # 0xF4
+ 'Ó', # 0xF5
+ 'Ò', # 0xF6
+ 'Ú', # 0xF7
+ 'æ', # 0xF8
+ 'Æ', # 0xF9
+ 'ð', # 0xFA
+ ' ', # 0xFB
+ 'ø', # 0xFC
+ 'Ø', # 0xFD
+ ' ', # 0xFE
+ ' ', # 0xFF
+ ' ', # 0x60a
+ ' ', # 0x61a
+ ' ', # 0x62a
+ ' ', # 0x63a
+ ' ', # 0x64a
+ ' ', # 0x65a
+ ' ', # 0x66a
+ ' ', # 0x67a
+ ' ', # 0x68a
+ ' ', # 0x69a
+ ' ', # 0x6Aa
+ ' ', # 0x6Ba
+ ' ', # 0x6Ca
+ ' ', # 0x6Da
+ ' ', # 0x6Ea
+ ' ', # 0x6Fa
+ ' ', # 0x70a
+ ' ', # 0x71a
+ ' ', # 0x72a
+ ' ', # 0x73a
+ ' ', # 0x74a
+ ' ', # 0x75a
+ ' ', # 0x76a
+ ' ', # 0x77a
+ ' ', # 0x78a
+ ' ', # 0x79a
+ ' ', # 0x7Aa
+ ' ', # 0x7Ba
+ ' ', # 0x7Ca
+ ' ', # 0x7Da
+ ' ', # 0x7Ea
+ ' ' # 0x7Fa
+);
+
+################################################################################
+# Translation table for HTML
+my @tablehtml = (
+ ' ', # 0x20
+ '!', # 0x21
+ '"', # 0x22
+ '#', # 0x23
+ '$', # 0x24
+ '%', # 0x25
+ '&amp;', # 0x26
+ '\'', # 0x27
+ '(', # 0x28
+ ')', # 0x29
+ '*', # 0x2A
+ '+', # 0x2B
+ ',', # 0x2C
+ '-', # 0x2D
+ '.', # 0x2E
+ '/', # 0x2E
+ '0', # 0x30
+ '1', # 0x31
+ '2', # 0x32
+ '3', # 0x33
+ '4', # 0x34
+ '5', # 0x35
+ '6', # 0x36
+ '7', # 0x37
+ '8', # 0x38
+ '9', # 0x39
+ ':', # 0x3A
+ ';', # 0x3B
+ '&lt;', # 0x3C
+ '=', # 0x3D
+ '&gt;', # 0x3E
+ '?', # 0x3F
+ '&sect;', # 0x40
+ 'A', # 0x41
+ 'B', # 0x42
+ 'C', # 0x43
+ 'D', # 0x44
+ 'E', # 0x45
+ 'F', # 0x46
+ 'G', # 0x47
+ 'H', # 0x48
+ 'I', # 0x49
+ 'J', # 0x4A
+ 'K', # 0x4B
+ 'L', # 0x4C
+ 'M', # 0x4D
+ 'N', # 0x4E
+ 'O', # 0x4F
+ 'P', # 0x50
+ 'Q', # 0x51
+ 'R', # 0x52
+ 'S', # 0x53
+ 'T', # 0x54
+ 'U', # 0x55
+ 'V', # 0x56
+ 'W', # 0x57
+ 'X', # 0x58
+ 'Y', # 0x59
+ 'Z', # 0x5A
+ '&Auml;', # 0x5B
+ '&Ouml;', # 0x5C
+ '&Uuml;', # 0x5D
+ '^', # 0x5E
+ '_', # 0x5F
+ '&deg;', # 0x60
+ 'a', # 0x61
+ 'b', # 0x62
+ 'c', # 0x63
+ 'd', # 0x64
+ 'e', # 0x65
+ 'f', # 0x66
+ 'g', # 0x67
+ 'h', # 0x68
+ 'i', # 0x69
+ 'j', # 0x6A
+ 'k', # 0x6B
+ 'l', # 0x6C
+ 'm', # 0x6D
+ 'n', # 0x6E
+ 'o', # 0x6F
+ 'p', # 0x70
+ 'q', # 0x71
+ 'r', # 0x72
+ 's', # 0x73
+ 't', # 0x74
+ 'u', # 0x75
+ 'v', # 0x76
+ 'w', # 0x77
+ 'x', # 0x78
+ 'y', # 0x79
+ 'z', # 0x7A
+ '&auml;', # 0x7B
+ '&ouml;', # 0x7C
+ '&uuml;', # 0x7D
+ '&szlig;', # 0x7E
+ 'image-7F', # Block 0x7F
+ '@', # 0x80
+ '&ndash;', # 0x81
+ '&frac14;', # 0x82 1/4
+ '&pound;', # 0x83
+ '$', # 0x84
+ ' ', # 0x85 Taste Teletext (a)
+ ' ', # 0x86 Taste Small
+ ' ', # 0x87 Taste Hide
+ ' ', # 0x88 ||
+ '&frac34;', # 0x89 3/4
+ '&divide;', # 0x8A
+ '&larr;', # 0x8B <-
+ '&frac12;', # 0x8C 1/2
+ '&rarr;', # 0x8D ->
+ '&uarr;', # 0x8E
+ '#', # 0x8F
+ '&Eacute;', # 0x90
+ '&eacute;', # 0x91
+ '&auml;', # 0x92
+ '#', # 0x93
+ '&curren;', # 0x94
+ ' ', # 0x95 Taste Teletext (b)
+ ' ', # 0x96 Taste
+ ' ', # 0x97 Taste Big
+ '&ouml;', # 0x98
+ '&aring;', # 0x99
+ '&uuml;', # 0x9A
+ '&Auml;', # 0x9B
+ '&Ouml;', # 0x9C
+ '&Aring;', # 0x9D
+ '&Uuml;', # 0x9E
+ '_', # 0x9F
+ 'image-20', # 0x20a 0xA0 # image-20 == whitespace
+ 'image-21', # 0x21a 0xA1
+ 'image-22', # 0x22a 0xA2
+ 'image-23', # 0x23a 0xA3
+ 'image-24', # 0x24a 0xA4
+ 'image-25', # 0x25a 0xA5
+ 'image-26', # 0x26a 0xA6
+ 'image-27', # 0x27a 0xA7
+ 'image-28', # 0x28a 0xA8
+ 'image-29', # 0x29a 0xA9
+ 'image-2A', # 0x2Aa 0xAA
+ 'image-2B', # 0x2Ba 0xAB
+ 'image-2C', # 0x2Ca 0xAC
+ 'image-2D', # 0x2Da 0xAD
+ 'image-2E', # 0x2Ea 0xAE
+ 'image-2F', # 0x2Fa 0xAF
+ 'image-30', # 0x30a 0xB0
+ 'image-31', # 0x31a 0xB1
+ 'image-32', # 0x32a 0xB2
+ 'image-33', # 0x33a 0xB3
+ 'image-34', # 0x34a 0xB4
+ 'image-35', # 0x35a 0xB5
+ 'image-36', # 0x36a 0xB6
+ 'image-37', # 0x37a 0xB7
+ 'image-38', # 0x38a 0xB8
+ 'image-39', # 0x39a 0xB9
+ 'image-3A', # 0x3Aa 0xBA
+ 'image-3B', # 0x3Ba 0xBB
+ 'image-3C', # 0x3Ca 0xBC
+ 'image-3D', # 0x3Da 0xBD
+ 'image-3E', # 0x3Ea 0xBE
+ 'image-3F', # 0x3Fa 0xBF
+ '&eacute;', # 0xC0
+ '&ugrave;', # 0xC1
+ '&agrave;', # 0xC2
+ '&pound;', # 0xC3
+ '$', # 0xC4
+ '&atilde;', # 0xC5
+ '&otilde;', # 0xC6
+ '&bull;', # 0xC7
+ '&ograve;', # 0xC8
+ '&egrave;', # 0xC9
+ '&igrave;', # 0xCA
+ '&deg;', # 0xCB
+ '&ccedil;', # 0xCC
+ '&rarr;', # 0xCD
+ '&uarr;', # 0xCE
+ '#', # 0xCF
+ '&agrave;', # 0xD0
+ '&egrave;', # 0xD1
+ '&acirc;', # 0xD2
+ '&eacute;', # 0xD3
+ '&iuml;', # 0xD4
+ '&Atilde;', # 0xD5
+ '&Otilde;', # 0xD6
+ '&Ccedil;', # 0xD7
+ '&ocirc;', # 0xD8
+ '&ucirc;', # 0xD9
+ '&ccedil;', # 0xDA
+ '&euml;', # 0xDB
+ '&ecirc;', # 0xDC
+ '&ugrave;', # 0xDD
+ '&icirc;', # 0xDE
+ '#', # 0xDF
+ '&iexcl;', # 0xE0
+ '&iquest;', # 0xE1
+ '&uuml;', # 0xE2
+ '&ccedil;', # 0xE3
+ '$', # 0xE4
+ ' ', # 0xE5 a mit unterstrich
+ ' ', # 0xE6 o mit unterstrich
+ '&Ntilde;', # 0xE7
+ '&ntilde;', # 0xE8
+ '&egrave;', # 0xE9
+ '&agrave;', # 0xEA
+ '&aacute;', # 0xEB
+ '&eacute;', # 0xEC
+ '&iacute;', # 0xED
+ '&oacute;', # 0xEE
+ '&uacute;', # 0xEF
+ '&Aacute;', # 0xF0
+ '&Agrave;', # 0xF1
+ '&Egrave;', # 0xF2
+ '&Iacute;', # 0xF3
+ '&Iuml;', # 0xF4
+ '&Oacute;', # 0xF5
+ '&Ograve;', # 0xF6
+ '&Uacute;', # 0xF7
+ '&aelig;', # 0xF8
+ '&AElig;', # 0xF9
+ '&eth;', # 0xFA
+ '&ETH;', # 0xFB
+ '&oslash;', # 0xFC
+ '&Oslash;', # 0xFD
+ '&thorn;', # 0xFE
+ '&THORN;', # 0xFF
+ 'image-60', # 0x60a
+ 'image-61', # 0x61a
+ 'image-62', # 0x62a
+ 'image-63', # 0x63a
+ 'image-64', # 0x64a
+ 'image-65', # 0x65a
+ 'image-66', # 0x66a
+ 'image-67', # 0x67a
+ 'image-68', # 0x68a
+ 'image-69', # 0x69a
+ 'image-6A', # 0x6Aa
+ 'image-6B', # 0x6Ba
+ 'image-6C', # 0x6Ca
+ 'image-6D', # 0x6Da
+ 'image-6E', # 0x6Ea
+ 'image-6F', # 0x6Fa
+ 'image-70', # 0x70a
+ 'image-71', # 0x71a
+ 'image-72', # 0x72a
+ 'image-73', # 0x73a
+ 'image-74', # 0x74a
+ 'image-75', # 0x75a
+ 'image-76', # 0x76a
+ 'image-77', # 0x77a
+ 'image-78', # 0x78a
+ 'image-79', # 0x79a
+ 'image-7A', # 0x7Aa
+ 'image-7B', # 0x7Ba
+ 'image-7C', # 0x7Ca
+ 'image-7D', # 0x7Da
+ 'image-7E', # 0x7Ea
+ 'image-7F' # 0x7Fa
+);
+
+################################################################################
+# Color table
+my @colors = (
+ "black", "red", "green", "yellow",
+ "blue", "magenta", "cyan", "white"
+);
+
+################################################################################
+# Translation unpacked bytes to text
+sub translate {
+
+ my $self=shift;
+ my $bHTML=shift;
+ my $c=shift;
+ my $graph=shift;
+ my $double=shift;
+ my $sepgraph=shift;
+ my $fg=shift;
+ my $bg=shift;
+ $c = int($c);
+ if ($graph == 1) {
+ if (($c>=0x20) and ($c<=0x3F)) { $c += 0x80; }
+ elsif (($c>=0x60) and ($c<=0x7F)) { $c += 0xA0; }
+ }
+ $c -= 0x20;
+ if($bHTML == 1) {
+ my $result;
+
+ if ($fg != $self->{ofg} or $bg != $self->{obg}) {
+ if ($self->{ofg} != -1 or $self->{obg} != -1) {
+ $result .= "</font>";
+ }
+ $result .= sprintf("<font style=\"color:%s;background-color:%s;\">",$colors[$fg],$colors[$bg]);
+
+ $self->{ofg} = $fg;
+ $self->{obg} = $bg;
+ }
+ if($c < 0 or $c > 256) {
+ $result .= '&nbsp;';
+ } else {
my $h .= $tablehtml[$c];
$h =~ s/ /"&nbsp;"/eg;
- $result .= $h;
+ $result .= $h;
if ($graph == 1 || $c == 0x5f) #Block 0x5f = 0x7f - 0x20
{
my $pre = "<img class=\"vtx\" src=\"vtximages/";
@@ -1020,341 +1020,341 @@ sub translate {
my $post = ".gif\" alt=\"\" title=\"\" />&nbsp;";
# set <img class="vtx" class="vtx" src="vtximages/black21.gif" alt="" title="">
# vtx-image are locate inside skin folder
- $result =~ s/(image)\-(.+)/$pre.$color.$2.$post/eg;
+ $result =~ s/(image)\-(.+)/$pre.$color.$2.$post/eg;
}
- }
- return $result;
- } else {
- return ' ' if($c < 0 or $c > 256);
- return $tableascii[$c];
- }
-}
-################################################################################
-# close text line
-sub endline {
- my $self=shift;
- my $bHTML=shift;
- my $result = "";
- $result .= "</font><br />" if($bHTML);
- $result .= "\n";
- return $result;
-}
-
-################################################################################
-# Read page which open from filehandle
-sub readpage {
- my $self=shift;
- my $console=shift;
- my $fh=shift;
- my $mainpage=shift;
- my $subpage=shift;
- my $bHTML = shift;
- my $cache = $self->{cache} || 'packed';
-
-# Seek inside packed file
- if ($cache eq 'packed') {
- # Parse TOC
- #
- # 8x[MAIN,SUB a 2x4byte],
- # 8x[PAGE a 972byte],
- # 8x[MAIN,SUB a 2x4byte],
- # 8x[PAGE a 972byte]
- #
- my $tocbuf;
- my $notfound = 1;
- while($notfound == 1) {
- if($fh->read($tocbuf, 4*2*8) ne 64) {
- $self->pagedump($console,gettext("The page could not readed!"),"");
- return "";
- }
- my @toc = unpack( "i*", $tocbuf);
- my $n = 0;
- for (;$n < 8 and $notfound == 1; ++$n ) {
- my $mpage = int(sprintf ("%X",@toc[$n*2]));
- my $spage = int(sprintf ("%X",@toc[($n*2)+1]));
- # Check for last toc entry 0/0
- if($mpage == 0 and $spage == 0) {
- $self->pagedump($console,gettext("The page could not be found!"),"");
- return "";
- }
- # Look for toc entry same wanted page
- if($mpage == $mainpage) {
- if(($spage == $subpage )
- or ($subpage <= 1 and $spage <= 1)) {
-
- $self->{mainpage} = $mpage;
- $self->{subpage} = $spage;
-
- $notfound = 0;
- }
- }
- }
- --$n if($notfound == 0);
+ }
+ return $result;
+ } else {
+ return ' ' if($c < 0 or $c > 256);
+ return $tableascii[$c];
+ }
+}
+################################################################################
+# close text line
+sub endline {
+ my $self=shift;
+ my $bHTML=shift;
+ my $result = "";
+ $result .= "</font><br />" if($bHTML);
+ $result .= "\n";
+ return $result;
+}
+
+################################################################################
+# Read page which open from filehandle
+sub readpage {
+ my $self=shift;
+ my $console=shift;
+ my $fh=shift;
+ my $mainpage=shift;
+ my $subpage=shift;
+ my $bHTML = shift;
+ my $cache = $self->{cache} || 'packed';
+
+# Seek inside packed file
+ if ($cache eq 'packed') {
+ # Parse TOC
+ #
+ # 8x[MAIN,SUB a 2x4byte],
+ # 8x[PAGE a 972byte],
+ # 8x[MAIN,SUB a 2x4byte],
+ # 8x[PAGE a 972byte]
+ #
+ my $tocbuf;
+ my $notfound = 1;
+ while($notfound == 1) {
+ if($fh->read($tocbuf, 4*2*8) ne 64) {
+ $self->pagedump($console,gettext("The page could not readed!"),"");
+ return "";
+ }
+ my @toc = unpack( "i*", $tocbuf);
+ my $n = 0;
+ for (;$n < 8 and $notfound == 1; ++$n ) {
+ my $mpage = int(sprintf ("%X",@toc[$n*2]));
+ my $spage = int(sprintf ("%X",@toc[($n*2)+1]));
+ # Check for last toc entry 0/0
+ if($mpage == 0 and $spage == 0) {
+ $self->pagedump($console,gettext("The page could not be found!"),"");
+ return "";
+ }
+ # Look for toc entry same wanted page
+ if($mpage == $mainpage) {
+ if(($spage == $subpage )
+ or ($subpage <= 1 and $spage <= 1)) {
+
+ $self->{mainpage} = $mpage;
+ $self->{subpage} = $spage;
+
+ $notfound = 0;
+ }
+ }
+ }
+ --$n if($notfound == 0);
# Skip unwanted Pages
- if(0 == $fh->seek((972*$n), 1)) {
- $self->pagedump($console,gettext("The page could not readed!"),"");
- return "";
- }
- }
- } else {
- $self->{mainpage} = $mainpage;
- $self->{subpage} = $subpage;
- }
-
-# Read page now
- my $packed;
- if($fh->read($packed, 972) ne 972) {
- $self->pagedump($console,gettext("The page could not readed!"),"");
- return "";
- }
- my $result = "";
- $result .= "<p class=\"vtx\">\n" if($bHTML);
-
- my @buf = unpack( "C*", $packed);
-
- my $n = 9 + 1 + 2; #Index, skip irgendwas davor, Language, irgendwas wieder
- my $flash=0;
- my $double=0;
- my $hidden=0; #hidden = verdeckt!!!
- my $sepgraph=0;
- my $hold=0;
- my $graph=0;
- my $skipnextline=0;
- my $lc=0x20;
-
- my $fg = 7;
- my $bg = 0;
- for (my $y=0;$y<24;$y++) {
-
- $flash=0;
- $double=0;
- $hidden=0; #hidden = verdeckt!!!
- $sepgraph=0;
- $hold=0;
- $graph=0;
- $skipnextline=0;
- $lc=0x20;
-
- $fg = 7;
- $bg = 0;
- $self->{ofg} = -1;
- $self->{obg} = -1;
-
- for (my $x=0;$x<40;++$x,++$n)
+ if(0 == $fh->seek((972*$n), 1)) {
+ $self->pagedump($console,gettext("The page could not readed!"),"");
+ return "";
+ }
+ }
+ } else {
+ $self->{mainpage} = $mainpage;
+ $self->{subpage} = $subpage;
+ }
+
+# Read page now
+ my $packed;
+ if($fh->read($packed, 972) ne 972) {
+ $self->pagedump($console,gettext("The page could not readed!"),"");
+ return "";
+ }
+ my $result = "";
+ $result .= "<p class=\"vtx\">\n" if($bHTML);
+
+ my @buf = unpack( "C*", $packed);
+
+ my $n = 9 + 1 + 2; #Index, skip irgendwas davor, Language, irgendwas wieder
+ my $flash=0;
+ my $double=0;
+ my $hidden=0; #hidden = verdeckt!!!
+ my $sepgraph=0;
+ my $hold=0;
+ my $graph=0;
+ my $skipnextline=0;
+ my $lc=0x20;
+
+ my $fg = 7;
+ my $bg = 0;
+ for (my $y=0;$y<24;$y++) {
+
+ $flash=0;
+ $double=0;
+ $hidden=0; #hidden = verdeckt!!!
+ $sepgraph=0;
+ $hold=0;
+ $graph=0;
+ $skipnextline=0;
+ $lc=0x20;
+
+ $fg = 7;
+ $bg = 0;
+ $self->{ofg} = -1;
+ $self->{obg} = -1;
+
+ for (my $x=0;$x<40;++$x,++$n)
{
# $result .= sprintf("<!-- %2x -->",$buf[$n])
# if($bHTML);
-
- my $c=int($buf[$n] & 0x7F); #Parity Bit ist uninteressant!
-
- if (($y==0)&&($x<8)) { # Die Daten sind uninteressant zur Anzeige!
- $c = 0x20;
- }
-
+
+ my $c=int($buf[$n] & 0x7F); #Parity Bit ist uninteressant!
+
+ if (($y==0)&&($x<8)) { # Die Daten sind uninteressant zur Anzeige!
+ $c = 0x20;
+ }
+
if( $c >= 0x00 and $c <= 0x07 ) {
$lc=0x20
if($graph);
- $hidden= 0;
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
- $graph= 0;
- $fg = int($c);
-
- } elsif( $c == 0x08 ) { # Blinken einschalten (flashing)
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
- $flash= 1;
-
- } elsif( $c == 0x09 ) { # Blinken ausschalten (steady)
- $flash= 0;
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
- } elsif( $c == 0x0A ) { # end box (nicht benutzt)
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x0B ) { # start box (nicht benutzt)
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x0C ) { # normal high
+ $hidden= 0;
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+ $graph= 0;
+ $fg = int($c);
+
+ } elsif( $c == 0x08 ) { # Blinken einschalten (flashing)
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+ $flash= 1;
+
+ } elsif( $c == 0x09 ) { # Blinken ausschalten (steady)
+ $flash= 0;
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+ } elsif( $c == 0x0A ) { # end box (nicht benutzt)
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x0B ) { # start box (nicht benutzt)
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x0C ) { # normal high
$double= 0;
- $lc=0x20;
- $result .= $self->translate($bHTML, 0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x0D ) { # double high
-# for (my $frei=1;$frei<40;$frei++)
-# $result .= $self->translate($bHTML, $frei,$y+1,0x20,$graph,$double,$sepgraph,$fg,$bg);
-# $result .= $self->endline($bHTML);
-
- $result .= $self->translate($bHTML, 0x20,$graph,$double,$sepgraph,$fg,$bg);
- $double= 1;
-# $skipnextline= 1;
-
- } elsif( $c >= 0x0E and $c <= 0x0F ) { # keine Funktion
-
- } elsif( $c >= 0x10 and $c <= 0x17 ) { #
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
- $hidden= 0;
- $graph= 1;
- $fg = $c-0x10;
-
- } elsif( $c == 0x18 ) { # verborgen
- $hidden= 1;
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x19 ) { # contigouous graphics
- $sepgraph= 0;
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x1A ) { # separated grphics
- $sepgraph= 1;
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x1B ) { # ESC
-
- } elsif( $c == 0x1C ) { # black background
- $bg = (0);
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x1D ) { # new background
- my $tmp = $fg; # ExchangeColor
- $fg = $bg;
- $bg = $tmp;
-
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x1E ) { # hold graphics
- $hold= 1;
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
-
- } elsif( $c == 0x1F ) { # release graphics
- $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
- $hold= 0;
-
- } else { #
- if ($graph == 1) {
- $lc = $c;
- }
- $result .= $self->translate($bHTML, $c,$graph,$double,$sepgraph,$fg,$bg);
- }
- }
- $result .= $self->endline($bHTML);
- if ($skipnextline==1) {
- $y++;
- }
- }
- $result .= "</p>\n" if($bHTML);
- return $result;
-}
-
-################################################################################
-# Read TOC from packed file for index
-sub GetPackedToc {
-
- my $filename = shift;
- my @index;
- my $fh = FileHandle->new;
- if(!$fh->open($filename)) {
- error ("The page could not be found! : $filename");
- } else {
- # Parse TOC
- #
- # 8x[MAIN,SUB a 2x4byte],
- # 8x[PAGE a 972byte],
- # 8x[MAIN,SUB a 2x4byte],
- # 8x[PAGE a 972byte]
- #
- my $tocbuf;
- my $bEnd = 0;
- while(!$fh->eof() and $bEnd == 0) {
- if($fh->read($tocbuf, 4*2*8) ne 64) {
- $bEnd = 1;
- last;
- }
- my @toc = unpack( "i*", $tocbuf);
- my $n = 0;
- for (;$n < 8; ++$n ) {
- my $m = (sprintf ("%X",@toc[$n*2]));
-
- next # Skip nonregular pages like 80F
+ $lc=0x20;
+ $result .= $self->translate($bHTML, 0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x0D ) { # double high
+# for (my $frei=1;$frei<40;$frei++)
+# $result .= $self->translate($bHTML, $frei,$y+1,0x20,$graph,$double,$sepgraph,$fg,$bg);
+# $result .= $self->endline($bHTML);
+
+ $result .= $self->translate($bHTML, 0x20,$graph,$double,$sepgraph,$fg,$bg);
+ $double= 1;
+# $skipnextline= 1;
+
+ } elsif( $c >= 0x0E and $c <= 0x0F ) { # keine Funktion
+
+ } elsif( $c >= 0x10 and $c <= 0x17 ) { #
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+ $hidden= 0;
+ $graph= 1;
+ $fg = $c-0x10;
+
+ } elsif( $c == 0x18 ) { # verborgen
+ $hidden= 1;
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x19 ) { # contigouous graphics
+ $sepgraph= 0;
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x1A ) { # separated grphics
+ $sepgraph= 1;
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x1B ) { # ESC
+
+ } elsif( $c == 0x1C ) { # black background
+ $bg = (0);
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x1D ) { # new background
+ my $tmp = $fg; # ExchangeColor
+ $fg = $bg;
+ $bg = $tmp;
+
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x1E ) { # hold graphics
+ $hold= 1;
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+
+ } elsif( $c == 0x1F ) { # release graphics
+ $result .= $self->translate($bHTML, ($hold == 1)?$lc:0x20,$graph,$double,$sepgraph,$fg,$bg);
+ $hold= 0;
+
+ } else { #
+ if ($graph == 1) {
+ $lc = $c;
+ }
+ $result .= $self->translate($bHTML, $c,$graph,$double,$sepgraph,$fg,$bg);
+ }
+ }
+ $result .= $self->endline($bHTML);
+ if ($skipnextline==1) {
+ $y++;
+ }
+ }
+ $result .= "</p>\n" if($bHTML);
+ return $result;
+}
+
+################################################################################
+# Read TOC from packed file for index
+sub GetPackedToc {
+
+ my $filename = shift;
+ my @index;
+ my $fh = FileHandle->new;
+ if(!$fh->open($filename)) {
+ error ("The page could not be found! : $filename");
+ } else {
+ # Parse TOC
+ #
+ # 8x[MAIN,SUB a 2x4byte],
+ # 8x[PAGE a 972byte],
+ # 8x[MAIN,SUB a 2x4byte],
+ # 8x[PAGE a 972byte]
+ #
+ my $tocbuf;
+ my $bEnd = 0;
+ while(!$fh->eof() and $bEnd == 0) {
+ if($fh->read($tocbuf, 4*2*8) ne 64) {
+ $bEnd = 1;
+ last;
+ }
+ my @toc = unpack( "i*", $tocbuf);
+ my $n = 0;
+ for (;$n < 8; ++$n ) {
+ my $m = (sprintf ("%X",@toc[$n*2]));
+
+ next # Skip nonregular pages like 80F
if($m =~ /\D/sig);
- my $mpage = int($m);
+ my $mpage = int($m);
my $spage = int(sprintf ("%X",@toc[($n*2)+1]));
- # Check for last toc entry 0/0
- if($mpage == 0 and $spage == 0) {
- $bEnd = 1;
- last;
- }
- my $found = 0;
- foreach my $p (@index) {
- if($p->[0] == $mpage) {
- $found = 1;
- push(@{$p->[1]},$spage)
- if($spage != 0);
- last;
- }
- }
- if ($found == 0) {
- push(@index,[$mpage, [$spage] ]);
- }
- }
+ # Check for last toc entry 0/0
+ if($mpage == 0 and $spage == 0) {
+ $bEnd = 1;
+ last;
+ }
+ my $found = 0;
+ foreach my $p (@index) {
+ if($p->[0] == $mpage) {
+ $found = 1;
+ push(@{$p->[1]},$spage)
+ if($spage != 0);
+ last;
+ }
+ }
+ if ($found == 0) {
+ push(@index,[$mpage, [$spage] ]);
+ }
+ }
# Skip Pages
- if(0 == $fh->seek((972*8), 1)) {
- $bEnd = 1;
- last;
- }
- }
-
- $fh->close();
- }
- return @index;
-}
-
-################################################################################
-# HighLight searched text
-sub HighLight {
-
- my $self = shift;
- my $result = shift;
- my $search = shift;
- my $lines;
-
- my $ua = "<font style=\"color:black;background-color:lime;\">";
- my $ub = "</font>";
-
- foreach my $line (split('\n',$result)) {
- $line =~ s/$search/$ua$search$ub/g;
+ if(0 == $fh->seek((972*8), 1)) {
+ $bEnd = 1;
+ last;
+ }
+ }
+
+ $fh->close();
+ }
+ return @index;
+}
+
+################################################################################
+# HighLight searched text
+sub HighLight {
+
+ my $self = shift;
+ my $result = shift;
+ my $search = shift;
+ my $lines;
+
+ my $ua = "<font style=\"color:black;background-color:lime;\">";
+ my $ub = "</font>";
+
+ foreach my $line (split('\n',$result)) {
+ $line =~ s/$search/$ua$search$ub/g;
$lines .= $line;
- }
- return $lines;
+ }
+ return $lines;
}
-################################################################################
-# Callback "Teletext search"
-sub search {
- my $self = shift || return error ('No Object!');
- my $watcher = shift || return error ('No Watcher!');
- my $console = shift || return error ('No Console');
- my $search = shift;
-
- my $channel = $self->{CHANNEL};
- my $chandir = $self->{CHANNELDIR};
- if($channel eq "" or $chandir eq "") {
- $self->pagedump($console,gettext("No channel defined!"),"");
- }
+################################################################################
+# Callback "Teletext search"
+sub search {
+ my $self = shift || return error ('No Object!');
+ my $watcher = shift || return error ('No Watcher!');
+ my $console = shift || return error ('No Console');
+ my $search = shift;
+
+ my $channel = $self->{CHANNEL};
+ my $chandir = $self->{CHANNELDIR};
+ if($channel eq "" or $chandir eq "") {
+ $self->pagedump($console,gettext("No channel defined!"),"");
+ }
chomp($search);
unless($search) {
- $self->pagedump($console,gettext("No data to search given!"),$chandir);
+ $self->pagedump($console,gettext("No data to search given!"),$chandir);
}
- my $oldpage = $self->{mainpage};
+ my $oldpage = $self->{mainpage};
my $oldsubpage = $self->{subpage};
my @foundlist;
my $searchlimit = 25;
- foreach my $p (@{$self->{INDEX}}) {
+ foreach my $p (@{$self->{INDEX}}) {
foreach my $s (@{$p->[1]}) {
- my $mp = sprintf("%3d",$p->[0]);
- my $sp = sprintf("%2d",$s);
+ my $mp = sprintf("%3d",$p->[0]);
+ my $sp = sprintf("%2d",$s);
my $lookup = $self->realpage($console, $mp, $sp, 0);
@@ -1363,22 +1363,22 @@ sub search {
push(@foundlist,[$mp, $sp]);
$searchlimit--;
last if($searchlimit <= 0);
- }
- }
- last if($searchlimit <= 0);
+ }
+ }
+ last if($searchlimit <= 0);
}
if(scalar @foundlist < 1) {
- $self->{mainpage} = $oldpage;
+ $self->{mainpage} = $oldpage;
$self->{subpage} = $oldsubpage;
- $self->pagedump($console,sprintf(gettext("No page with \'%s\' found!"),$search),$chandir);
+ $self->pagedump($console,sprintf(gettext("No page with \'%s\' found!"),$search),$chandir);
return 0;
}
- my $bHTML = ($console->{TYP} ne 'HTML')?0:1;
+ my $bHTML = ($console->{TYP} ne 'HTML')?0:1;
foreach my $pp (@foundlist) {
- $self->{mainpage} = $pp->[0];
+ $self->{mainpage} = $pp->[0];
$self->{subpage} = $pp->[1];
my $result = $self->realpage($console, $pp->[0], $pp->[1],$bHTML);
@@ -1391,6 +1391,6 @@ sub search {
if($result ne "");
}
return 1;
-}
-
+}
+
1;