Try 30 days of free premium.

XML API output / Kodi/XBMC metadata scraping

sjhoran wrote 8 years ago: 1

Hi,

How feasible would it be to add an option for API quries to have it throw back XML rather than JSON?

I have written a metadata scraper for Kodi/XBMC that uses the tvmaze API, but it's pretty gross. The grossness is entirely due to Kodi's scraping framework forcing you to use regular expressions to extract data rather than being able to parse JSON/XML and call variables directly, but given these restrictions, XML is easier to work with and has less caveats.

The Kodi metadata scrapers work simply by taking input and munging into XML with a structure and element names that Kodi expects. Ideally, being able to have the API throw back XML preformatted so Kodi can directly parse it would be perfect. I don't expect this to happen, but put it out there as having an official TVMaze metadata scraper in Kodi might be appealing if you want more people to discover TV Maze. What language/framework is this site built on? I could possibly do this work myself if that's an option.

All that said, I love the site and the current API. It's clean and fast and very easy to work with. Keep it up.


david wrote 8 years ago: 1

Hey there,

I moved your thread to the API forum.

First of all, thanks for the kind words! Unfortunately I have to disappoint you though; it's extremely unlikely that we'll ever add support for XML alongside JSON. We have a near infite stream of requests, and adding a secondary inferior output format would take a lot of time and (server) resources but has no real upsides.

I'm not familiar with the Kodi architecture, but couldn't this be tackled in a different approach? For example, adding a layer (a library, a http proxy, something working on stdin/stdout) that takes our JSON data and pre-formats it to something more suitable for Kodi?

sjhoran wrote 8 years ago: 1

Thanks for the quick reply.

Unfortunately, from what I've seen/read about the Kodi scraping framework, you're pretty much stuck with making HTTP GET/POST requests and then bashing away on what it sends back to get it into the XML format Kodi likes. No piping through external processors. A HTTP server that acts as a go-between for API calls and reformats them into Kodi XML would work well, but without such a service publicly hosted, it becomes too complicated for a general purpose Kodi addon.

I do concur that JSON is superior to XML, and am glad tvmaze chose it. Hopefully in the future the Kodi devs will extend their scraping framework to make it possible to work with JSON/XML more directly rather than using revolting regular expression voodoo to do the job.

Thanks again for your time and the thoughtful response. Hopefully I'll be able to contribute in some way going forward.

sjh


david wrote 8 years ago: 1

I just checked through the documentation for writing a Kodi scraper. Ouch.

I agree that the easiest way to go about this would be to write an external proxy that's a client to the TVmaze API and re-formats the output into the exact format Kodi wants, rather than trying to wrap your brain around regexes embedded in XML.

That's probably not something we should host though. It would be unmaintainable to create a separate API for each client application.

Try 30 days of free premium.