Getting all instances of a show

Hello, John from WXNA Nashville here, skilled developer.

We have some shows that repeat. I see that /api/shows only returns one instance of a show, what appears to be the next occurrence. if I call /shows/id it only returns what appear to be the next occurence.

I’m wanting to build a calendar to show all times and shows. How can I find all instances of a show via the api?

thanks john

1 Like

Hey John. I have a Spinitron API adapter written in Node.js that can help you out with this. It’s in a private GitLab, but I can give you access if it helps ease the pain here — just DM me.

It is theoretically impossible to build a correct show calendar from the Spinitron API data because it does not include data like “Weekly on Wednesdays at 3:30PM” that simply says when a show happens each week. Instead, it only includes specific occurrences of shows, like 2024-03-27T08:00:00Z, and so you need to do a lot of weird interpolation in order to get something resembling a correct show schedule.

Ideally, Spinitron would put out iCal recurrence rules that you could then parse with something like this JS-based rrule library.

To get around this, I ended building a Spinitron admin panel web scraper that is able to put our RRULE-compatible times for each show — along with a lot of other data that is not normally in the Spinitron API.

And if you’re wondering — yes, it’s part of Creek, but you can use this API adapter independently of Creek since it just puts out generic JSON.

Also, here are two websites with show schedules that rely on this API adapter:

The code for the show schedule itself is also available if you want access to it, and I’m hoping to smooth it out and package it as an open source toolkit soon (along with Creek itself).

Thank you Travis, its odd that they can’t simply do a dump of data that’s already in their database. If the back end is .NET I would volunteer to write an API to dump that table.

I think I’ll just create a separate database. It appears that each show is in the export at least once so I can get the show ID, and then an admin can manually fill in the holes. I had already developed a back end that’s used for things like guest request, show substitution and volunteer sign up.

By the way your player is brilliant and gorgeous, if you ever open source that I’ll be interested to see how that works, especially how you figured out how to skip songs.

thanks,

john

Unless all recurrences of all your scheduled shows have a specified end date, the number you’re requesting is mathematically infinite.

For this reason, the API returns only the first occurrence of each show unless you provide an end query parameter. Without the end parameter the request unbounded.

When you specify an end in the request then we call that bounded and the API returns all occurrences.

https://spinitron.github.io/v2api/#/Show/get_shows

If you want to fetch a very large number of occurrence via the API, you need to consider batching. The API limits the number of occurrence in each HTTP response to 200. The response includes also a link to get the next 200 so you can iterate a large result set like that.

You can also batch by date. e.g. I wouldn’t try requesting end=2030 and iterating to fetch that result set. For example, do that in a loop getting one month at a time.

But your program schedule in Spinitron will change from time to time. Even requesting everything for the next 12 months is a questionable design without a way to synchronize your copy of the data to changes as they are made in Spinitron?

So I suggest a design that fetches what you need to display (e.g. one week, i.e. a bounded request) when you need to display it and caching the result for an hour or whatever you consider reasonable. If you manually clear cache when you change the schedule then cache life could be much longer.

What do I mean here: “what you need to display”? Generally we are using web or mobile apps to display data to people. And “when you need to display it” is when that person requests it from your web/mobile app. If your local cache expired the response is a bit slower otherwise there’s no delay.

Feel free to call me or set up a zoom time to discuss more, or proceed here, as you prefer.

how do i get in touch? I think a phone call would be quick john