FAQ  •  Register  •  Login

RSS feed plugin - code to run once per feed update?

<<

ttguy

Serviio lover

Posts: 63

Joined: Sun May 27, 2012 10:52 am

Post Mon Sep 03, 2012 2:10 pm

RSS feed plugin - code to run once per feed update?

So I have created a plugin for ABC TV Australias iView service. But to get the play path for the videos I have emulated a iView downloader called python-iview by Jeremy Visser https://jeremy.visser.name/2012/05/pyth ... red-users/
Each of the RSS feed items contains an episode ID.
We requires a four step operation to get the playpath for the episode.

First we get a JSON file that contains a list of all the available series and the episode IDs associated with these.
Second we use this data to find the series ID that this episode belongs to.
Third we query a different JSON source using the seriesID to get the play paths for all the episodes for the series.
Fourth we return only the playpath for feed items episode ID

This task would be resouce intensive to repeat from begining to end for every item in the feed. So my plugin populates a Map object of all the data it extracts in step 1.
Then for each feed item it only needs to do step 3 and 4.

Currently my plugin does the Map object population from extractorMatches() method (if the extractor does Match). And this seems to work - since this method is apparently only called once per feed. But what I would really like is to have this code execute once when ever the feed updates. Because I am concerned that my Map will become out of date as time moves on if extractorMatches() method only executes one time - when serviio starts.

Is there a way to do that?

A copy of my plugin is attached. I would like feed back on this as this is a newbie attempt at plugin writing.
Attachments
ABCiView.groovy
Plugin for ABC TV Australia iView - version 0.1 - for review
(16.29 KiB) Downloaded 597 times
--
linux/Humax HDR-3000T
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Mon Sep 03, 2012 5:55 pm

Re: RSS feed plugin - code to run once per feed update?

No it refreshes at the interval set in the console as well, or you can add "expires on" if you want it to refresh sooner than that default.
Unfortunately your plugin will only work in .au due to abc's restrictions.
<<

ttguy

Serviio lover

Posts: 63

Joined: Sun May 27, 2012 10:52 am

Post Mon Sep 03, 2012 10:30 pm

Re: RSS feed plugin - code to run once per feed update?

jhb50 wrote:No it refreshes at the interval set in the console as well, or you can add "expires on" if you want it to refresh sooner than that default.
Unfortunately your plugin will only work in .au due to abc's restrictions.


Are you saying that extractorMatches() executes whenever the feed updates? Because if this is the case then I am happy. I am looking for a place to execute code that runs every time the entire feed is updated. But not for each individual feed item. And I am not sure if extractorMatches() runs every time the feed updates or only right at the start of the plugin load process.

Yes the plugin will only work in Oz due to geo blocking.
--
linux/Humax HDR-3000T
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Mon Sep 03, 2012 10:53 pm

Re: RSS feed plugin - code to run once per feed update?

Yes, both methods run.
<<

ttguy

Serviio lover

Posts: 63

Joined: Sun May 27, 2012 10:52 am

Post Tue Sep 04, 2012 10:41 am

Re: RSS feed plugin - code to run once per feed update?

jhb50 wrote:Yes, both methods run.


What do you mean "both" methods? I just asked about one method - extractorMatches(). Do you mean "both times". - in reply to my question about whether it runs " every time the feed updates or only right at the start of the plugin load process" ?

Anyway. I think I can see from my logs that extractorMatches() is called when the feeds is updated. So all is good I think with my logic.
--
linux/Humax HDR-3000T
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Tue Sep 04, 2012 1:43 pm

Re: RSS feed plugin - code to run once per feed update?

I was referring to ExtractItems and ExtractURL. ExtractorMatches is only used to determine if your plugin is the correct one to use whenever any feed is used. Looking at your plugin you need to move the item stuff to ExtractItems per the plugin guide.
<<

ttguy

Serviio lover

Posts: 63

Joined: Sun May 27, 2012 10:52 am

Post Tue Sep 04, 2012 2:36 pm

Re: RSS feed plugin - code to run once per feed update?

jhb50 wrote: Looking at your plugin you need to move the item stuff to ExtractItems per the plugin guide.


No I do not. If you read my introductory post you will understand that I have code that I only want to run once when the whole feed is updated. That is my whole point in this thread. I want a place where I can call something that only runs once per feed update. And I have a good reason to only needing it run once per feed update - efficency.

My plugin works as it stands.
--
linux/Humax HDR-3000T
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Tue Sep 04, 2012 10:20 pm

Re: RSS feed plugin - code to run once per feed update?

You totally misunderstand the plugin architecture. read the guide and use the 2 methods I described to find the items and then extract the urls. Creating the list of items everytime the feed is called is a massive waste of resources.
<<

ttguy

Serviio lover

Posts: 63

Joined: Sun May 27, 2012 10:52 am

Post Wed Sep 05, 2012 4:35 pm

Re: RSS feed plugin - code to run once per feed update?

jhb50 wrote:You totally misunderstand the plugin architecture. read the guide and use the 2 methods I described to find the items and then extract the urls. Creating the list of items everytime the feed is called is a massive waste of resources.


No you totally missunderstand how my plugin works and how the ABC iView service works.

As I explained in my first post the RSS feed items sends in program IDs. And the only way to find play paths is via a series number. But you can not look up series number via a program ID. You can however get a list of all series with the program IDs that are part of the series. Therefore, I need to create a complete list of all the series and then I need to look up the series ID using the program ID from the RSS feed item. Now I have two options I can build the series ID to program ID map once for the 95 feed items on the RSS feed and store the info in a Map structure - the way my plugin works. Or I could build the map 95 times for each feed item - your suggestion.

Which do you think is most efficient?
--
linux/Humax HDR-3000T
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Sep 05, 2012 9:08 pm

Re: RSS feed plugin - code to run once per feed update?

you are doing it right, the extractorMatches() method is called when a feed expires and Serviio checks if the feed url (now possibly updated) matches the plugin
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Wed Sep 05, 2012 9:38 pm

Re: RSS feed plugin - code to run once per feed update?

Gee zip. That's great news. So I can move all my logic out of extractItems and build a map in extractorMatches like this ABC grrovy and not get hit by the 30 second timeout in extractItems.

I guess I misundestood last year when I thought you told me not to extract during extractorMatches.

I do wonder though why you added WebResources when all this can be done with extractorMatches and extractURl.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Sep 06, 2012 11:26 am

Re: RSS feed plugin - code to run once per feed update?

extractorMatches is not originally designed to do this, but it is called only once and might serve the purpose to read a static data that is needed only once. It should not extract any content URL's though as it's not called any time after the initial call, especially if your URLs are expiresImmediately=true

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 15 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.