Hi guys’n’girls,
I have a German language movie library and it always hurt my feelings that I have movie trailers in my library with English audio.
Using PlexAPI and Python, I found a way to delete all trailers with audio not in German language. And those trailer disappear.
To make a long story short, I am searching for all movies with trailer extras, then check the audio track languages and in addition to that I check also the extra title for mentioning of German language. All non-German trailers are deleted.
Here’s the relevant section of the code:
try:
plex = PlexServer(baseurl, token)
movies = plex.library.sectionByID(library_id).search(libtype='movie')
except Exception as e:
print(f"Fehler beim Verbinden mit dem Plex-Server oder Abrufen der Bibliothek: {e}")
return []
movie_data = []
for movie in movies:
film_info = {
"title": movie.title,
"year": movie.year,
"trailer_available": False,
"trailer_audio_languages": [],
"has_german_trailer": False
}
# Überprüfen, ob Extras vorhanden sind und ob es Trailer gibt
if movie.extras():
for extra in movie.extras():
extra_title = extra.title
if extra.subtype == 'trailer':
film_info["trailer_available"] = True
# Durchlaufe alle Streams des Trailers, um Audiospuren zu finden
for part in extra.iterParts():
for stream in part.audioStreams():
if stream.streamType == 2 and stream.language: # StreamType 2 ist Audio
film_info["trailer_audio_languages"].append(stream.language)
if 'german' in extra_title.lower():
film_info["trailer_audio_languages"].append("German")
if 'deutsch' in extra_title.lower():
film_info["trailer_audio_languages"].append("Deutsch")
break # Nur den ersten Trailer prüfen
# Prüfen, ob eine der Audiosprachen Deutsch ist oder Deutsch im Titel genannt wird
if "Deutsch" in film_info["trailer_audio_languages"] or "German" in film_info["trailer_audio_languages"]:
film_info["has_german_trailer"] = True
movie_data.append(film_info)
if film_info["has_german_trailer"] == False:
if movie.extras():
for extra in movie.extras():
if extra.subtype == 'trailer':
print(f" - Lösche Trailer: {extra.title}")
extra.delete()
...
The trailer is removed from the movie object (view and XML). But unfortunately the link of the trailer to the “Play Trailer button” is not removed…
This is what it looks like:
Movie with German trailer (correct display: trailer visible, play trailer button above also):
Movie that never had a trailer (also correct display: no trailer and no button to play trailer):
The relevant XML of that movie looks like this:
<Extras size="0"> </Extras>
Movie where I removed the trailer (incorrect display: trailer gone, button to play trailer there):
The relevant XML of that movie looks like this (the same as the other movie):
<Extras size="0"> </Extras>
And since the trailer is deleted, an attempt to play it results in an error message:

My question:
How do I delete the extras of a movie in a way that Plex also removes the play trailer button?
That one:
![]()
Is there a way to get rid of this button? I tried “refresh metadata” for that movie, “Analyze” that movie, and re-read the library files of that library.
If I add another local trailer and try to remove it again, the reference of that local trailer trailer stays.
Only if I remove the movie itself from the library and re-add it without any trailer, the trailer and the trailer play button go away.
Of course, it’s not every day’s work for Plex to remove existing trailers as they are meant to stay. But if the file is gone, the play button should be gone, too. Shouldn’t it?




