Distant day filtering

For talk and Help about everything concerning TV-Browser.
Antworten
dingers01

Distant day filtering

Beitrag von dingers01 »

I am a newbie using tvbrowser and I'm very impressed with it. I'm moving from a home made excel macro solution and have manged to achieve most of what I was able to do previously (and much faster and with much more flexibility).
However there are two things I still can't manage, of which one at least I'm sure is possible with a bit more knowledge. This one is:

I would like to create a filter that only passes data that is within a certain number of days of today (for example the next 10 days worth)

I can't see anything in any of the standard filters that allows this (but maybe I missed something), except perhaps the beanshell filter. I have written C before so probably with enough research I could do it but in case some helpful soul can rattle something off from the top of their head in as little time as it took me to type this then I'd be very grateful.

I also thought that simply not downloading data more than 10 days in advance would work but it's only possible to specify that in whole number of weeks. I wonder as I'm typing this whether if I set the clock back 4 days and requested 2 weeks I would get actually 10 days from the true date but I wouldn't be surprised if this doesn't work and even if it does it's not very elegant.

So any ideas?

Bananeweizen
Site Admin
Beiträge: 3353
Registriert: 09 Sep 2006, 22:45

Re: Distant day filtering

Beitrag von Bananeweizen »

Believe it or not, but I have just committed this as a new filter component to our trunk yesterday: http://tvbrowser.org:8080/jira/browse/TVB-465.
But I guess it will still take some months until we release a new version from trunk. In principle, you could create a BeanShell filter using the same code, so it should look like this to filter for a week.

Code: Alles auswählen

import devplugin.Date;

public boolean accept(Program program) {
final Date progDate = program.getDate();
Date currentDate = Date.getCurrentDate();
Date mStartDate = currentDate.addDays(0);
Date mEndDate = currentDate.addDays(6);
return mStartDate.compareTo(progDate) <= 0 && progDate.compareTo(mEndDate) <= 0;
}

dingers01

Re: Distant day filtering

Beitrag von dingers01 »

Wow thanks, good timing!
I may have to wait for the filter to be implemented in a formal release perhaps as I didn't manage to get it working though.. If I paste the code snippet you supplied into a beanshell filter exactly I get an 'error parsing script' error.

To avoid this I re-introduced some of the lines from the original 'template' so I ended up with:

Code: Alles auswählen

import devplugin.beanshell.BeanShellProgramFilterIf;
import devplugin.Program;
import devplugin.ProgramFieldType;

import devplugin.Date;
public boolean accept(Program program) {
final Date progDate = program.getDate();
Date currentDate = Date.getCurrentDate();
Date mStartDate = currentDate.addDays(0);
Date mEndDate = currentDate.addDays(6);
return mStartDate.compareTo(progDate) <= 0 && progDate.compareTo(mEndDate) <= 0;
}

return (BeanShellProgramFilterIf) this;
This parses OK, but when I apply the filter it returns all programs (i.e. it doesn't filter).
I would guess it is something to do with the last (return) line but I'm not sure.

ds10
Site Admin
Beiträge: 17466
Registriert: 23 Jun 2005, 12:36
Kontaktdaten:

Re: Distant day filtering

Beitrag von ds10 »

For me this filter works. It shows all programs that are in a week. Did you try to restart TV-Browser?
"First they ignore you, then they ridicule you, then they fight you, then you win." - Mahatma Gandhi
Unterstütze die Weiterentwicklung von TV-Browser

dingers01

Re: Distant day filtering

Beitrag von dingers01 »

Just tried to re-start and still no joy.
Which version works for you (the original that gave me a parse error, or 'my' version with extra lines)?

FYI I am running TVB v2.72

dingers01

Re: Distant day filtering

Beitrag von dingers01 »

Hold on.. sorry it does work now.
I was being a fool. A re-start and paying more attention(!) has fixed it.
Thanks to Bananeweizen and ds10 for your help
Ding

Antworten