Exemple #1
0
// Update receives the updated *pt.IEPG record to update the scheduled recording time.
func (r *PT1Recorder) Update(iepg *pt.IEPG) {
	if iepg == nil {
		r.Stop()
	} else {
		if r.stats.Status == pt.IEPGScheduled {
			r.iepg.ProgramTitle = iepg.ProgramTitle
		}
		if !r.iepg.StartAt.Equal(iepg.StartAt) {
			r.logger.Debugf(
				"Updating StartAt field: %q -> %q",
				lib.FormatDateTimeString(r.iepg.StartAt),
				lib.FormatDateTimeString(iepg.StartAt),
			)
			r.iepg.StartAt = iepg.StartAt
		}
		if !r.iepg.EndAt.Equal(iepg.EndAt) {
			r.logger.Debugf(
				"Updating EndAt field: %q -> %q",
				lib.FormatDateTimeString(r.iepg.StartAt),
				lib.FormatDateTimeString(iepg.StartAt),
			)
			r.iepg.EndAt = iepg.EndAt
		}
	}
}
Exemple #2
0
func (r *PT1Recorder) waitForScheduledTime() {
	for {
		if r.iepg.StartAt.Add(-r.cfg.ProcessPreparationTime).Sub(lib.Now()) <= 0 {
			return
		}
		r.logger.Tracef(
			"Waiting %s for the next schedule check until %s",
			r.cfg.ProcessPreparationTime,
			lib.FormatDateTimeString(r.iepg.StartAt),
		)
		select {
		case <-r.stopChannel:
			r.logger.Debugf("A stop flag received, cancel recording...")
			r.stats.Status = pt.IEPGCanceled
			r.stopChannel <- true
			return
		case <-time.Tick(r.cfg.ProcessPreparationTime):
			break
		}
	}
}