FAQ  •  Register  •  Login

RSS parser class

<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Tue Jan 08, 2013 9:00 am

RSS parser class

Is the built in RSS parser available from plugins? I.e. calling its extractorMatches()?
And btw., is it possible to get from one plugin a list of available plugins?
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Jan 08, 2013 9:29 am

Re: RSS parser class

mqojdn wrote:Is the built in RSS parser available from plugins? I.e. calling its extractorMatches()?

Serviio ships with Rome RSS parsing library, so you have that to your disposal. Although if that changed in future your plugin would stop working.

And btw., is it possible to get from one plugin a list of available plugins?

You could call the REST API to get that.
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Tue Jan 08, 2013 10:49 am

Re: RSS parser class

zip wrote:You could call the REST API to get that.

How is that?
And isn't there some Groovy way to get that? Like a master WebResourceUrlExtractor or something?

zip wrote:Serviio ships with Rome RSS parsing library, so you have that to your disposal. Although if that changed in future your plugin would stop working.

The idea is to join multiple feeds by calling builtInRssPlugin.extractItems() from the plugin for several URLs, and then joining results into one WebResourceContainer and passing back to Serviio.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Jan 08, 2013 11:12 am

Re: RSS parser class

mqojdn wrote:
zip wrote:You could call the REST API to get that.

How is that?

Check the API docs: http://docs.serviio.apiary.io/

And isn't there some Groovy way to get that? Like a master WebResourceUrlExtractor or something?


try calling

  Code:
org.serviio.library.online.AbstractOnlineItemParser.getListOfPlugins()


But this will stop working if I move the method/class.
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Tue Jan 08, 2013 11:48 am

Re: RSS parser class

zip wrote:Check the API docs: http://docs.serviio.apiary.io/
try calling
  Code:
org.serviio.library.online.AbstractOnlineItemParser.getListOfPlugins()


Thanks.

And in case you missed:
zip wrote:Serviio ships with Rome RSS parsing library, so you have that to your disposal. Although if that changed in future your plugin would stop working.

The idea is to join multiple feeds by calling builtInRssPlugin.extractItems() from the plugin for several URLs, and then joining results into one WebResourceContainer and passing back to Serviio.
Without writing any code. But it seems that that Rome library would work with just a few lines of code.

And btw., is there any HTML escape/unescape libs included with Serviio? Like org.apache.commons.lang.StringEscapeUtils.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Jan 08, 2013 12:12 pm

Re: RSS parser class

yes, check the lib folder
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Tue Jan 08, 2013 6:33 pm

Re: RSS parser class

zip wrote:yes, check the lib folder

Checked those, nothing rings the bell. A push in the right direction wouldn't hurt, not everyone have a Java background.
<<

will

DLNA master

Posts: 2138

Joined: Mon Aug 30, 2010 11:18 am

Location: UK

Post Tue Jan 08, 2013 7:15 pm

Re: RSS parser class

org.apache.commons.lang.StringEscapeUtils is in the commons-lang.jar file, so yes you can use that
Will

ServiiDroid (Android Console) Developer: Download | Home | Support
ServiiGo (Android 3G/4G/WiFi Playback App) Developer: Download | Home | Support
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Tue Jan 08, 2013 7:37 pm

Re: RSS parser class

will wrote:org.apache.commons.lang.StringEscapeUtils is in the commons-lang.jar file, so yes you can use that

Thanks.

@zip:
I'm trying to load a mixed RSS feed, loading required plugins when needed. But I have 2 questions, see comments below:
  Code:
    private void populatePluginList() {
        pluginList = ["YouTube"];
        // How would I get the list from org.serviio.library.online.AbstractOnlineItemParser.getListOfPlugins()?
    }

    private FeedItemUrlExtractor getClassByName(String name) {
        def instance = this.class.classLoader.loadClass(name, true, false)?.newInstance();
        return instance;
    }

    private FeedItemUrlExtractor getPluginByURL(String url) {
        FeedItemUrlExtractor plugin = null;
       
        pluginList.each {
            FeedItemUrlExtractor test = getClassByName(it);
            if(test) {
                if(test.extractorMatches(new URL(url))) {
                    plugin = test;
                }
            }
        }
       
        return plugin;
    }

    @Override
    protected ContentURLContainer extractUrl(Map links, PreferredQuality preferredQuality) {
        populatePluginList();
       
        URL linkUrl = links.default;
        FeedItemUrlExtractor plugin = getPluginByURL(linkUrl.toString());
        if(plugin) {
            pluginLog("Loaded: " + plugin.getExtractorName());
        } else {
            pluginLog("Loaded: NULL");
            return null;
            // How would I pass that to the default Serviio's RSS parser?
            // i.e. return defaultPlugin.extractUrl(links, preferredQuality);
        }

        return plugin.extractUrl(links, preferredQuality);
    }
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Tue Jan 08, 2013 8:35 pm

Re: RSS parser class

the method that lists plugins doesn't return classes, only display names of the plugins, so you won't be able to instantiate them.
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Tue Jan 08, 2013 8:39 pm

Re: RSS parser class

All I need is names. They are instantaned no problem with:
  Code:
    private FeedItemUrlExtractor getClassByName(String name) {
        def instance = this.class.classLoader.loadClass(name, true, false)?.newInstance();
        return instance;
    }

Like the YouTube class gets instantaned from "YouTube".

And please see the question in the second comment.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Jan 09, 2013 12:05 am

Re: RSS parser class

No, the name may be different from the class name.

e.g. "4OD (UK only)" vs. Channel4od.class
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Wed Jan 09, 2013 12:31 am

Re: RSS parser class

Most of them are returning getClass().getName(). And I can live without a few that aren't. So how would I get these?

And what about the default Serviio's RSS plugin? The one that is called when there are no plugins?
Like in the example above. I try to match the extractUrl() by probing against classes extractorMatches(), and if there is one, I pass the URL to that plugin. So how do I pass the URL to the default RSS plugin, when there are no matches.

For example in a feed I have mixed entries, form Youtube, and I forward these to the Youtube plugin, and "normal" ones, that are supported by the built in RSS parser. How would I pass these "normal" entries to the built in parser? Where Serviio passes these when no matching plugin is found?

And I get that it's not possible for the built in plugin to get the link to the media file from the link that is passed to extractUrl(), cause the link to the media file is in the other XML tag. So how would I signal the built in plugin to handle that entry? That shouldn't be too involved, just getting the caller class methods and signaling to handle that entry by itself. So how?

Or at least how would I get the XML or the current item part of the XML or the link to the XML while inside the extractUrl() call?
<<

miksa

Serviio lover

Posts: 68

Joined: Fri Nov 09, 2012 2:30 am

Post Wed Jan 09, 2013 3:35 am

Re: RSS parser class

mqojdn wrote:For example in a feed I have mixed entries, form Youtube, and I forward these to the Youtube plugin, and "normal" ones, that are supported by the built in RSS parser. How would I pass these "normal" entries to the built in parser? Where Serviio passes these when no matching plugin is found?
imho,

RSS plug-in : url is pre-loaded and parsed for items collection by serviio. plug-ih has to return media items from the collection.

Webresource plug-in : url should be loaded and parsed for items collection by plug-in and then it has to return media items from this collection.
- Mike
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Wed Jan 09, 2013 9:21 am

Re: RSS parser class

miksa wrote:RSS plug-in : url is pre-loaded and parsed for items collection by serviio. plug-ih has to return media items from the collection.
Webresource plug-in : url should be loaded and parsed for items collection by plug-in and then it has to return media items from this collection.


And that is exactly what I don't like. I'd prefer to have per item selection instead of per feed.

Either way, got bored waiting for help, and wrote the parser instead. Everything is working nicely, and mixed streams work just fine.

The problems:
- May I get that plugin list at last?),
- Do not see much use of any other plugins besides YouTube,
- Most plugins are written as Web Resources,
- Currently it's linked to the Yahoo Pipes URL, but it would work just fine with any RSS you'd throw at it. But if I'll set the URL filter to any then there would be no control of when it should load...
<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Mon Jan 14, 2013 7:38 pm

Re: RSS parser class

<<

mqojdn

Streaming enthusiast

Posts: 44

Joined: Thu Jan 03, 2013 6:39 pm

Post Wed Jan 16, 2013 7:48 am

Re: RSS parser class

zip wrote:
And btw., is it possible to get from one plugin a list of available plugins?

You could call the REST API to get that.


Could you also provide the class name? Something like:
  Code:
    <onlinePlugin>
        <name>You Tube</name>
        <class>Youtube</class>
        <version>1</version>
    </onlinePlugin>

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 12 guests

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