FAQ  •  Register  •  Login

Plugin development problem

<<

brainforge.uk

Serviio newbie

Posts: 7

Joined: Sat Jan 28, 2017 5:19 pm

Post Thu Jun 08, 2017 8:28 am

Plugin development problem

I have a bare example plugin named brainforge.groovy coded as follows:
  Code:
import org.serviio.library.metadata.MediaFileType;
import org.serviio.library.online.*;

/**
 * WebResource extractor plugin example
 *
 * @author  Jonathan Brain
 * @website http://brainforge.co.uk
 * @version 1.0
 */
class BrainForge extends WebResourceUrlExtractor{
    protected final static VALID_WEB_RESOURCE_URL = '^brainforge://.*.pxf.*$'
   protected static final int PLUGIN_VERSION     = 1
   
    @Override
    protected WebResourceContainer extractItems(URL url, int i) {
        // TODO
        // return uk.co.brainforge.serviio.dosomething(url);
        String webResourceTitle="Unknown title"
        String thumbnailUrl="";
        return new WebResourceContainer(title: webResourceTitle ,thumbnailUrl:thumbnailUrl, items: items)
    }

    @Override
    protected ContentURLContainer extractUrl(WebResourceItem webResourceItem, PreferredQuality preferredQuality) {
        return new ContentURLContainer(fileType:MediaFileType.IMAGE, thumbnailUrl:webResourceItem.additionalInfo.thumbnailURL, contentUrl:webResourceItem.additionalInfo.sourceURL)
    }

    @Override
    boolean extractorMatches(URL url) {
   return true;
    }

    @Override
    String getExtractorName() {
        return getClass().getName()
    }

    @Override
    int getVersion() {
        return PLUGIN_VERSION;
    }
}


In the Serviio library I have a Web Resource configured.
Media type image selected.
Source URL configured as:
  Code:
brainforge://t:/temp/temp.pxf


In serviio.log I see the following messages:
2017-06-08 09:13:27,075 INFO [PluginCompilerThread] Added Web Resouce plugin BrainForge (brainforge.groovy), version: 1
2017-06-08 09:14:02,049 WARN [FeedUpdaterWorker] An error occured while trying to parse an online resouce requiring a plugin, provide the plugin or remove the resource: No plugin for web resource brainforge://t:/temp/temp.pxf has been found.


Why is my plugin not being found :?:
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16499

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Jun 08, 2017 12:37 pm

Re: Plugin development problem

Do you have any other plugins? This plugin will be used for any URL (as your extractorMatches() always returns true).

anyway, this is the method used for matching, so it should work for your example.

What if you try a different URL in the console, like brainforge://foo ?
<<

brainforge.uk

Serviio newbie

Posts: 7

Joined: Sat Jan 28, 2017 5:19 pm

Post Thu Jun 08, 2017 1:55 pm

Re: Plugin development problem

Thanks.
This is a new install on a machine which has never has Serviio before.
No other plugins.
No other entries in Library / Online Sources or Library / Shared folders.

I thought a simple 'do nothing' plugin like this would be a good starting point.
Creating a proper extractorMatches() method would be the next step, if current code worked.
  Code:
    @Override
    boolean extractorMatches(URL url) {
        return url ==~ VALID_WEB_RESOURCE_URL
    }


Tried your foo suggestion - just gives me another warning.
2017-06-08 14:37:50,769 INFO [PlaylistMaintainerWorker] Started looking for playlist changes
2017-06-08 14:38:50,487 WARN [FeedUpdaterWorker] An error occured while trying to parse an online resouce requiring a plugin, provide the plugin or remove the resource: No plugin for web resource brainforge://t:/temp/temp.pxf has been found.
2017-06-08 14:38:50,488 WARN [FeedUpdaterWorker] An error occured while trying to parse an online resouce requiring a plugin, provide the plugin or remove the resource: No plugin for web resource brainforge://foo has been found.


In MediaBrowser the Home / Image Online page is empty.
I was expecting an empty listing titled 'Unknown' - instead got warning in log file.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16499

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Fri Jun 09, 2017 6:52 pm

Re: Plugin development problem

Ok, reproduced it. The problem is that your feed Url is not URL, but a URI. So you need to implement extractorMatches() and extractItems() that take URI instead of URL, and also implement the URL versions of these that just throw exceptions. Like this:
  Code:
    @Override
    protected WebResourceContainer extractItems(URI url, int i) {
        // TODO
        // return uk.co.brainforge.serviio.dosomething(url);
        String webResourceTitle="Unknown title"
        String thumbnailUrl="";
        return new WebResourceContainer(title: webResourceTitle ,thumbnailUrl:thumbnailUrl, items: [])
    }

    @Override
    WebResourceContainer extractItems(URL resourceUrl, int maxItems) {
        throw new RuntimeException("Not implemented");
    }


    @Override
    boolean extractorMatches(URI webResourceUrl) {
        return webResourceUrl ==~ VALID_WEB_RESOURCE_URL
    }

    @Override
    public boolean extractorMatches(URL webResourceUrl) {
        throw new RuntimeException("Not implemented");
    }

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 2 guests

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