tvheadend/tvheadend — pull request #408 by ProfYaffle (2014-05-30 16:51:10+00:00)
Title: Not for merge: For discussion - concept of filtering EPG on duration

I don't know if PRs are the right way to do this, but it's done now :)

Thoughts, please. I've just tweaked epg.js to created a prototype filter on duration - if it's got legs, I'll look to implement the needed changes into epg.c.

![filter](https://cloud.githubusercontent.com/assets/6093716/3133470/7aa8c232-e81a-11e3-9652-1779f6c2da8f.png)

#### Problem Statement

I find the genre tags somewhat random - not every movie gets tagged by the broadcaster, for example. So, having a way to say "give me everything > 1.5 hours on HD channels" might be an alternative way of seeing what's on.

#### Musings

* Am I the only one who thinks that this would be useful?

* Would we need this in autorec, i.e. is there *really* any reason to have "autorec everything > 1.5 hours on HDTV"? That obviously has a ripple effect through more code, and I'm not sure of its usefulness - but, equally, I don't know the implications of not having it because filtering the EPG and then triggering an autorec event would give you a spurious set of matches if it's not included.

* If not autorec then you could still set individual events, or course, so it's not disaster. It could be a filter purely for finding programmes.

* What options would make sense in a pick list - the three shown, or more?

* Would a regexp make sense? I don't think so given how much trouble people would be likely to have and the fact that it's testing vs the real underlying duration, which is stored in seconds - also, why use string handling on a number?

* Would it make sense (it'd certainly be easier!) to have two filters - "longer than x" and "shorter than y" (with or without handling to ensure y > x - I'm inclined to simply return no results if you're that careless)? You could then simply pass those two mappings (e.g. "> 30 min" maps to a minimum duration of 1800s, so pass "min_duration = 1800"). That'd also address the "how many options?" question, as you could have 15-minute increments on both (for example).

* Any pointers in the code? I think it's 'simply' a case of adjusting epg_query, epg_query0, _eqr_add and _eqr_add_channel in epg.c so that the duration parameters are passed through. autorec obviously then has its own implications as well, and that's part of the uncertainty - it could be work for something that, while consistent, is ultimately purposeless.

I can't promise I can do this, I'll say that now, but I'll certainly have a look.