You’ll be amused by this. In PlexMovie.bundle:
# Defer to TMDb release information, because it's better than IMDb

You’ll be amused by this. In PlexMovie.bundle:
# Defer to TMDb release information, because it's better than IMDb

Hi Volts,
That is funny. It looks like somebody at Plex agrees that the release info is better on TMDB. I’ll take a close look at their Python script now. It wouldn’t be that big a deal to switch over to their new scanner/agent like you said. TMDB includes the IMDb ID (which the Plex Movie Agent stores in the gui field). So I’ll still be able to maintain my collection using the TheTVDB and TheMovieDB APIs and easily run verification code against Plex. It’s just frustrating that they have such a great product and easy to fix issues like this and an unusable randomization feature stick around for years.
I don’t care as much about ratings, but I do remember skimming much of the metadata and not finding any other issues. Just the date.
I’m not saying that Plex is using the release_date API call. I’m saying that, if you look at the 130 examples I provided, the first release date listed in the API’s JSON result (for your selected language) matches the date in Plex. This proves that whatever Plex is doing and what this API is doing comes to the same end result.
The “Primary Release Date” you mention is exactly what I suggested earlier in this thread as an alternate solution. This “release_date” is provided in the basic movie API call. If a movie is originally released in Spain in 2018 and then in the USA in 2020 I don’t see a problem with showing it as 2018. It’s better than using a DVD release date 63 years later like they do for “Rebel Without a Cause (1955)”.
Are your ratings (R, PG, etc.) missing, on these movies, when using the TMDB Agent? Mine are odd, but I’m not sure if it’s following the same pattern or something else.
If you don’t care about movie ratings at all, you could simply remove releases from line 13 of TheMovieDB.bundle/Contents/Code/__init__.py:
From:
TMDB_MOVIE = ‘/movie/%s?append_to_response=releases,credits&language=%s’
To:
TMDB_MOVIE = ‘/movie/%s?append_to_response=credits&language=%s’
Professionals on a closed course, make a backup, your face might stick that way, etc. It doesn’t ask for release info, so it doesn’t get confused by their dates. That means it doesn’t get any rating/certification info, however.
Or, attached, is one that’s less stupid. It copies more of the logic from the Plex Movie agent. It does ask for releases, so it does get ratings/certifications. I think it gets the matching right for your movie examples, and at least gets the same ratings/certifications the TMDB agent usually does. I also don’t know what else it breaks, and you can keep both pieces when it does. ![]()
Whole file:
init.py.gz|attachment (7.8 KB)
Patch:
tmdb-init.patch.gz (738 Bytes)
While copying that logic from the Plex Movie agent, I noticed other things that are “better” in the Plex Movie agent, too. It has better country-code handling, it’s better about sanitizing responses from TMDB, etc.
Thanks Volts,
Yes, I confirmed what you said. The certifications/ratings for many of the sample movies were wrong. It makes sense since TMDB pairs these with the release date. It’s grabbing the same incorrect certification that is paired with the wrong release date.
Thanks. Both of your solutions fixed the year issue. Your second solution still doesn’t bring in the correct certification. I tested with three movies. It’s still bring in the rating associated with the wrong release date.
I really appreciate you debugging the Python script and solving the issue.
Rudolph ... (1964) is a good example of just how bad the metadata scene is. There are so many cuts of that movie!
IMDB Rudolph Versions, Wikipedia Rudolph Versions
The original 1964 broadcast was 47 minutes long.
IMDB says it’s from 1964 and 47 minutes long.
TMDB says it’s from 1964, 52 minutes long, and rated G. That’s kooky.
Amazon says it’s from 2016, 52 minutes long.
VUDU says it’s from 1965, 52 minutes long.
Wikipedia says it’s 55 minutes long.
IMDB admits alternate cuts exist, but only in a narrative form. TMDB promises to add support for cuts/editions, but deletes them today. (I’m not blaming them, it would be a mess.) Except Superman II, which apparently gets a pass.
With Rudolph ... (1964) it’s like the Ship of Theseus. At what point has it been changed so many times that it’s no longer the original item? You don’t have the 1964 movie, you don’t have a straightforward remaster, you have an edit of an edit, with removed and restored and re-edited content, with mashed-up audio and video, with different intro and credits.
There isn’t even a “best” version. It’s as bad as Star Wars / You know, the first one / A New Hope / Episode IV / Greedo Deserved It / Save us, Harmy!
Rudolph ... (1964) (1964 TV Original "Why didn't Santa come back?")
Rudolph ... (1964) (2005 HD Remaster, with goofy Fame & Fortune / Misfits mash-up)
Rudolph ... (1964) (Freeform edition with Peppermint Mine scene restored)
That all said, it’s certainly not a 2005 movie. The other Plex agents get it as 1964 correctly, and my dumb hacks to the TMDB Agent / init.py seem to get it as 1964, too.
HI Volts,
I fixed the Plex Python script to handle release dates correctly.
TheMovieDb URL needed to be changed so it returns more release information. The “release_dates” JSON includes all the data included in the “releases” JSON and more…
TMDB_MOVIE = ‘/movie/%s?append_to_response=releases,credits&language=%s’
TMDB_MOVIE = ‘/movie/%s?append_to_response=release_dates,credits&language=%s’
Here is the code that pulls in the certification (G, PG, R, etc.) and official release dates from the selected country. If a country doesn’t have a theatrical release (type = 1 or 3), then it uses the movies default release date (already set earlier in the existing Plex code)…
if Prefs[‘country’] != ‘’:
c = Prefs[‘country’]
try:
for releaseresults in tmdb_dict[‘release_dates’][‘results’]:
if releaseresults[‘iso_3166_1’] == Locale.CountryCodes.MatchToCode(c):
for releasedates in releaseresults[‘release_dates’]:
if releasedates[‘type’] == 1 or releasedates[‘type’] == 3:
try:
metadata[‘originally_available_at’] = releasedates[‘release_date’]
metadata[‘year’] = Datetime.ParseDate(releasedates[‘release_date’]).date().year
metadata[‘content_rating’] = releasedates[‘certification’]
except:
pass
break
except: pass
Is there any changes of passing this on to Plex development or am I going to have to re-apply this after every installation?
And I have used it (on a test system) and its incredibly fast and accurate. I don’t however necessarily get the inner workings behind it. If its pulling the info from various sources and those sources conflict then…?
Who actually maintains this DB… I’m probably being dumb here (its been a long night shift) and maybe its wishful thinking but are we saying that it is an official Plex DB that can be corrected by “confirmed” user requests?
Please read the linked thread for this information. It’s mentioned in there. No need to duplicate this here.
I think we were doing some of the same thing. I stared at releases vs. release_dates for a while before I found the TMDB API “that’s deprecated” documentation.
Are you sure you like that behavior for releasedates? I think I like the spirit of TMDB’s “primary release date” better, it’s more like “first widespread public availability”. I like TMDB’s dates better for all of these films, for instance:
Laputa: Castle in the Sky (1986) - 1989 Theatrical Release in the US
The Hurt Locker (2008) - 2009 Theatrical Release in the US
Trolls World Tour (2020) - Digital only, so far, in the US
Vast of Night (2020) - 2019 Premiere, 2020 Theatrical
IMDB seems to (usually) include Premiere dates, and might be more consistent about it. I like TMDB’s approach of (usually) not.
There’s some logic in the Plex agent scripts to prefer the TMDB primary release date, and then to fall back to searching for the earliest per-country date. I’m not sure if that’s ever needed, or if TMDB always gives a primary release date.
Another thing to consider about your current approach is that it may still stomp on records, including overwriting “good” fields with “worse” or “empty” data.
Mainstream theatrical releases are almost always rated, while Premiere releases may not be. There are many movies with multiple Premiere release dates. You could parse the Theatrical release first, and then overwrite it with an empty content_rating from a Premiere.
I can’t think of many, but there are a few movies with multiple Theatrical release dates too. Those could be significantly spread out in time. Theatrical re-releases aren’t always rated.
In your list of problem movies, this would apply to at least Apocalypse Now and Apollo 13. I didn’t look at them all. I know that Terminator 2 made it into the theaters a few times, too.
If you don’t want to use the TMDB primary date as-is, or if it’s not consistently present, you might consider only updating the date IF it’s lower. Whether globally or in one country, it makes sense to find the lowest date.
You might also consider only updating the content_rating when it exists, and you might consider only updating IF it’s stricter. It doesn’t make sense to go from PG to empty, or from R to PG-13.
is NR the softest or strictest rating?
The Preview scanner/agent might be using something closer to your per-region date strategy.
I’m set up for English/US. In the Preview scanner/agent:
Aguirre... shows up as 1977, the US Theatrical date.
The Hurt Locker... shows up as 2009, the US Theatrical date.
There was some talk about this on the Preview thread. Now I feel like reading it again, more carefully, and comparing dates in my Preview scanner/agent library.
FileBot and TMM and Radarr all like the other dates.
I’m not sure if I care; I’m optimistic searching/matching in Plex will work fine as long as it’s “a” valid date in IMDB/TMDB. I would kinda like the choice though.
@JuiceWSA
Maybe they should check and see if the TVDB has the correct year…
I refreshed the metadata for all my movies and all but a couple movies now have the correct year and certification. I had noticed the issue you mentioned with Apollo 13 last night. There was an IMAX release 7 years later and it was listed first on TMDB. I’m going to fix this by modifying the code to take the earliest theatrical release date. I also noticed that some theatrical releases don’t have a certification in TMDB. This is easily fixed by picking the certification from the theatrical release that has one. This should give me 100% accuracy on both the year and certification on 4000+ movies.
I may try out the new Plex preview scanner/agent at some point. But with all the help you’ve provided me with the The Movie Database agent, I couldn’t be happier with the result. It’s still plenty fast and is now accurate.
The matching piece still needs to be improved though. Not a big deal for me at this point since it only fails on about 60 of 4000 movies and I wrote code that identifies all the bad matches.
I don’t think I’ve ever received so much good information on a single forum thread. Thanks again.
Here is my updated Python script. I confirmed with Apollo 13 that it fixes the issue with multiple theatrical releases and when the certification is missing on some releases. I then spot checked 20 movies and found no issues. It only replaces the default release date & certification if it finds valid data in the country’s releases.
releasedate = ‘9999-99-99’
certification = ‘’
if Prefs[‘country’] != ‘’:
c = Prefs[‘country’]
try:
for releaseresults in tmdb_dict[‘release_dates’][‘results’]:
if releaseresults[‘iso_3166_1’] == Locale.CountryCodes.MatchToCode(c):
for releasedates in releaseresults[‘release_dates’]:
if releasedates[‘type’] == 1 or releasedates[‘type’] == 3:
if releasedates[‘release_date’] < releasedate:
releasedate = releasedates[‘release_date’]
if releasedates[‘certification’] != ‘’: certification = releasedates[‘certification’]
except: pass
if releasedate != ‘9999-99-99’:
metadata[‘originally_available_at’] = releasedate
metadata[‘year’] = Datetime.ParseDate(releasedate).date().year
if certification != ‘’:
metadata[‘content_rating’] = certification
That’s so much cleaner than how I was doing it. Nice. TY for sharing.
I hope they find this thread when they’re working on Y10K problems. If anybody is still using Plex in ~8000 years …
Funny. I’ll be long dead by then.
After refreshing the metadata for all 4,234 movies I ran a verification on all release dates and certifications.
The years all appear accurate now. There were 114 movies where the years didn’t match. I reviewed the 10 of them that were more than 1 year off. They all had legitimate reasons…
| Path | ID | Year Diff | Note |
|---|---|---|---|
| Aguirre, The Wrath of God (1972) | 2000 | -5 | Released in USA 5 years after Germany. |
| Darkness (2002) | 11056 | -2 | Released in USA 2 years after Spain. |
| The Gods Must Be Crazy (1980) | 8393 | -4 | Released in USA 4 years after South Africa. |
| Henry V (1944) | 22638 | -2 | Released in USA 2 years after UK. |
| Nosferatu (1922) | 653 | -7 | Released om ISA 7 years after Germany. |
| Paranormal Activity (2009) | 23827 | 2 | Premiered 2 years before widespread release. |
| Seven Samurai (1954) | 346 | -2 | Released in USA 2 years after Japan. |
| The Upside (2019) | 440472 | 2 | Premiered 2 years before widespread release. |
| The Wages of Fear (1953) | 204 | -2 | Released in USA 2 years after France. |
| The Wicker Man (1973) | 16307 | -2 | Released in USA 2 years after UK. |
There were 73 movies that were missing certifications since they were added in the USA in 1968. I reviewed all of them an they are either an issue with TMDB or don’t have one…
| Movie | Note |
|---|---|
| The Grudge (2020) | Missing on TMDB for USA. |
| Queen & Slim (2019) | Missing on TMDB for USA. |
| I Can Only Imagine (2018) | Missing on TMDB for USA. |
| Almost Christmas (2016) | Missing on TMDB for USA. |
| Racing Extinction (2015) | Missing on TMDB for USA. |
| The Hunting Ground (2015) | Missing on TMDB for USA. |
| Chef (2014) | Missing on TMDB for USA. |
| The Borrowers (2011) | Missing on TMDB for USA. |
| Appaloosa (2008) | Missing on TMDB for USA. |
| Sea Monsters- A Prehistoric Adventure (2008) | IMAX presentation. |
| Daddy’s Little Girls (2007) | Missing on TMDB for USA. |
| We Own the Night (2007) | Missing on TMDB for USA. |
| Why Did I Get Married (2007) | Missing on TMDB for USA. |
| A Prairie Home Companion (2006) | Missing on TMDB for USA. |
| Get Rich or Die Tryin’ (2005) | Missing on TMDB for USA. |
| NASCAR- The IMAX Experience (2004) | IMAX presentation. |
| The Fighting Temptations (2003) | Missing on TMDB for USA. |
| Like Mike (2002) | Missing on TMDB for USA. |
| Holiday Heart (2000) | Missing on TMDB for USA. |
| In the Mood for Love (2000) | Missing on TMDB for USA. |
| All About My Mother (1999) | Missing on TMDB for USA. |
| The Out-of-Towners (1999) | Missing on TMDB for USA. |
| Topsy-Turvy (1999) | Missing on TMDB for USA. |
| Madeline (1998) | Missing on TMDB for USA. |
| Ringu (1998) | TMDB shows no USA release. |
| T-Rex- Back to the Cretaceous (1998) | IMAX presentation. |
| The Dinner Game (1998) | Missing on TMDB for USA. |
| Box of Moonlight (1996) | Missing on TMDB for USA. |
| Jackie Brown (1997) | Missing on TMDB for USA. |
| The Postman (1994) | Missing on TMDB for USA. |
| A Low Down Dirty Shame (1994) | Missing on TMDB for USA. |
| Blue Sky (1994) | Missing on TMDB for USA. |
| Corrina, Corrina (1994) | Missing on TMDB for USA. |
| Final Analysis (1992) | Missing on TMDB for USA. |
| Class Action (1991) | Missing on TMDB for USA. |
| The First Power (1990) | Missing on TMDB for USA. |
| An Innocent Man (1989) | Missing on TMDB for USA. |
| Nuts (1987) | Missing on TMDB for USA. |
| Tin Men (1987) | Missing on TMDB for USA. |
| ’Round Midnight (1986) | Missing on TMDB for USA. |
| City Heat (1984) | Missing on TMDB for USA. |
| The Year of Living Dangerously (1982) | Missing on TMDB for USA. |
| Fitzcarraldo (1982) | TMDB shows no USA release. |
| Quest for Fire (1981) | Missing on TMDB for USA. |
| The Four Seasons (1981) | Missing on TMDB for USA. |
| Melvin and Howard (1980) | Missing on TMDB for USA. |
| Norma Rae (1979) | Missing on TMDB for USA. |
| The Champ (1979) | Missing on TMDB for USA. |
| When a Stranger Calls (1979) | Missing on TMDB for USA. |
| Death on the Nile (1978) | Missing on TMDB for USA. |
| F.I.S.T. (1978) | Missing on TMDB for USA. |
| House Calls (1978) | Missing on TMDB for USA. |
| Thank God It’s Friday (1978) | Missing on TMDB for USA. |
| Aguirre, The Wrath of God (1972) | Missing on TMDB for USA. |
| New York, New York (1977) | Missing on TMDB for USA. |
| Bound for Glory (1976) | Missing on TMDB for USA. |
| Gus (1976) | Missing on TMDB for USA. |
| Alice Doesn’t Live Here Anymore (1974) | Missing on TMDB for USA. |
| Lucky Lady (1975) | Missing on TMDB for USA. |
| The Hindenburg (1975) | Missing on TMDB for USA. |
| Butterflies Are Free (1972) | Missing on TMDB for USA. |
| Cries and Whispers (1972) | Missing on TMDB for USA. |
| Cromwell (1970) | Missing on TMDB for USA. |
| Lovers and Other Strangers (1970) | Missing on TMDB for USA. |
| Ryan’s Daughter (1970) | Missing on TMDB for USA. |
| Santa Claus Is Comin’ to Town (1970) | Made for TV. |
| The Out-of-Towners (1970) | Missing on TMDB for USA. |
| Waterloo (1970) | Missing on TMDB for USA. |
| Anne of the Thousand Days (1969) | Missing on TMDB for USA. |
| Bob & Carol & Ted & Alice (1969) | Missing on TMDB for USA. |
| They Shoot Horses, Don’t They (1969) | Missing on TMDB for USA. |
| Rachel, Rachel (1968) | Missing on TMDB for USA. |
| The Little Drummer Boy (1968) | Made for TV. |
I had to make a second revision to the script. There was another rating type to include (2 = Theatrical (limited)). Also, premiers come before theatrical releases and often don’t have certifications. I also made it Y10K compliant (it will outlive the sun). …
releasedate = ‘9999999999-99-99’
certification = ‘’
if Prefs[‘country’] != ‘’:
c = Prefs[‘country’]
try:
for releaseresults in tmdb_dict[‘release_dates’][‘results’]:
if releaseresults[‘iso_3166_1’] == Locale.CountryCodes.MatchToCode(c):
for releasedates in releaseresults[‘release_dates’]:
if 1 <= releasedates[‘type’] <= 3: #1 = Premier, 2 = Theatrical (limited), 3 = Theatrical
if releasedates[‘release_date’] < releasedate: releasedate = releasedates[‘release_date’]
if releasedates[‘certification’] != ‘’: certification = releasedates[‘certification’]
except: pass
if releasedate != ‘9999999999-99-99’:
metadata[‘originally_available_at’] = releasedate
metadata[‘year’] = Datetime.ParseDate(releasedate).date().year
if certification != ‘’:
metadata[‘content_rating’] = certification
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.