Custom Function in built-in scraper?
#1
Hi everyone,

I'm trying to adapt the built-in tmdb scraper to better handle my files.
So far it seems to work when I test it with ScraperEdit (except for that it terminates with an empty warning. But it does that with the untampered one as well). But modifying the existing one seems kind of dirty, I would very much like to just have my own scraper which calls the tmdb scraper.
Or if that isn't possible at least keep the functions separate, so that I only need to include them in the tmdb scraper.

So far I tried the latter. I have added an import statement to the addon.xml of the tmdb scraper
Code:
<requires>
    <import addon="xbmc.metadata" version="2.1.0"/>
    <import addon="metadata.common.imdb.com" version="2.7.8"/>
    <import addon="metadata.common.themoviedb.org" version="2.13.1"/>
    <import addon="plugin.video.youtube" version="4.4.10" optional="true"/>
    <import addon="metadata.myextract" version="1.0"/>
</requires>

and added the following RegExp to it's CreateSearchUrl

Code:
<CreateSearchUrl dest="3">
    <RegExp input="$$1" output="&lt;url&gt;http://api.tmdb.org/3/search/movie?api_key=57983e31fb435df4df77afb854740ea9&amp;amp;query=\1&amp;amp;year=$$4&amp;amp;language=$INFO[language]&lt;/url&gt;" dest="3">
        <RegExp input="$$2" output="\1" dest="4">
            <expression clear="yes">(.+)</expression>
        </RegExp>
<!-- added by me ------->
        <RegExp input="$$1" output="&lt;chain function=&quot;GetTitleFromFilename&quot;&gt;$$1&lt;/chain&gt;" dest="1" >
            <expression encode = "1" />
        </RegExp>
<!---------------------->
        <expression noclean="1" />
    </RegExp>
</CreateSearchUrl>
I pretty much copied that from the other function calls in the file. What I don't understand yet, is what the buffer after the function="..." part is for?
Also I'm not quite sure how the buffers transfer from inside the function call to outside. As far as I understand they are separate and no matter what destination I set in the function definition it will be written into the destination set in the function call?

I have tested this with ScraperEdit. It just seems to put the whole function call into the search url, which of course won't work.
Below is my "library", again pretty much copied existing ones. Seemed straight forward, but maybe I still made a mistake?

Any help is appreciated!

The library is defined in %AppData%\Roaming\Kodi\addons\metadata.myextract\addon.xml :
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="metadata.myextract"
       name="My title extractor"
       version="1.0"
       provider-name="kaeptnjoker">
  <requires>
    
  </requires>
  <extension point="xbmc.metadata.scraper.library"
             language="en"
             library="myextract.xml"/>
  <extension point="xbmc.addon.metadata">
    <summary lang="en">My title extractor</summary>
    <description lang="en">Extracts movie title from filename.</description>
    <platform>all</platform>
    <license>GPL v2.0</license>
    <forum></forum>
    <website></website>
    <email></email>
    <source></source>
  </extension>
</addon>


The function itself is in %AppData%\Roaming\Kodi\addons\metadata.myextract\myextract.xml :
Code:
<?xml version="1.0" encoding="UTF-8">
<scraperfunctions>

    <GetTitleFromFilename dest="5">
        <RegExp dest="5" output="\3+\1" input="$$1">
            <RegExp dest="1" output="\1 " input="$$1">
                <RegExp dest="1" output="\1" input="$$1">
                    <expression>^([^_]+)_(xvid|divx|h264|mpg1|mpg2|spark)(_\d){0,1}((_(de|en|fr|ja|zh|fi|es|hu|da|it|ro|sv|no|pl|hs|ma|zz)\.[0-6])+)(_sub)*\.(mkv|avi|mpg|mp4)$</expression>
                </RegExp>
                <expression repeat="yes">([^.]+(\.\.\.)?(\.(?=\.))?)</expression>
            </RegExp>
            <expression encode="1">^([^,]*)(,(.*))? $</expression>
        </RegExp>
    </GetTitleFromFilename>
    
</scraperfunctions>
Reply

Logout Mark Read Team Forum Stats Members Help
Custom Function in built-in scraper?0