Kodi Community Forum

Full Version: need help with getting TV fanart to my scraper
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to get Fanart backgrounds for TV shows I scrape with my custom scraper in <GetDetails>.
I have the IMDB title ID.
Can someone post a regexp code that will do the job?
You could probably do via two functions.

First, use the IMDb ID to have a custom function fetch GetSeriesByRemoteID from tvdb.
e.g.
Code:
<url function="GetTVDBid">http://www.thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=tt0411008</url>
Use that function to parse the TVDB id out from the xml (easy), and then have that return a function fetching the banners.xml
e.g.
Code:
<details><url function="GetFanart">http://www.thetvdb.com/api/1D62F2F90030C444/series/73739/banners.xml</url></details>
And then from there parse out the fanart and return it (at that point you can probably just copy-paste the relevant bit from the tvdb scraper, just switch out the buffers as needed).
Ok, so what should the final xml look like in order for the background to appear in XBMC?
like this?

<Banner>
<id>89141</id>
<BannerPath>fanart/original/73739-34.jpg</BannerPath>
<BannerType>fanart</BannerType>
<BannerType2>1920x1080</BannerType2>
<Colors>|148,149,153|13,23,22|165,159,137|</Colors>
<Language>en</Language>
<Rating>7.5758</Rating>
<RatingCount>33</RatingCount>
<SeriesName>false</SeriesName>
<ThumbnailPath>_cache/fanart/original/73739-34.jpg</ThumbnailPath>
<VignettePath>fanart/vignette/73739-34.jpg</VignettePath>
</Banner>
You need it to look like:
Code:
<details>
    <fanart url="http://thetvdb.com/banners/">
        <thumb dim="1920x1080" colors="|148,149,153|13,23,22|165,159,137|" preview="_cache/fanart/original/73739-34.jpg">
            fanart/original/73739-34.jpg
        </thumb>
        <thumb ...>
            ...
        </thumb>
        ...
    </fanart>
</details>
Thanks!
I'm having trouble getting the TVDB ID into:

<details><url function="GetFanart">http://www.thetvdb.com/api/1D62F2F90030C444/series/$$20/banners.xml</url></details>

I'm trying to populate buffer 20 before with the "GetTVDBid" function but the buffer is empty for some reason.

In xbmc.log I see the "GetFanart" function call but not the "GetTVDBid".

Here's the relevant xml code I'm using:

http://pastebin.com/TQKLsaXL
You have to remember the order in which the functions are processed, compared to when the buffers are substituted in. GetTVDBid (and GetFanart) won't be run until after GetDetails has returned, so of course $$20 will be empty because it hasn't been filled yet.

What I was suggesting above was to have GetTVDBid return the call to GetFanart.

And remember each function as a whole needs to return a <details>...</details> block, you don't need to wrap each call to a function in them. (The reason I put them around the call to GetFanart was because it was meant to be the complete output of GetTVDBid.)
Well, now in xbmc.log, I see the call to the chain function "GetThumb" but i don't get the output from it after that.

I also tried to put the input directly without an expression:

<GetFanart dest="17" clearbuffers="no">
<RegExp input="$$17" output="&lt;details&gt;&lt;fanart url=&quot;http://thetvdb.com/banners/&quot;&gt;\1&lt;/fanart&gt;&lt;/details&gt;" dest="17">
<RegExp input="$$1" output="&lt;details&gt;&lt;chain function=&quot;GetThumb&quot;&gt;&lt;Banner&gt;&lt;id&gt;888699&lt;/id&gt;&lt;BannerPath&gt;fanart/original/253463-2.jpg&lt;/BannerPath&gt;&lt;BannerType&gt;fanart&lt;/BannerType&gt;&lt;BannerType2&gt;1920x1080&lt;/BannerType2&gt;&lt;Colors/&gt;&lt;Language&gt;en&lt;/Language&gt;&lt;Rating&gt;8.1667&lt;/Rating&gt;
&lt;RatingCount&gt;6&lt;/RatingCount&gt;&lt;SeriesName&gt;false&lt;/SeriesName&gt;&lt;ThumbnailPath&gt;_cache/fanart/original/253463-2.jpg&lt;/ThumbnailPath&gt;&lt;VignettePath&gt;fanart/vignette/253463-2.jpg&lt;/VignettePath&gt;&lt;/Banner&gt;&lt;/chain&gt;&lt;/details&gt;" dest="17">
<expression noclean="1"/>
<!--<expression noclean="1">&lt;banner&gt;(.|\r|\n)*?&lt;/banner&gt;</expression>-->
</RegExp>
<expression noclean="1"/>
</RegExp>
</GetFanart>

by the way, with this expression in "GetFanart": <expression noclean="1">&lt;banner&gt;(.|\r|\n)*?&lt;/banner&gt;</expression>
I don't get any results although it does match the contents of "http://www.thetvdb.com/api/1D62F2F90030C444/series/253463/banners.xml" when I search it in Notepad ++.
Why is that?
You're making this more complicated than it needs to be.

1. In GetDetails:
Code:
<RegExp input="$$1" output="&lt;url cache=&quot;TVDBid-\1.xml&quot; function=&quot;GetTVDBid&quot;&gt;http://www.thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=\1&lt;/url&gt;" dest="4+">
     <expression noclean="1">&lt;td style=&quot;padding-right:8px;vertical-align:top;&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/(.*?)&quot;</expression>
</RegExp>

2. GetTVDBid:
Code:
<GetTVDBid dest="4">
    <RegExp input="$$3" output="&lt;details&gt;\1&lt;/details&gt;" dest="4">
        <RegExp input="$$1" output="&lt;url cache=&quot;Fanart-\1.xml&quot; function=&quot;GetFanart&quot;&gt;http://www.thetvdb.com/api/1D62F2F90030C444/series/\1/banners.xml&lt;/url&gt;" dest="3">
            <expression clear="yes" noclean="1">&lt;id&gt;(\d+)&lt;/id&gt;</expression>
        </RegExp>
        <expression noclean="1"/>
    </RegExp>
</GetTVDBid>

3. GetFanart:
Code:
<GetFanart dest="4">
    <RegExp input="$$3" output="&lt;details&gt;\1&lt;/details&gt;" dest="4">
        <RegExp input="$$5" output="&lt;fanart url=&quot;http://thetvdb.com/banners/&quot;&gt;\1&lt;/fanart&gt;" dest="3">
            <RegExp input="$$1" output="&lt;thumb dim=&quot;\2&quot; colors=&quot;\3&quot; preview=&quot;_cache/\1&quot;&gt;\1&lt;/thumb&gt;" dest="5">
                <expression repeat="yes">&lt;BannerPath&gt;([^&lt;]*)&lt;/BannerPath&gt;[^&lt;]*&lt;BannerType&gt;fanart&lt;/BannerType&gt;[^&lt;]*&lt;BannerType2&gt;([^&lt;]*)&lt;/BannerType2&gt;[^&lt;]*&lt;Colors&gt;([^&lt;]*)&lt;/Colors&gt;</expression>
            </RegExp>
            <expression noclean="1"/>
        </RegExp>
        <expression noclean="1"/>
    </RegExp>
</GetFanart>

(Disclaimer: Not actually tested.)
Thanks! worked.