Try 30 days of free premium.

API by todays date returns previous episode

morningcoffee wrote a year ago: 1

Hi,

If I hit the api for shows airing today (2023-02-08), I noticed at least one of those shows (Late Night with Seth Meyers) has info from the previous/yesterdays (2023-02-07) episode. The show airs at 00:35 if that matters, though it shouldn't since airtime 00:35 on 2023-02-08 is still 2023-02-08, not 2023-02-07. If I fetch the full embedded schedule, and match by airdate, the next episode is correct. I did search before posting and saw this problem previously but was supposedly fixed. Any ideas what could be causing it now?


david wrote a year ago: 1

What's the exact URL of the endpoint you were using?

Keep in mind that API output is cached for 60 minutes, so the first hour after an episode has aired you might still see references to an older episode.

morningcoffee wrote a year ago: 1

with: http://api.tvmaze.com/schedule/full
-----
jq -r --arg TODAY "$(date +%Y-%m-%d)" --arg NAME "late night with seth meyers" '.[]|select(.airdate==$TODAY and (._embedded.show.name|ascii_downcase)==$NAME) | "airdate: \(.airdate)  *  \(.name)"' <(curl -s "http://api.tvmaze.com/schedule/full")

airdate: 2023-02-09  *  Fred Armisen, Penn Badgley
-----

This is correct, the next episode will occur at 00:35 tonight, passing midnight and airing on 2023-02-09.

 

and with: http://api.tvmaze.com/schedule?date="2023-02-08"
-----
jq -r --arg NAME "late night with seth meyers" '.[]|select((.show.name|ascii_downcase)==$NAME) | "airdate: \(.airdate)  *  \(.name)"' <(curl -s "http://api.tvmaze.com/schedule?date=2023-02-08")

airdate: 2023-02-07  *  Reese Witherspoon, Paula Pell, Chef Michael Solomonov
-----

This is not correct. Since today=2023-02-08, the episode shown for today should be the episode from 2023-02-08, not 2023-02-07. Or am I missing something? We're well past the first hour after that 2023-02-07 has aired. Also, adding "country=US" produces the same results.


david wrote a year ago: 1

Right! This has nothing to do with the API in particular, but with how we deal with episodes that air after midnight.

Check out https://www.tvmaze.com/faq/15/episodes#airtime-release-time:

For example, if an episode airs after midnight between Monday the 1st and Tuesday the 2nd, the airdate should be set to the 1st; even though technically the proper date would be the 2nd. (API users should take note that the property "airdate" uses the date as described here; while "airstamp" uses the technically correct date).

morningcoffee wrote a year ago: 2

@david wrote:
Right! This has nothing to do with the API in particular, but with how we deal with episodes that air after midnight.

Check out https://www.tvmaze.com/faq/15/episodes#airtime-release-time:

This seems broken and inconsistent. If I hit a specific date with the api, I should get the correct data for that date. I guess the airdate vs. airstamp thing can be used to work around the date itself, but the problem is that the episode if is still incorrect for the requested date. In my example, I requested episode data for the episode airing on 2023-02-08. Even though airstamp was correct, all the episode data wasn't. I didn't get episode data for 2023-02-08, I got episode data for the incorrect 2023-02-07 episode.  So basically, you can't get correct episode data by requesting a specific date because you'll always get the episode data for the episode prior to what you actually want. Even worse, results are inconsistent because the correct info is present when fetching the full schedule, or searching the show on the website. So you either have to fetch the full schedule, which is significantly bigger and slower to parse, or you have to request multiple different dates just to get good episode data for a single date - the correct date for all the shows not affected by this, and dates in the future for all the shows/episodes affected. It's like on Tuesday I ask what today's lunch special is, and the response is the lunch special for Monday. I don't see how this behavior isn't broken when I'm requesting data for a specific date. Would it be reasonable to have an alternate date request endpoint that provides episode data based on airstamp instead so you'd get what you're asking for? Thanks for clarifying the cause of the problem btw!


david wrote a year ago: 1

I understand that this is confusing, but it's simply how TV shows airing after midnight are treated pretty much everywhere else.

For example, if you head to Seth Meyers' official website at https://www.nbc.com/late-night-with-seth-meyers you'll see that the episode with Reese Witherspoon is listed for "Tue 02/07" even though it airs in the night between Tuesday 7 and Wednesday 8 so the technically correct date would be the 8th. So that's how we treat it on the site and in the API.

If you really want something else on your end, simply request the schedule for one day before & after the desired date then manually filter by airdate.

morningcoffee wrote a year ago: 2

@david wrote:
I understand that this is confusing, but it's simply how TV shows airing after midnight are treated pretty much everywhere else.

For example, if you head to Seth Meyers' official website at https://www.nbc.com/late-night-with-seth-meyers you'll see that the episode with Reese Witherspoon is listed for "Tue 02/07" even though it airs in the night between Tuesday 7 and Wednesday 8 so the technically correct date would be the 8th. So that's how we treat it on the site and in the API.

If you really want something else on your end, simply request the schedule for one day before & after the desired date then manually filter by airdate.

I understand and concede if that's simply whats been widely accepted. I guess if I want Tuesday's lunch special, I'll ask on Wednesday. :)  Thank you for clearing up the confusion.

Try 30 days of free premium.