summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndreas Brachold <vdr07@deltab.de>2007-12-18 12:57:39 +0000
committerAndreas Brachold <vdr07@deltab.de>2007-12-18 12:57:39 +0000
commitc7ad2a741f2a025c685ad0c039176aba4b35e224 (patch)
tree6079319379524406cead57ae64099787f59b400d /lib
parent7f73ec4fe7f744e5abf4bcd5b6c524991ce09c3e (diff)
downloadxxv-c7ad2a741f2a025c685ad0c039176aba4b35e224.tar.gz
xxv-c7ad2a741f2a025c685ad0c039176aba4b35e224.tar.bz2
* Drop support for older then vdr 1.3.44
* GRAB: load image direct from svdrp to memory, and send it direct to socket. * GRAB: Support multi line overlay * GRAB: simply variable names of overlay * RECORDS: reorder info.vdr routines * RECORDS: write title and subtitle into info.vdr after editing
Diffstat (limited to 'lib')
-rw-r--r--lib/XXV/MODULES/AUTOTIMER.pm40
-rw-r--r--lib/XXV/MODULES/CHANNELS.pm2
-rw-r--r--lib/XXV/MODULES/EPG.pm4
-rw-r--r--lib/XXV/MODULES/GRAB.pm196
-rw-r--r--lib/XXV/MODULES/RECORDS.pm369
-rw-r--r--lib/XXV/MODULES/TIMERS.pm77
6 files changed, 349 insertions, 339 deletions
diff --git a/lib/XXV/MODULES/AUTOTIMER.pm b/lib/XXV/MODULES/AUTOTIMER.pm
index 38d4e38..bf85632 100644
--- a/lib/XXV/MODULES/AUTOTIMER.pm
+++ b/lib/XXV/MODULES/AUTOTIMER.pm
@@ -373,8 +373,6 @@ sub _autotimerLookup {
my $M = 0;
my $log;
- my $vdrVersion = main::getVdrVersion();
-
# Search only for event there added since last runtime.
# and search not with TEMPEPG at manual running
my $addtime = ((not ref $console) && ($obj->{addtime})) ? $obj->{addtime} : 0;
@@ -428,7 +426,7 @@ sub _autotimerLookup {
[gettext("Channel") , $events->{$Id}->{Channel}],
[gettext("Start") , strftime("%x %X", localtime($events->{$Id}->{starttime}))],
[gettext("Stop") , strftime("%x %X", localtime($events->{$Id}->{stoptime}))],
- [gettext("Description"), $events->{$Id}->{Summary}],
+ [gettext("Description"), $events->{$Id}->{description}],
];
$console->table($output);
};
@@ -454,11 +452,7 @@ sub _autotimerLookup {
# Add anchor for reidentify timer
my $aidcomment = sprintf('#~AT[%d]', $id);
- if($vdrVersion >= 10344){
- $events->{$Id}->{Summary} = $aidcomment;
- } else {
- $events->{$Id}->{Summary} .= $aidcomment;
- }
+ $events->{$Id}->{aux} = $aidcomment;
# Wished timer already exist with same data from autotimer ?
next if($obj->_timerexists($events->{$Id}, $aidcomment));
@@ -1191,7 +1185,7 @@ SELECT SQL_CACHE
c.POS as POS,
e.title as Title,
e.subtitle as Subtitle,
- e.description as Summary,
+ e.description as description,
(UNIX_TIMESTAMP(e.starttime) - ? ) as starttime,
(UNIX_TIMESTAMP(e.starttime) + e.duration + ?) as stoptime,
UNIX_TIMESTAMP(e.vpstime) as vpsstart,
@@ -1227,14 +1221,14 @@ sub _timerexists {
and Lifetime = ?
and (
( Status & 1 = '0' )
- or ( File = ? and Summary = ? )
- or ( Summary not like ? )
+ or ( File = ? and aux = ? )
+ or ( aux not like ? )
)";
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventdata->{ChannelID},$eventdata->{starttime},$eventdata->{stoptime},
$eventdata->{Priority},$eventdata->{Lifetime},
- $eventdata->{File},$eventdata->{Summary},"%".$aidcomment)
+ $eventdata->{File},$eventdata->{aux},"%".$aidcomment)
or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg->{cc}
@@ -1256,8 +1250,8 @@ sub _timerexistsfuzzy {
ChannelID = ?
and UNIX_TIMESTAMP(NextStartTime) = ?
and UNIX_TIMESTAMP(NextStopTime) = ?
- and Summary like ?
- order by length(Summary) desc;";
+ and aux like ?
+ order by length(aux) desc;";
my $sth = $obj->{dbh}->prepare($sql);
$sth->execute($eventdata->{ChannelID},$eventdata->{starttime},$eventdata->{stoptime},
@@ -1376,15 +1370,15 @@ sub _placeholder {
$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: (.*?)\|/;
+ $at_details{'regie'} = $1 if $data->{description} =~ m/\|Director: (.*?)\|/;
+ $at_details{'category'} = $1 if $data->{description} =~ m/\|Category: (.*?)\|/;
+ $at_details{'genre'} = $1 if $data->{description} =~ m/\|Genre: (.*?)\|/;
+ $at_details{'year'} = $1 if $data->{description} =~ m/\|Year: (.*?)\|/;
+ $at_details{'country'} = $1 if $data->{description} =~ m/\|Country: (.*?)\|/;
+ $at_details{'originaltitle'} = $1 if $data->{description} =~ m/\|Originaltitle: (.*?)\|/;
+ $at_details{'fsk'} = $1 if $data->{description} =~ m/\|FSK: (.*?)\|/;
+ $at_details{'episode'} = $1 if $data->{description} =~ m/\|Episode: (.*?)\|/;
+ $at_details{'rating'} = $1 if $data->{description} =~ m/\|Rating: (.*?)\|/;
$title =~ s/%([\w_-]+)%/$at_details{lc($1)}/sieg;
$file = $title;
} else { # Classic mode DIR~TITLE~SUBTILE
diff --git a/lib/XXV/MODULES/CHANNELS.pm b/lib/XXV/MODULES/CHANNELS.pm
index be8020b..e150eef 100644
--- a/lib/XXV/MODULES/CHANNELS.pm
+++ b/lib/XXV/MODULES/CHANNELS.pm
@@ -672,7 +672,7 @@ sub editChannel {
} ];
#Change Position only on editing
push(@{$questions},@{$newpos})
- if($cid && main::getVdrVersion >= 10332);
+ if($cid);
my $more = [
'Name' => {
diff --git a/lib/XXV/MODULES/EPG.pm b/lib/XXV/MODULES/EPG.pm
index 867527f..98470a4 100644
--- a/lib/XXV/MODULES/EPG.pm
+++ b/lib/XXV/MODULES/EPG.pm
@@ -974,8 +974,8 @@ ORDER BY
sub NowOnChannel {
# ------------------
my $obj = shift || return error('No object defined!');
- my $watcher = shift || return error('No watcher defined!');
- my $console = shift || return error('No console defined!');
+ my $watcher = shift;
+ my $console = shift;
my $channel = shift || $obj->_actualChannel || return con_err($console, gettext('No channel defined!'));
my $zeit = time;
diff --git a/lib/XXV/MODULES/GRAB.pm b/lib/XXV/MODULES/GRAB.pm
index 26f89bb..9aa2eee 100644
--- a/lib/XXV/MODULES/GRAB.pm
+++ b/lib/XXV/MODULES/GRAB.pm
@@ -35,15 +35,15 @@ sub module {
type => 'integer',
required => gettext('This is required!'),
},
- file => {
- description => gettext('Location where the grabbed image file will be stored'),
- default => '/tmp/live.jpg',
- type => 'file',
- },
- imgtext => {
+ overlay => {
description => gettext('Text to display in the grabbed picture.'),
- default => "[?- i = channel.split(' ') -?][[? i.shift ?]] [? i.join(' ') ?]",
+ default => "<< event.POS >>.<< event.Channel >>\|<< event.Title >> << event.Subtitle >>",
type => 'string',
+ check => sub{
+ my $value = shift;
+ $value = join('|',(split(/[\r\n]/, $value)));
+ return $value;
+ },
},
vpos => {
description => gettext('Vertical position of displayed text, in pixels.'),
@@ -115,11 +115,11 @@ sub new {
# create Template object
$self->{tt} = Template->new(
- START_TAG => '\[\?', # Tagstyle
- END_TAG => '\?\]', # Tagstyle
+ START_TAG => '\<\<', # Tagstyle
+ END_TAG => '\>\>', # Tagstyle
INTERPOLATE => 1, # expand "$var" in plain text
- PRE_CHOMP => 1, # cleanup whitespace
- EVAL_PERL => 1, # evaluate Perl code blocks
+ PRE_CHOMP => 0, # cleanup whitespace
+ EVAL_PERL => 0, # evaluate Perl code blocks
);
$self->_init or return error('Problem to initialize modul!');
@@ -149,56 +149,32 @@ sub grab {
my $obj = shift || return error('No object defined!');
my $watcher = shift;
my $console = shift;
- my $file = $obj->{file};
- my $erg;
-
- if(main::getVdrVersion() >= 10338) {
-
- # command for get inline data (JPEG BASE64 coded)
- my $cmd = sprintf('grab - %d %d %d',
- $obj->{imgquality},
- $obj->{xsize},
- $obj->{ysize},
- );
-
- my $data = $obj->{svdrp}->command($cmd);
- my $uu = [ grep(/^216-/, @$data) ];
- foreach (@{$uu}) { s/^216-//g; }
-
- if(scalar @{$uu} <= 0) {
- # None data with 216-, maybe svdrp message contain reason
- $erg = $data;
- } elsif(!open(F, ">$file")) {
- # Open failed
- $erg = sprintf("Couldn't write file %s : %s",$file,$!);
- } else {
- # uudecode data to file
- binmode(F);
- foreach (@{$uu}) { print F MIME::Base64::decode_base64($_); }
- close F;
- }
- } else {
- if(-e $file) {
- unlink($file) || error sprintf("Couldn't remove '%s' : %s",$file,$!);
- }
- # the command
- my $cmd = sprintf('grab %s jpeg %d %d %d',
- $obj->{file},
- $obj->{imgquality},
- $obj->{xsize},
- $obj->{ysize},
- );
-
- $erg = $obj->{svdrp}->command($cmd);
+ # command for get inline data (JPEG BASE64 coded)
+ my $cmd = sprintf('grab - %d %d %d',
+ $obj->{imgquality},
+ $obj->{xsize},
+ $obj->{ysize},
+ );
+
+ my $data = $obj->{svdrp}->command($cmd);
+
+ my $binary;
+ foreach my $l (@{$data}) {
+ if($l =~ /^216-/sg) {
+ $l =~ s/^216-//g;
+ $binary .= MIME::Base64::decode_base64($l);
+ }
}
- # Make imgtext
- $file = $obj->makeImgText($file, $obj->{imgtext})
- if($obj->{imgtext} && -s $file);
+ $binary = $obj->_noise() unless($binary);
- $console->msg($erg, $obj->{svdrp}->err)
- if(ref $console);
- return $file;
+ if($binary) {
+ # Make overlay on image
+ $binary = $obj->makeImgText($binary, $obj->{overlay})
+ if($obj->{overlay});
+ return $binary;
+ }
+ return undef;
}
# ------------------
@@ -208,13 +184,14 @@ sub display {
my $watcher = shift || return error('No watcher defined!');
my $console = shift || return error('No console defined!');
- my $file = $obj->grab();
- if(-s $file) { # Datei existiert und hat eine Grösse von mehr als 0 Bytes
+ my $binary = $obj->grab();
+ if($binary) { # Datei existiert und hat eine Grösse von mehr als 0 Bytes
$console->{nocache} = 1;
- return $console->image($file);
- } else {
- error("Couldn't locate file : $file, maybe grabbing was failed");
- return 0;
+ $console->{nopack} = 1;
+ my %args = ();
+ $args{'attachment'} = 'grab.jpg';
+ $args{'Content-Length'} = length($binary);
+ return $console->out($binary, 'image/jpeg', %args );
}
}
@@ -222,49 +199,86 @@ sub display {
sub makeImgText {
# ------------------
my $obj = shift || return error('No object defined!');
- my $watcher = shift || return error('No watcher defined!');
- my $console = shift || return error('No console defined!');
- my $file = shift || $obj->{file} || return error ('No file to display defined!');
- my $text = shift || $obj->{imgtext} || return error ('No text to display defined!');
+ my $binary = shift || return error ('No data to create overlay defined!');
+ my $text = shift || return error ('No text to display defined!');
- my $im;
- if(int(${GD::VERSION}) >= 2.0) {
- $im = GD::Image->newFromJpeg($file, 1) || return error("Couldn't read $file $!");
- } else {
- $im = GD::Image->newFromJpeg($file) || return error("Couldn't read $file $!");
+ my $image = GD::Image->newFromJpegData($binary);
+ unless($image && $image->width > 8 && $image->height > 8) {
+ return error("Data has'nt jpeg data or jpeg data contains errors!");
}
- my $color = $im->colorClosest(255,255,255);
- my $shadow = $im->colorClosest(0,0,0);
+ my $color = $image->colorClosest(255,255,255);
+ my $shadow = $image->colorClosest(0,0,0);
- # XXX: Hier sollten noch mehr Informationen dazu kommen
- my $channeltext = main::getModule('REMOTE')->switch();
- my $channelpos = (split(' ', $channeltext))[0];
+ # Hier sollten noch mehr Informationen dazu kommen
my $vars = {
- channel => $channeltext,
- event => main::getModule('EPG')->NowOnChannel($watcher, $console, $channelpos),
+ event => main::getModule('EPG')->NowOnChannel(undef,undef),
};
my $output = '';
$obj->{tt}->process(\$text, $vars, \$output)
or return error($obj->{tt}->error());
+
my $font = sprintf("%s/%s",$obj->{paths}->{FONTPATH},$obj->{font});
if($obj->{paths}->{FONTPATH} and $obj->{font} and -r $font) {
- $im->stringFT($shadow,$font,$obj->{imgfontsize},0,11,($obj->{vpos}-1),$output);
- $im->stringFT($color,$font,$obj->{imgfontsize},0,10,($obj->{vpos}),$output);
+ my $height = ($obj->{imgfontsize} + 2);
+ $height *= -1 if($obj->{vpos} > ($obj->{ysize} / 2));
+
+ my $offset = 0;
+ foreach my $zeile (split(/\|/, $output)) {
+ $image->stringFT($shadow,$font,$obj->{imgfontsize},0,11,($obj->{vpos}-1)+$offset,$zeile);
+ $image->stringFT($color,$font,$obj->{imgfontsize},0,10,($obj->{vpos})+$offset,$zeile);
+ $offset += $height;
+ }
} else {
- # Schatten
- $im->string(&gdGiantFont,11, ($obj->{vpos}-1),$output,$shadow);
- # Text
- $im->string(&gdGiantFont,10, ($obj->{vpos}),$output,$color);
+ my $height = 12;
+ $height *= -1 if($obj->{vpos} > ($obj->{ysize} / 2));
+
+ my $offset = 0;
+ foreach my $zeile (split(/\|/, $output)) {
+ $image->string(&gdGiantFont,11, ($obj->{vpos}-1) + $offset,$zeile,$shadow); # Schatten
+ $image->string(&gdGiantFont,10, ($obj->{vpos}) + $offset,$zeile,$color); # Text
+ $offset += $height;
+ }
+ }
+
+ my $img_data = $image->jpeg($obj->{imgquality});
+ return $img_data;
+}
+
+sub _noise {
+ my $obj = shift || return error('No object defined!');
+ my $image = GD::Image->new($obj->{xsize}, $obj->{ysize},1);
+
+ my $colors;
+ push( @{$colors}, $image->colorClosest(255,255,255));
+ push( @{$colors}, $image->colorClosest(128,128,128));
+ push( @{$colors}, $image->colorClosest(0,0,0));
+
+ $obj->_noise_rect($image,0,0,$obj->{xsize},$obj->{ysize},$colors);
+ my $img_data = $image->jpeg($obj->{imgquality});
+ return $img_data;
+}
+
+sub _noise_rect {
+ my $obj = shift || return error('No object defined!');
+ my $image = shift;
+ my $x1 = shift; my $y1 = shift;
+ my $x2 = shift; my $y2 = shift;
+ my $colors_ref = shift;
+ my $colorcount = scalar @{$colors_ref};
+
+ return if $x2 <= $x1; # refuse to create a zero- or negative-size box
+ return if $y2 <= $y1;
+
+ for (my $x = $x1; $x < $x2; ++$x) {
+ for (my $y = $y1; $y < $y2; ++$y) {
+ $image->setPixel($x, $y,$colors_ref->[CORE::int(rand($colorcount))]);
+ }
}
- my $img_data = $im->jpeg($obj->{imgquality});
- my @f = split('\.', $file);
- my $newfile = ($file =~ 'text' ? $file : sprintf('%s_text.%s', @f));
- save_file($newfile, $img_data);
- return $newfile;
+ return;
}
# ------------------
diff --git a/lib/XXV/MODULES/RECORDS.pm b/lib/XXV/MODULES/RECORDS.pm
index fd2e95e..eb73778 100644
--- a/lib/XXV/MODULES/RECORDS.pm
+++ b/lib/XXV/MODULES/RECORDS.pm
@@ -910,86 +910,193 @@ sub videoInfo {
return 0;
}
- my $status = {};
+ my $status;
# Dateigröße von index.vdr für Aufnahmedauer ermitteln
if($files[0] && -e $files[0]) {
- my $path = dirname($files[0]);
+ my $path = dirname($files[0]);
#Splitt 2005-01-16.04:35.88.99.rec
my ($year, $month, $day, $hour, $minute, $prio, $lifetime)
= (basename($path)) =~ /^(\d+)\-(\d+)\-(\d+)\.(\d+)[\:|\.](\d+)\.(\d+)\.(\d+)\.rec/si;
- $status->{Prio} = $prio;
- $status->{Lifetime} = $lifetime;
-
- $status->{duration} = $obj->_recordinglength($path);
- $status->{FileSize} = $obj->_recordingCapacity(\@files,($status->{duration} * 8 * $obj->{framerate}));
-
- # Schnittmarken ermitteln
- my $marks = sprintf("%s/marks.vdr", $path);
- if(-r $marks) {
- my $data = load_file($marks)
- or error sprintf("Couldn't read file '%s'",$marks);
- if($data) {
- foreach my $zeile (split("\n", $data)) {
- # 0:35:07.09 moved from [0:35:13.24 Logo start] by checkBlackFrameOnMark
- my ($mark) = $zeile =~ /^(\d+\:\d+\:\d+\.\d+)/sg;
- push(@{$status->{marks}}, $mark)
- if(defined $mark);
- }
+ $status->{Prio} = $prio;
+ $status->{Lifetime} = $lifetime;
+
+ $status->{duration} = $obj->_recordinglength($path);
+ $status->{FileSize} = $obj->_recordingCapacity(\@files,($status->{duration} * 8 * $obj->{framerate}));
+
+ my $info = $obj->readinfo($path);
+ foreach my $h (keys %{$info}) { $status->{$h} = $info->{$h}; }
+ my $marks = $obj->readmarks($path);
+ foreach my $m (keys %{$marks}) { $status->{$m} = $marks->{$m}; }
+
+ $status->{path} = $path;
+ $status->{RecordMD5} = md5_hex($path);
+ }
+ return $status;
+}
+
+#-------------------------------------------------------------------------------
+# get cut marks from marks.vdr
+sub readmarks {
+ my $obj = shift || return error('No object defined!');
+ my $path = shift || return error ('No recording path defined!');
+
+ my $status;
+ # Schnittmarken ermitteln
+ my $marks = sprintf("%s/marks.vdr", $path);
+ if(-r $marks) {
+ my $data = load_file($marks)
+ or error sprintf("Couldn't read file '%s'",$marks);
+ if($data) {
+ foreach my $zeile (split("\n", $data)) {
+ # 0:35:07.09 moved from [0:35:13.24 Logo start] by checkBlackFrameOnMark
+ my ($mark) = $zeile =~ /^(\d+\:\d+\:\d+\.\d+)/sg;
+ push(@{$status->{marks}}, $mark)
+ if(defined $mark);
}
}
+ }
+ return $status;
+}
- # Summary ermitteln
- my $file = sprintf("%s/info.vdr", $path);
- $file = sprintf("%s/summary.vdr", $path ) if(main::getVdrVersion() < 10325);
-
- $status->{type} = 'UNKNOWN';
- if(-r $file) {
- my $text = load_file($file);
-
- # Neue Vdr Version 1.3.25!
- if(main::getVdrVersion() >= 10325) {
- my $cmod = main::getModule('CHANNELS');
- foreach my $zeile (split(/[\r\n]/, $text)) {
- if($zeile =~ /^D\s+(.+)/s) {
- $status->{summary} = $1;
- $status->{summary} =~ s/\|/\r\n/g; # pipe used from vdr as linebreak
- $status->{summary} =~ s/^\s+//; # no leading white space
- $status->{summary} =~ s/\s+$//; # no trailing white space
- }
- elsif($zeile =~ /^C\s+(\S+)/s) {
- $status->{channel} = $1;
- $status->{type} = $cmod->getChannelType($status->{channel});
- }
- elsif($zeile =~ /^T\s+(.+)$/s) {
- $status->{title} = $1;
- }
- elsif($zeile =~ /^S\s+(.+)$/s) {
- $status->{subtitle} = $1;
- }
- elsif($zeile =~ /^X\s+1\s+(.+)$/s) {
- $status->{video} = $1;
- }
- elsif($zeile =~ /^X\s+2\s+(.+)$/s) {
- $status->{audio} .= "\n" if($status->{audio});
- $status->{audio} .= $1;
- }
- }
- } else {
- $status->{summary} = $text;
+#-------------------------------------------------------------------------------
+# get information about recording from info.vdr
+sub readinfo {
+ my $obj = shift || return error('No object defined!');
+ my $path = shift || return error ('No recording path defined!');
+
+ my $info;
+ $info->{type} = 'UNKNOWN'; #TV / RADIO
+
+ # get description
+ my $file = sprintf("%s/info.vdr", $path);
+ if(-r $file) {
+ my $text = load_file($file);
+ my $cmod = main::getModule('CHANNELS');
+ foreach my $zeile (split(/[\r\n]/, $text)) {
+ if($zeile =~ /^D\s+(.+)/s) {
+ $info->{description} = $1;
+ $info->{description} =~ s/\|/\r\n/g; # pipe used from vdr as linebreak
+ $info->{description} =~ s/^\s+//; # no leading white space
+ $info->{description} =~ s/\s+$//; # no trailing white space
+ }
+ elsif($zeile =~ /^C\s+(\S+)/s) {
+ $info->{channel} = $1;
+ $info->{type} = $cmod->getChannelType($info->{channel});
+ }
+ elsif($zeile =~ /^T\s+(.+)$/s) {
+ $info->{title} = $1;
+ }
+ elsif($zeile =~ /^S\s+(.+)$/s) {
+ $info->{subtitle} = $1;
+ }
+ elsif($zeile =~ /^X\s+1\s+(.+)$/s) {
+ $info->{video} = $1;
+ }
+ elsif($zeile =~ /^X\s+2\s+(.+)$/s) {
+ $info->{audio} .= "\n" if($info->{audio});
+ $info->{audio} .= $1;
}
}
+ }
+ return $info;
+}
+#-------------------------------------------------------------------------------
+# store information about recording into info.vdr
+sub saveinfo {
+ my $obj = shift || return error('No object defined!');
+ my $path = shift || return error ('No recording path defined!');
+ my $info = shift || return error ('No information defined!');
- $status->{path} = $path;
- $status->{RecordMD5} = md5_hex($path);
+ my $out;
+ foreach my $h (keys %{$info}) {
+ $info->{$h} =~ s/\r\n/\|/g; # pipe used from vdr as linebreak
+ $info->{$h} =~ s/\n/\|/g; # pipe used from vdr as linebreak
+ $info->{$h} =~ s/^\s+//; # no leading white space
+ $info->{$h} =~ s/\s+$//; # no trailing white space
}
- return $status;
+ my $file = sprintf("%s/info.vdr", $path);
+ my $text = ( -r $file ? load_file($file) : '');
+ foreach my $zeile (split(/[\r\n]/, $text)) {
+ $zeile =~ s/^\s+//;
+ $zeile =~ s/\s+$//;
+ if($zeile =~ /^T\s+(.+)/s) {
+ if(defined $info->{title} && $info->{title}) {
+ $out .= "T ". $info->{title} . "\n";
+ undef $info->{title};
+ }
+ }
+ elsif($zeile =~ /^S\s+(.+)/s) {
+ if(defined $info->{subtitle} && $info->{subtitle}) {
+ $out .= "S ". $info->{subtitle} . "\n";
+ undef $info->{subtitle};
+ }
+ }
+ elsif($zeile =~ /^D\s+(.+)/s) {
+ if(defined $info->{description} && $info->{description}) {
+ $out .= "D ". $info->{description} . "\n";
+ undef $info->{description};
+ }
+ }
+ elsif($zeile =~ /^C\s+(\S+)/s) {
+ if(defined $info->{channel} && $info->{channel}) {
+ $out .= "C ". $info->{channel} . "\n" if($info->{channel});
+ undef $info->{channel};
+ }
+ }
+ elsif($zeile =~ /^X\s+1\s+(.+)$/s) {
+ if(defined $info->{video} && $info->{video}) {
+ $out .= "X 1 ". $info->{video} . "\n" if($info->{video});
+ undef $info->{video};
+ }
+ }
+ elsif($zeile =~ /^X\s+2\s+(.+)$/s) {
+ if(defined $info->{audio} && $info->{audio}) {
+ foreach my $line (split(/\|/, $info->{audio})) {
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ next unless($line);
+ $out .= "X 2 ". $line . "\n";
+ }
+ undef $info->{audio};
+ }
+ } else {
+ $out .= $zeile . "\n" if($zeile);
+ }
+ }
+
+ if(defined $info->{title} && $info->{title}) {
+ $out .= "T ". $info->{title} . "\n";
+ }
+ if(defined $info->{subtitle} && $info->{subtitle}) {
+ $out .= "S ". $info->{subtitle} . "\n";
+ }
+ if(defined $info->{channel} && $info->{channel}) {
+ $out .= "C ". $info->{channel} . "\n" if($info->{channel});
+ }
+ if(defined $info->{description} && $info->{description}) {
+ $out .= "D ". $info->{description} . "\n";
+ }
+ if(defined $info->{video} && $info->{video}) {
+ $out .= "X 1 ". $info->{video} . "\n" if($info->{video});
+ }
+ if(defined $info->{audio} && $info->{audio}) {
+ foreach my $line (split(/\|/, $info->{audio})) {
+ $line =~ s/^\s+//;
+ $line =~ s/\s+$//;
+ $out .= "X 2 ". $line . "\n" if($line);
+ }
+ }
+
+ return save_file($file, $out);
}
+
+#-------------------------------------------------------------------------------
sub qquote {
my $str = shift;
$str =~ s/(\')/\'\\\'\'/g;
@@ -1170,7 +1277,7 @@ sub createOldEventId {
my $attr = {
title => $title,
subtitle => $subtitle,
- description => $info->{summary} || "",
+ description => $info->{description} || "",
channel => $info->{channel} || "<undef>",
duration => $duration,
starttime => $start,
@@ -1654,35 +1761,7 @@ WHERE
}
}
- my $file = sprintf("%s/info.vdr", $rec->{Path});
-
- my $desc;
- my $channel;
- my $video;
- my $audio;
-
- if(-r $file) {
- my $text = load_file($file) || "";
-
- foreach my $zeile (split(/[\r\n]/, $text)) {
- if($zeile =~ /^D\s+(.+)/s) {
- $desc = $1;
- $desc =~ s/\|/\r\n/g; # pipe used from vdr as linebreak
- $desc =~ s/^\s+//; # no leading white space
- $desc =~ s/\s+$//; # no trailing white space
- }
- elsif($zeile =~ /^C\s+(\S+)/s) {
- $channel = $1;
- }
- elsif($zeile =~ /^X\s+1\s+(.+)$/s) {
- $video = $1;
- }
- elsif($zeile =~ /^X\s+2\s+(.+)$/s) {
- $audio .= "\n" if($audio);
- $audio .= $1;
- }
- }
- }
+ my $status = $obj->readinfo($rec->{Path});
my $marksfile = sprintf('%s/%s', $rec->{Path}, 'marks.vdr');
my $marks = (-r $marksfile ? load_file($marksfile) : '');
@@ -1729,7 +1808,7 @@ WHERE
},
'channel' => {
typ => 'list',
- def => $mod->ChannelToPos($channel),
+ def => $mod->ChannelToPos($status->{channel}),
choices => sub {
my $erg = $mod->ChannelArray('Name');
unshift(@$erg, [gettext("Undefined"),undef]);
@@ -1748,17 +1827,17 @@ WHERE
}
},
},
- 'summary' => {
- msg => gettext("Summary"),
- def => $desc || '',
+ 'description' => {
+ msg => gettext("Description"),
+ def => $status->{description} || '',
},
'video' => {
msg => gettext('Video'),
- def => $video,
+ def => $status->{video},
},
'audio' => {
msg => gettext('Audio'),
- def => $audio,
+ def => $status->{audio},
},
'marks' => {
param => {type => 'text'},
@@ -1773,80 +1852,28 @@ WHERE
my $dropEPGEntry = 0;
my $ChangeRecordingData = 0;
- if($data->{summary} ne $desc
- or $data->{channel} ne $channel
- or $data->{video} ne $video
- or $data->{audio} ne $audio) {
- my $out;
- $data->{summary} =~ s/\r\n/\|/g; # pipe used from vdr as linebreak
- $data->{summary} =~ s/\n/\|/g; # pipe used from vdr as linebreak
- $data->{summary} =~ s/^\s+//; # no leading white space
- $data->{summary} =~ s/\s+$//; # no trailing white space
- if(-r $file) {
- my $text = load_file($file) || "";
- foreach my $zeile (split(/[\r\n]/, $text)) {
- $zeile =~ s/^\s+//;
- $zeile =~ s/\s+$//;
- if($zeile =~ /^D\s+(.+)/s) {
- if(defined $data->{summary} && $data->{summary}) {
- $out .= "D ". $data->{summary} . "\n";
- undef $data->{summary};
- }
- }
- elsif($zeile =~ /^C\s+(\S+)/s) {
- if(defined $data->{channel} && $data->{channel}) {
- $data->{channel} =~ s/^\s+//;
- $data->{channel} =~ s/\s+$//;
- $out .= "C ". $data->{channel} . "\n" if($data->{channel});
- undef $data->{channel};
- }
- }
- elsif($zeile =~ /^X\s+1\s+(.+)$/s) {
- if(defined $data->{video} && $data->{video}) {
- $data->{video} =~ s/^\s+//;
- $data->{video} =~ s/\s+$//;
- $out .= "X 1 ". $data->{video} . "\n" if($data->{video});
- undef $data->{video};
- }
- }
- elsif($zeile =~ /^X\s+2\s+(.+)$/s) {
- if(defined $data->{audio} && $data->{audio}) {
- foreach my $line (split(/[\r\n]/, $data->{audio})) {
- $line =~ s/^\s+//;
- $line =~ s/\s+$//;
- next unless($line);
- $out .= "X 2 ". $line . "\n";
- }
- undef $data->{audio};
- }
- } else {
- $out .= $zeile . "\n" if($zeile);
- }
- }
- }
- if(defined $data->{channel} && $data->{channel}) {
- $data->{channel} =~ s/^\s+//;
- $data->{channel} =~ s/\s+$//;
- $out .= "C ". $data->{channel} . "\n" if($data->{channel});
- }
- if(defined $data->{summary} && $data->{summary}) {
- $out .= "D ". $data->{summary} . "\n";
- }
- if(defined $data->{video} && $data->{video}) {
- $data->{video} =~ s/^\s+//;
- $data->{video} =~ s/\s+$//;
- $out .= "X 1 ". $data->{video} . "\n" if($data->{video});
- }
- if(defined $data->{audio} && $data->{audio}) {
- foreach my $line (split(/[\r\n]/, $data->{audio})) {
- $line =~ s/^\s+//;
- $line =~ s/\s+$//;
- $out .= "X 2 ". $line . "\n" if($line);
- }
+
+ $data->{title} =~s#~+#~#g;
+ $data->{title} =~s#^~##g;
+ $data->{title} =~s#~$##g;
+
+ if($data->{title} ne $rec->{title}
+ or $data->{description} ne $status->{description}
+ or $data->{channel} ne $status->{channel}
+ or $data->{video} ne $status->{video}
+ or $data->{audio} ne $status->{audio}) {
+
+ my $info;
+ foreach my $h (keys %{$data}) { $info->{$h} = $data->{$h}; }
+ my @t = split('~', $info->{title});
+ if(scalar @t > 1) { # Splitt genre~title | subtitle
+ $info->{subtitle} = delete $t[-1];
+ $info->{title} = join('~',@t);
}
- save_file($file, $out)
- or return con_err($console,sprintf(gettext("Couldn't write file '%s' : %s"),$file,$!));
+ $obj->saveinfo($rec->{Path},$info)
+ or return con_err($console,sprintf(gettext("Couldn't write file '%s' : %s"),$rec->{Path} . '/info.vdr',$!));
+
$dropEPGEntry = 1;
}
@@ -1877,10 +1904,6 @@ WHERE
$ChangeRecordingData = 1;
}
- $data->{title} =~s#~+#~#g;
- $data->{title} =~s#^~##g;
- $data->{title} =~s#~$##g;
-
if($data->{title} ne $rec->{title}) {
# Rename auf der Platte
diff --git a/lib/XXV/MODULES/TIMERS.pm b/lib/XXV/MODULES/TIMERS.pm
index 5c9275e..ab06713 100644
--- a/lib/XXV/MODULES/TIMERS.pm
+++ b/lib/XXV/MODULES/TIMERS.pm
@@ -374,7 +374,7 @@ sub _init {
return 0;
}
- my $version = 26; # Must be increment if rows of table changed
+ my $version = 27; # Must be increment if rows of table changed
# this tables hasen't handmade user data,
# therefore old table could dropped if updated rows
if(!tableUpdated($obj->{dbh},'TIMERS',$version,1)) {
@@ -393,7 +393,7 @@ sub _init {
Priority tinyint(2),
Lifetime tinyint(2),
File text,
- Summary text default '',
+ aux text default '',
NextStartTime datetime,
NextStopTime datetime,
Collision varchar(100) default '0',
@@ -458,7 +458,7 @@ sub saveTimer {
int($data->{Priority}),
int($data->{Lifetime}),
$data->{File},
- ($data->{Summary} || '')
+ ($data->{aux} || '')
)
);
@@ -475,7 +475,7 @@ sub saveTimer {
int($data->{Priority}),
int($data->{Lifetime}),
$data->{File},
- ($data->{Summary} || '')
+ ($data->{aux} || '')
], $pos);
}
@@ -499,7 +499,7 @@ sub newTimer {
SELECT SQL_CACHE
eventid,
channel_id,
- description as Summary,
+ description,
CONCAT_WS('~', title, subtitle) as File,
DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) - ? ), '$dayFormat') as Day,
DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) - ? ), '%H%i') as Start,
@@ -521,7 +521,7 @@ WHERE
$epg = {
channel_id => '',
File => '',
- Summary => '',
+ description => '',
Day => my_strftime($dayFormat,$t),
Start => my_strftime("%H%M",$t),
Stop => my_strftime("%H%M",$t)
@@ -534,10 +534,7 @@ WHERE
if(not defined $epg->{Priority});
$epg->{Lifetime} = $obj->{Lifetime}
if(not defined $epg->{Lifetime});
- if(main::getVdrVersion() >= 10344) {
- $epg->{desc} = $epg->{Summary};
- $epg->{Summary} = ""
- }
+
if($epg->{VpsStart} && $obj->{usevpstime} eq 'y') {
$epg->{Status} |= 4;
$epg->{Day} = $epg->{VpsDay};
@@ -565,7 +562,7 @@ SELECT SQL_CACHE
Id,
ChannelID as channel_id,
File,
- Summary,
+ aux,
Start,
Stop,
Day,
@@ -584,8 +581,8 @@ WHERE
$timerData = $data;
}
- $timerData->{Summary} =~ s/(\r|\n)//sig
- if(defined $timerData->{Summary});
+ $timerData->{aux} =~ s/(\r|\n)//sig
+ if(defined $timerData->{aux});
my $mod = main::getModule('CHANNELS');
my $con = $console->typ eq "CONSOLE";
@@ -720,42 +717,24 @@ WHERE
def => $timerData->{File},
req => gettext("This is required!"),
},
- ];
-
- my $Summary = $timerData->{Summary};
- $Summary =~s/\#~AT\[(\d+)\]//g;
-
- if(main::getVdrVersion() >= 10344){
- if($timerData->{Id} || $timerData->{desc}) {
- my $desc = $timerData->{desc} || $obj->getEpgDesc($timerData->{Id});
- if($desc) {
- push(@$questions,
- 'Description' => {
- msg => gettext('Description'),
- typ => 'string',
- def => $desc,
- readonly => 1
- });
- }
+ 'aux' => {
+ typ => 'hidden',
+ def => $timerData->{aux},
}
+ ];
- push(@$questions,
- 'Summary' => {
- typ => 'hidden',
- def => $Summary,
- });
- } else {
- push(@$questions,
- 'Summary' => {
- msg => gettext('Additional description'),
- def => $Summary,
- check => sub{
- my $value = shift || return;
- $value =~ s/(\r|\n)//sig;
- return $value;
- },
- });
- }
+ if($timerData->{Id} || $timerData->{description}) {
+ my $description = $timerData->{description} || $obj->getEpgDesc($timerData->{Id});
+ if($description) {
+ push(@$questions,
+ 'Description' => {
+ msg => gettext('Description'),
+ typ => 'string',
+ def => $description,
+ readonly => 1
+ });
+ }
+ }
# Ask Questions
my $datasave = $console->question(($timerid ? gettext('Edit timer')
: gettext('New timer')), $questions, $data);
@@ -1265,7 +1244,7 @@ sub getCheckTimer {
my $sql = qq|
SELECT SQL_CACHE t.Id as Id, t.Status as Status,t.ChannelID as ChannelID,
t.Priority as Priority, t.Lifetime as Lifetime,
- t.File as File, t.Summary as Summary,
+ t.File as File, t.aux as aux,
t.Start as TimerStart,t.Stop as TimerStop,
UNIX_TIMESTAMP(e.starttime) as starttime,
@@ -1315,7 +1294,7 @@ SELECT SQL_CACHE t.Id as Id, t.Status as Status,t.ChannelID as ChannelID,
VPS => (($erg->{$t}->{Status} & 4) ? 'y' : 'n'),
ChannelID => $erg->{$t}->{ChannelID},
File => $erg->{$t}->{File},
- Summary => $erg->{$t}->{Summary},
+ aux => $erg->{$t}->{aux},
Day => my_strftime($dayFormat,$start),
Start => my_strftime("%H%M",$start),
Stop => my_strftime("%H%M",$stop),