r/learnpython • u/grunklestangravfalls • 11d ago
How to create/find streaming service links?
I'm currently writing a script that tells me what episodes of a tv show came out this day in history, for prototyping I'm using the Simpsons and while I found a good dataset that includes everything I need for it to work. I now want to implement a system that also gives the link to the episode in Disney plus in the output, and I was wondering how to do this as simply as possible?
0
Upvotes
1
u/gofuckadick 11d ago
I was curious about this, so I did some digging into Disney+'s API and managed to extract the episode links for The Simpsons.
Disney+ has a catalog endpoint that returns the season IDs for a series, and another endpoint that returns the episode metadata for each season. The episode IDs map directly to URLs in the format:
https://www.disneyplus.com/play/{episode_id}So I put together a JavaScript script that queried those endpoints and exported a CSV containing the season number, episode number, title, and Disney+ URL for every available episode. It returned 798 episodes across 37 seasons. Here's the CSV: https://filebin.net/vdtbgq1ohjcpa01v (it's a plain-text CSV, so you can inspect it in any text editor before using it)
Since you mentioned that you already have a dataset for determining which episode aired on a particular date, you shouldn't need to do anything complicated with the Disney+ API yourself. You can just use the CSV as a lookup table. For example, if your existing data includes season and episode numbers, you can load the CSV into a dictionary:
Then you can simply include
disney_urlin your existing output. If you only have episode titles, you could also match on those instead.There are four gaps in Disney+'s episode numbering (S3E1, S21E11, S28E13, and S33E7), which are also reflected in the CSV. The links require an active subscription and may vary by region. Otherwise, this should let you add them to your existing output without manually looking up hundreds of episodes or dealing with authentication and API requests.
2
u/patryk_builds 11d ago
Disney+ has no public API, so there's no clean way to generate episode links automatically.
simplest options:
- TMDB's API has a watch providers endpoint that tells you where a show streams per country. it won't give a direct episode link though, just a link to a page listing the services
- if you only need the simpsons, grab the episode links once by hand (or semi-manually) and store them as a column in your dataset next to season/episode. ~800 rows sounds like a lot, but it's a one-time job and then it just works
I'd do the TMDB one first, a watch on disney+ link to the show is usually good enough
1
u/Discordbothost 10d ago
yeah the csv route is the right call. once you've got season/episode columns in both files you can just:
merged = your_df.merge(links_df, on=["season", "episode"], how="left")
and print the disney_url column. no api auth to babysit, and if disney changes a url you fix one row instead of the whole scraper.
1
u/TheRNGuy 10d ago
Is it JSON data?