Try 30 days of free premium.

Shows Update endpoint

mero wrote 9 years ago: 1

Hi again David,

I am here again for one more infamous suggestion. The http://api.tvmaze.com/updates/shows is a great way to keep track of updates for local cache. But wouldn't it be better if we had a parameter where we could set the last edit timestamp and get only the shows that was edited after? It kinda makes sense because the update timestamp always update to a future date rather than old. That way we don't have to check all 15K shows for the changes and TVmaze doesn't have to dump all the Database data rather than a very small portion.


david wrote 9 years ago: 1

I can see the use for it.

It'd actually be a lot more resource intensive for us compared to the current implementation. Right now we can calculate the list once, cache it, then re-use it for all other consumers in the next 60 minutes. After the proposal, we'd have to calculate and cache many thousands of separate lists, since pretty much everyone hitting us would have a different timestamp.

If there's a lot of demand we'll consider it. :)

srob650 wrote 9 years ago: 1

It also really doesn't take too long to get all updates, especially because you shouldn't need to do so more than once in a given instance of your program.


gazza911 wrote 9 years ago: 1

Seems to be a bit of demand, so I decided to try it; this is all you need to do in jQuery to return just the shows after a certain time.

var shows;

$.get("http://api.tvmaze.com/updates/shows", function(data)

{

shows = $.map(data, function(updated, index)

{ if (updated >= VALUE) return index; });

});

The variable shows will contain all of the IDs.

srob650 wrote 9 years ago: 1

While you're at it, here's the Python version with pytvmaze. Replace the long number with your desired time in epoch-time format. "latest" variable now contains a list of Update objects that were updated after the given time.

import pytvmaze
updates = pytvmaze.show_updates()
latest = [show for show in updates if show.seconds_since_epoch > 1459813281]


Alternatively, you can use a Python datetime object and compare it to show.timestamp instead of show.seconds_since_epoch.

mero wrote 9 years ago: 1

Guys I am not a code novice! :D I already have a better solution but I was trying to point out that TVmaze is dumping the whole database and if it can be changed in a certain way because in the long run dumping the whole DB will rise some response "data size" issue.

Alas thank you guys for your efforts. And thank you David for considering it. :)

Labrys wrote 9 years ago: 1

I see a couple of ways to limit the results that should be meet both mero's desire to limit the number of returned results and david's need to limit the impact for the server too.

Add an optional period parameter such as hourly, daily, weekly and limit the returned list to shows updated during that period. So the server would calculate the results a single time every 60 minutes, and then limit the returned results to the desired period. This, at most, would only result in an additional cache per time period. This would be useful, for example, if you updated within the last week you only need this week's changes. This is not dependant on the user's timestamp which helps to address david's concerns.

Another optional parameter would be to page results similar to http://api.tvmaze.com/shows/. This could be implemented in a couple of ways. The first would be to limit it to just X number of results just like the paging for shows. Another option would be to page by time period. So for hourly updates, page 0 would be all updates in the last hour, page 2 would be the hour before that, etc. This would add a fair degree of flexibility to the time period searched, but i think the added caching here may be more resource intensive than desired. Also for longer time periods this could still result in a substantial number of results per query.

Try 30 days of free premium.