Reliable stripping of padding from recording timers

Moderators: Gully, peteru

Post Reply
prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Reliable stripping of padding from recording timers

Post by prl » Tue Feb 16, 2016 16:35

When I get the instant recording changes I've been working on tucked away, I'm considering on doing the work to make it possible to calculate a recording timer's unpadded time. Amongst other things, it's likely to prevent short IceTV recordings from getting the wrong description and from matching the incorrect EPG slot for Change Timer.

At the moment, a recording timer is created like this ("=" entries are default values):

Code: Select all

	RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled=False, justplay=False, afterEvent=AFTEREVENT.AUTO,
		checkOldTimers=False, dirname=None, tags=None, descramble='notset', record_ecm='notset', isAutoTimer=False,
		ice_timer_id=None, always_zap=False, rename_repeat=True)
When a padded recording timer is created, it's something like:

Code: Select all

	begin = epg_begin_time - config.recording.margin_before.value * 60 # recording margin is in minutes
	end = epg_end_time + config.recording.margin_after.value * 60
	RecordTimerEntry(serviceref, begin, end, name, description, eit, ...)
What I'm proposing is to add a couple of extra (!) optional arguments to constructing a RecordTimerEntry

Code: Select all

RecordTimerEntry(timer.TimerEntry, object):
	RecordTimerEntry(serviceref, begin, end, name, description, eit, disabled=False, justplay=False, afterEvent=AFTEREVENT.AUTO,
		checkOldTimers=False, dirname=None, tags=None, descramble='notset', record_ecm='notset', isAutoTimer=False,
		ice_timer_id=None, always_zap=False, rename_repeat=True,
		before_margin=0, after_margin=0)
So now that you'd do:

Code: Select all

	RecordTimerEntry(serviceref, epg_begin_time, epg_end_time, name, description, eit, ...,
		before_margin=config.recording.margin_before.value * 60,
		after_margin=config.recording.margin_after.value * 60)
Internally, the RecordTimerEntry would calculate

Code: Select all

self.begin = begin - before_margin
self.end = end + after_margin
self.beforeMargin = before_margin
self.afterMargin = after_margin
and define properties like:

Code: Select all

	unpaddedBegin = property(lambda self: self.begin + self.beforeMargin)
	unpaddedEnd = property(lambda self: self.end - self.afterMargin)
Entries in timers.xml would get new attributes before_margin and after_margin that would default to '0' if absent.

AutoTimers and IceTV timers would convert across to the new form automatically as new timers are created, typically changing over completely in about a week. Existing padded repeating timers (e.g. created in the EPG) would need to be re-created manually to take advantage of the new feature.

Manually entered timers would be created with the padding values as 0.

This would also potentially allow per-timer padding settings.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: Reliable stripping of padding from recording timers

Post by IanSav » Tue Feb 16, 2016 20:52

Hi Prl,

Could existing manual timers be updated to the new format by editing the existing timer and saving it without making any changes?

Regards,
Ian.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Reliable stripping of padding from recording timers

Post by prl » Tue Feb 16, 2016 21:59

I'm not sure how to do the timer editing yet. It's mostly of interest for timers set from the EPG, and "delete old timer, create new timer, adjust repeat" doesn't sound much harder than trying to set the correct padding parameters. I don't think that it should just do automatically adjust all existing timers.

But I'm open to suggestions.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

User avatar
peteru
Uber Wizard
Posts: 9741
Joined: Tue Jun 12, 2007 23:06
Location: Sydney, Australia
Contact:

Re: Reliable stripping of padding from recording timers

Post by peteru » Tue Feb 16, 2016 23:40

Couple of comments...

* See if you can apply consistent naming. Padding vs margin. To preserve compatibility you may need to stick with margin. Or is there a good argument for having both names?
* Consider handling the margins as a single tuple rather than two arguments/variables. i.e margin=(0,0) instead of before_margin=0, after_margin=0. Less code and easier to read.

"Beauty lies in the hands of the beer holder."
Blog.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Reliable stripping of padding from recording timers

Post by prl » Wed Feb 17, 2016 09:03

peteru wrote:Couple of comments...

* See if you can apply consistent naming. Padding vs margin. To preserve compatibility you may need to stick with margin. Or is there a good argument for having both names?
No good reason. Perhaps something like programBegin and programEnd instead of "unpadded" begin/end. I can't think of names that use "margin" for that context that aren't clunky.
peteru wrote:* Consider handling the margins as a single tuple rather than two arguments/variables. i.e margin=(0,0) instead of before_margin=0, after_margin=0. Less code and easier to read.
I'm fine with that. I just used the separate arguments for margin_before and margin_after to follow the use of separate begin/end names in the __init__() argument list and the naming of the config variables.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Post Reply

Return to “Developers Community”