Skip to content

Commit 2508d9e

Browse files
authored
Merge pull request #8 from RileyXX/1-incorrectly-tagged-subtitles-without-the-forced-tag-are-treated-as-non-forced-subs
Fix for incorrectly tagged subtitles
2 parents 38d9201 + fde87c5 commit 2508d9e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

PlexPreferNonForcedSubs.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
# Set all movies to use English non-forced subtitles if available, otherwise print no subtitles found
1111
for movie in plex.library.section('Movies').all():
1212
movie.reload()
13+
# Get all English subtitle streams for the current movie
1314
english_subs = [stream for stream in movie.subtitleStreams() if stream.languageCode == 'eng']
14-
non_forced_english_subs = [stream for stream in english_subs if not stream.forced]
15-
forced_english_subs = [stream for stream in english_subs if stream.forced]
15+
# Filter out any English subtitle streams that are marked as forced
16+
# or have the word "forced" in their title (case insensitive)
17+
non_forced_english_subs = [stream for stream in english_subs if not stream.forced or (hasattr(stream, 'title') and stream.title is not None and 'forced' not in stream.title.lower())]
18+
# Get all English subtitle streams that are marked as forced
19+
forced_english_subs = [stream for stream in english_subs if stream.forced or (hasattr(stream, 'title') and stream.title is not None and 'forced' in stream.title.lower())]
1620
part = movie.media[0].parts[0]
1721
partsid = part.id
1822
if forced_english_subs and non_forced_english_subs:
@@ -35,9 +39,13 @@
3539
for episode in show.episodes():
3640
show.reload()
3741
episode.reload()
42+
# Get all English subtitle streams for the current show
3843
english_subs = [stream for stream in episode.subtitleStreams() if stream.languageCode == 'eng']
39-
non_forced_english_subs = [stream for stream in english_subs if not stream.forced]
40-
forced_english_subs = [stream for stream in english_subs if stream.forced]
44+
# Filter out any English subtitle streams that are marked as forced
45+
# or have the word "forced" in their title (case insensitive)
46+
non_forced_english_subs = [stream for stream in english_subs if not stream.forced or (hasattr(stream, 'title') and stream.title is not None and 'forced' not in stream.title.lower())]
47+
# Get all English subtitle streams that are marked as forced
48+
forced_english_subs = [stream for stream in english_subs if stream.forced or (hasattr(stream, 'title') and stream.title is not None and 'forced' in stream.title.lower())]
4149
part = episode.media[0].parts[0]
4250
partsid = part.id
4351
if forced_english_subs and non_forced_english_subs:

0 commit comments

Comments
 (0)