# \[WS\] TheMovieDB

**URL:** https://community.mp3tag.de/t/ws-themoviedb/48029
**Category:** Web Sources Scripts
**Created:** [February 28, 2020, 7:04am UTC](https://community.mp3tag.de/t/ws-themoviedb/48029 "2020-02-28T07:04:12Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![RobertM](https://community.mp3tag.de/user_avatar/community.mp3tag.de/robertm/32/16067_2.png) [@RobertM](https://community.mp3tag.de/u/RobertM)
#### Post date: [April 10, 2025, 11:44am UTC](https://community.mp3tag.de/t/ws-themoviedb/48029/9 "2025-04-10T11:44:41Z")

</div>

> [@ny\_dave69](#):
>
> I know I'm late to the table but would be interested in getting the episode data from the TMDB.

TheMovieDB has [search API for movies](https://developer.themoviedb.org/reference/search-movie) and for [TV series](https://developer.themoviedb.org/reference/search-tv).  
But not for particular seasons or individual episodes of a show.

This doesn't mean you can't retrieve specific season or episode information.  
It just means you can't [SearchBy] show title, year, or any other search by criteria and simply plug them into [IndexUrl] to then pick from a list of total results as returned from the ParserScriptIndex section.

Instead, you need fully construct [AlbumUrl].

In practice, this just means you need the TV series id number along with the season and episode numbers.

For example, to retrieve specific episode information (including appended credits info), you need to construct an [AlbumUrl] that ultimately looks like this:

`https://api.themoviedb.org/3/tv/{series_id}/season/{season_number}/episode/{episode_number}?append_to_response=credits&api_key=YOUR_API_KEY&language=en-GB`

In other words, series\_id, season\_number and episode\_number values are your search criteria, which you can specify like this:

`[SearchBy]=SeriesId||$regexp(%tmdb%,.*/,)||%s||Season||%tvseason%||/season/%s||Episode||%tvepisode%||/episode/%s `

I hold TMDB's TV series id in Mp3tag's %tmdb% field, but with its numerical part prefixed tv/ for MKV files (as per [Matroska specification](https://www.matroska.org/technical/tagging.html#identifiers)).  
The $regexp function above is simply a way of stripping the tv/ prefix back out again before using it for search purposes.

Note how this search by set-up refers to three fields (series id, season number and episode number) defined as `||` delimited triplicates, where each triple is composed of the field prompt, field source, and field search value (plus hard-coded text).

The three field search values are all represented by %s, but season number is prefixed /season/, and episode number is prefixed /episode/, so that when they get strung together they become:

{series\_id}/season/{season\_number}/episode/{episode\_number}

As mentioned, these strung together values don't get plugged into [IndexUrl] to produce a list of search query results as they would for TV series as a whole, instead the combined %s value is used to construct an AlbumUrl for direct use.  
The AlbumUrl for episode level information is thus:

`[AlbumUrl]=https://api.themoviedb.org/3/tv/%s?append_to_response=credits,external_ids&api_key=YOUR_API_KEY&language=en-GB`

Since this approach is a bit different to that of using a ParserScriptIndex section and producing list of search query results, I've attached a commented template script.

[TMDB TV Episode (Template v1.0).src](https://community.mp3tag.de/uploads/short-url/b2cTDmMriiQfuuPZqFqNILRBWL1.src) (6.4 KB)

There's only a few items included in this template example (air date, episode name and directors).  
The intention is more to illustrate with code and comments how the search query step is skipped and how album url is otherwise constructed when using unique ids.

I haven't included a similar template for retrieving specific season level info as that would just be a simpler version of the episode level script.

---

_[View the full topic](https://community.mp3tag.de/t/ws-themoviedb/48029)._
