|
10 | 10 | # Set all movies to use English non-forced subtitles if available, otherwise print no subtitles found
|
11 | 11 | for movie in plex.library.section('Movies').all():
|
12 | 12 | movie.reload()
|
| 13 | + # Get all English subtitle streams for the current movie |
13 | 14 | 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())] |
16 | 20 | part = movie.media[0].parts[0]
|
17 | 21 | partsid = part.id
|
18 | 22 | if forced_english_subs and non_forced_english_subs:
|
|
35 | 39 | for episode in show.episodes():
|
36 | 40 | show.reload()
|
37 | 41 | episode.reload()
|
| 42 | + # Get all English subtitle streams for the current show |
38 | 43 | 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())] |
41 | 49 | part = episode.media[0].parts[0]
|
42 | 50 | partsid = part.id
|
43 | 51 | if forced_english_subs and non_forced_english_subs:
|
|
0 commit comments