Linux-DVB-DVBT-Apps-QuartzPVR
view release on metacpan or search on metacpan
lib/Linux/DVB/DVBT/Apps/QuartzPVR/Iplayer.pm view on Meta::CPAN
}
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::waypoint("IPLAY processed recordings") ;
Linux::DVB::DVBT::Apps::QuartzPVR::Prog::disp_sched("IPLAY Final schedule:", $schedule_aref) if ($this->debug) ;
# Report
$this->_new_phase('final IPLAY') ;
$tvreport->scheduling($schedule_aref, []) ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::endfn() ;
}
#---------------------------------------------------------------------
# Schedule a single IPLAY program for the following day at the specified time
#
sub _schedule_recording
{
my $this = shift ;
my ($prog_href) = @_ ;
print "Iplayer::_schedule_recording()\n" if $this->debug >= 4 ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::startfn() ;
## Calc date of recording
#
# | day | day+1 | day+2 |
# ^----^ ^
# |------+2days---------------------|
# :<--------|
# : : : :
# use this
# get_iplay
# download slot
#
#
my $end_dt = $prog_href->{'end_datetime'} ;
$end_dt = Linux::DVB::DVBT::Apps::QuartzPVR::Time::dt_offset($end_dt, "+ 1 day") ;
my $entry_href = {%$prog_href} ;
$entry_href->{'date'} = Linux::DVB::DVBT::Apps::QuartzPVR::Time::dt2date($end_dt) ;
$entry_href->{'start'} = $this->iplay_time ;
Linux::DVB::DVBT::Apps::QuartzPVR::Prog::set_times($entry_href) ;
$entry_href->{'prog_date'} = $prog_href->{'date'} ;
$entry_href->{'prog_start'} = $prog_href->{'start'} ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::endfn() ;
return $entry_href ;
}
#---------------------------------------------------------------------
# Update cron jobs
#
sub update_cron
{
my $this = shift ;
my ($schedule_aref) = @_ ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgTrace::startfn('update cron') ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::startfn() ;
## Set cron
Linux::DVB::DVBT::Apps::QuartzPVR::Crontab::update_iplay($schedule_aref) ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::endfn() ;
}
#---------------------------------------------------------------------
# Commit the final schedule (both to database and cron jobs)
#
sub commit
{
my $this = shift ;
my ($schedule_aref, $test) = @_ ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgTrace::startfn('commit') ;
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::startfn() ;
## Set database
my $tvsql = $this->_tvsql ;
unless ($test>=2)
{
## Enter sorted by record id RID
my @sorted = sort { $a->{'rid'} <=> $b->{'rid'} } @$schedule_aref ;
$tvsql->update_iplay_table(\@sorted) ;
}
Linux::DVB::DVBT::Apps::QuartzPVR::Base::DbgProf::endfn() ;
}
#---------------------------------------------------------------------
# Remove any recordings matching this RID
#
#
sub unschedule
{
my $this = shift ;
my ($schedule_aref, $rid) = @_ ;
my @sched = (@$schedule_aref) ;
@$schedule_aref = () ;
foreach my $href (@sched)
{
if ($href->{'rid'} != $rid)
{
push @$schedule_aref, $href ;
}
}
}
#---------------------------------------------------------------------
# Replace all rids set to NEW_RID with the specified new value
#
sub update_rid
{
my $this = shift ;
my ($new_rid, $schedule_aref) = @_ ;
foreach my $href (@$schedule_aref)
{
my @progs = ($href) ;
foreach my $rec_href (@progs)
{
if ($rec_href->{'rid'} == $Linux::DVB::DVBT::Apps::QuartzPVR::Base::Constants::NEW_RID)
{
$rec_href->{'rid'} = $new_rid ;
}
}
}
}
#---------------------------------------------------------------------
# Start a new scheduling phase
sub _new_phase
{
my $this = shift ;
my ($phase) = @_ ;
## save phase for tracing
$this->phase($phase) ;
## set report
my $tvreport = $this->_tvreport ;
$tvreport->new_phase($phase) ;
}
#---------------------------------------------------------------------
# filter out any recordings that include DVBT (they get handled elsewhere)
#
sub filter_iplay
{
my $this = shift ;
my ($recording_schedule_aref) = @_ ;
my @iplay_only_recordings = () ;
foreach my $prog_href (@$recording_schedule_aref)
{
if ($prog_href->{'type'} eq 'multiplex')
{
my @progs = @{$prog_href->{'multiplex'}} ;
@{$prog_href->{'multiplex'}} = () ;
foreach my $href (@progs)
{
if (Linux::DVB::DVBT::Apps::QuartzPVR::Base::Constants::has_iplay($href->{'record'}))
{
# skip anything that doesn't have IPLAY
push @{$prog_href->{'multiplex'}}, $href ;
}
}
# save multiplex if multiplex actually contains something
if (@{$prog_href->{'multiplex'}})
( run in 2.629 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )