Project

General

Profile

Feature #1357 ยป xxv.1.7.0._EPG.pm_.precise_speedup_2013-05-02-alexrichter.patch

faup, 05/02/2013 03:00 PM

View differences:

./xxv/xxv/lib/XXV/MODULES/CHANNELS.pm 2013-05-02 11:27:29.783527788 +0200
}
# ------------------
sub NameToPos {
# ------------------
my $self = shift || return error('No object defined!');
my $name = shift || return undef;
my $sth = $self->{dbh}->prepare('SELECT SQL_CACHE pos from CHANNELS where name = ?');
$sth->execute($name)
or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
my $erg = $sth->fetchrow_hashref();
return $erg ? $erg->{pos} : undef;
}
# ------------------
sub PosToChannel {
# ------------------
my $self = shift || return error('No object defined!');
-- ./pure_xxv/xxv/etc/xxvd.cfg.example 2013-05-02 14:09:23.059693321 +0200
++ ./xxv/xxv/etc/xxvd.cfg.example 2013-05-02 14:48:54.779454048 +0200
......
interval=3600
periods=12:00,18:00,20:20,22:00,23:00,00:00,02:00,04:00
timeframe=2
daysinfuture=14
skipchannels=1000
[GRAB]
font=VeraBI.ttf
-- ./pure_xxv/xxv/lib/XXV/MODULES/EPG.pm 2013-05-02 14:09:23.151693783 +0200
++ ./xxv/xxv/lib/XXV/MODULES/EPG.pm 2013-05-02 13:57:48.112247265 +0200
......
type => 'integer',
required => gettext('This is required!'),
},
periods => {
description => gettext("Preferred program times. (eg. 12:00, 18:00)"),
default => '12:00,18:00,20:15,22:00',
......
required => gettext('This is required!'),
level => 'guest'
},
daysinfuture => {
description => gettext('How deep in future the EPG should be read (in days)'),
default => 7,
type => 'integer',
required => gettext('This is required!'),
},
skipchannels => {
description => gettext('until which Position of Channels will be read)'),
default => 10000,
type => 'integer',
required => gettext('This is required!'),
},
},
Commands => {
search => {
......
panic ("Couldn't get modul SVDRP");
return 0;
}
$self->{channels} = main::getModule ('CHANNELS'); # clist
unless($self->{channels}) {
panic ("Couldn't get modul CHANNELS");
return 0;
}
$self->startReadEpgData();
# Restart interval every x hours
......
my $channelname;
my $hostname = $self->{svdrp}->hostname($vid);
# read only epg until $self->{daysinfuture} days in the future ( prevent to read full 4 Weeks EPG from some German Broadcasters )
my $now = time ;
my $some_days = 60 * 60 * 24 * $self->{daysinfuture} ;
my $in_some_days = $now + $some_days ;
while($count < scalar $vdata) {
($vdrData,$channel,$channelname,$count) = $self->readEpgData($vid,$vdata,$count);
last if(not $channel);
......
$waiter->next($count,undef, sprintf(gettext("Analyze channel '%s'"), $channelname))
if(ref $waiter);
## use only channels lower pos $self->{skipchannels}
my $ergpos = $self->{channels}->NameToPos("$channelname"); # pos of channel from CHANNELS
next if ( $ergpos >= $self->{skipchannels} );
# First - read database
my $sql = qq|SELECT SQL_CACHE eventid, title, subtitle, length(description) as ldescription, duration, UNIX_TIMESTAMP(starttime) as starttime, UNIX_TIMESTAMP(vpstime) as vpstime, video, audio, content from EPG where vid = ? and channel_id = ? |;
my $sql = qq|SELECT SQL_NO_CACHE eventid, title, subtitle, length(description) as ldescription, duration, UNIX_TIMESTAMP(starttime) as starttime, UNIX_TIMESTAMP(vpstime) as vpstime, video, audio, content from EPG where vid = ? and channel_id = ? |;
my $sth = $self->{dbh}->prepare($sql);
$sth->execute($vid, $channel)
or return error sprintf("Couldn't execute query: %s.",$sth->errstr);
......
lg sprintf("Compare EPG Database with data from %s : %d / %d for channel '%s' - %s", $hostname, scalar keys %$db_data,scalar keys %$vdrData, $channelname, $channel);
# Compare this Hashes
foreach my $eid (keys %{$vdrData}) {
my $row = $vdrData->{$eid};
next if ( $row->{starttime} >= $in_some_days );
# Exists in DB .. update
if(exists $db_data->{$eid}) {
# Compare fields
foreach my $field (qw/title subtitle ldescription duration starttime vpstime video audio content/) {
next if(not exists $row->{$field} or not $row->{$field});
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})) {
......
);
my $sql = qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as \'$f{'id'}\',
e.title as \'$f{'title'}\',
e.subtitle as __Subtitle,
......
my $config = shift || return error('No config defined!');
my $cid = shift;
unless($cid) {
my $c = $self->{dbh}->selectrow_arrayref("SELECT SQL_CACHE hash from CHANNELS order by vid, pos limit 1");
my $c = $self->{dbh}->selectrow_arrayref("SELECT SQL_NO_CACHE hash from CHANNELS order by vid, pos limit 1");
return $console->err(gettext("No channel available!"))
unless($c && $c->[0]);
$cid = $c->[0];
......
);
my $sql = qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as \'$f{'id'}\',
e.title as \'$f{'title'}\',
e.subtitle as __Subtitle,
......
foreach my $table (qw/EPG OLDEPG/) {
my $sql = qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as \'$f{'Id'}\',
e.title as \'$f{'Title'}\',
e.subtitle as \'$f{'Subtitle'}\',
......
);
my $sql =
qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as \'$f{'Service'}\',
e.title as \'$f{'Title'}\',
e.subtitle as __Subtitle,
......
);
my $sql =
qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as \'$f{'Service'}\',
e.title as \'$f{'Title'}\',
e.subtitle as __Subtitle,
......
my $sql =
qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as Service,
e.title as Title,
e.subtitle as Subtitle,
......
my $sql =
qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.eventid as Service,
e.title as Title,
e.subtitle as __Subtitle,
......
my $eid = shift || return con_err($console, gettext('No event id defined!'));
my $sql = qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.starttime,
ADDDATE(e.starttime, INTERVAL e.duration SECOND) as stoptime,
LEFT(c.Source,1) as source,
......
}
my $sql = qq|
SELECT SQL_CACHE
SELECT SQL_NO_CACHE
e.title as title
FROM
EPG as e,
    (1-1/1)