Get subtitles for a whole TV season in one API call
Disclosure: I build Wyzie Subs, the API used below. Season packs work on the free key. If your app plays TV shows, you have probably written this loop: for each episode, search for a subtitle, pick the best row, downloa
Disclosure: I build Wyzie Subs, the API used below. Season packs work on the free key.
If your app plays TV shows, you have probably written this loop: for each episode, search for a subtitle, pick the best row, download it. Ten episodes means ten searches, ten picks and ten downloads, plus retry logic for each one.
Wyzie Subs now has GET /search/season, which does that loop on our side. You send a show and a season, and you get back the best subtitle for every aired episode.
The call
curl "https://sub.wyzie.io/search/season?id=tt0903747&season=1&language=en&key=YOUR_KEY"
id is an IMDb or TMDB id. season=0 holds the specials. language is one language and defaults to en. To ask for only some episodes, add episodes=1-5 or episodes=1,3,8.
The answer
Each episode gets a row with its name, air date and the best subtitle, with a download link and a rank score:
{
"episode": 1,
"name": "Pilot",
"airDate": "2008-01-20",
"ok": true,
"subtitle": {
"url": "https://sub.wyzie.io/c/.../id/1955204396?format=srt&tok=...",
"format": "srt",
"language": "en",
"release": "Breaking.Bad.S01E01.720p.BluRay.x264-DEMAND",
"rank": { "score": 96, "reasons": [] }
}
}
subtitle: null means nothing was found for that episode. The top level tells you episodes, found, pending, cost and refunded.
Or one zip
Add zip=1 and you get one file, such as tt0903747.S01.en.zip, with S01E01.en.srt, S01E02.en.srt and so on inside. Download options apply to every file in it, so to=vtt gives you WebVTT for a browser player:
curl -o season1.zip "https://sub.wyzie.io/search/season?id=1396&season=1&zip=1&to=vtt&key=YOUR_KEY"
On a Pro key you can also add sdh=strip to remove hearing-impaired text like [DOOR SLAMS] and JOHN: from every file.
Slow episodes
The call answers within about 60 seconds. An episode that isn't done by then is listed in pending, and its cost is given back. Its search keeps running, so ask again with episodes= set to those numbers and they come back quickly.
From JavaScript
import { searchSeason } from 'wyzie-lib';
const pack = await searchSeason({ id: 'tt0903747', season: 1, language: 'en' });
for (const row of pack.results)
if (row.ok && row.subtitle) console.log(row.episode, row.subtitle.url);
if (pack.pending.length)
await searchSeason({ id: 'tt0903747', season: 1, episodes: pack.pending });
Cost
Each episode costs what its /search would (1 request, or 1 per named source), plus 1 with zip=1. The whole amount is charged up front, and the unused part comes back in one refund: pending episodes, searches that failed on our side, and with zip=1, episodes with no file. Episodes that haven't aired yet are left out and cost nothing. The free key gives 1,000 requests a day, so a 10-episode season pack is 10 of them, plus 1 for each subtitle you download from the JSON links (or 10 more for the zip).
A call takes up to 50 episodes. For longer seasons, send episodes=1-50 and then the rest.
Full reference and errors: https://docs.wyzie.io/subs/usage/season
Free key: https://sub.wyzie.io
If a season comes back with gaps you didn't expect, tell me in the comments and I'll look at it.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.