From 88432ed5ea21ad8842413ee3a35e8ae0ecd5c3d6 Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Wed, 2 Jun 2021 20:41:13 +0200 Subject: [PATCH] subtitle: when preferred is none get all subs. fixes: #1391 --- lib/svtplay_dl/tests/test_stream.py | 2 +- lib/svtplay_dl/utils/stream.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/svtplay_dl/tests/test_stream.py b/lib/svtplay_dl/tests/test_stream.py index 4055339..61525bf 100644 --- a/lib/svtplay_dl/tests/test_stream.py +++ b/lib/svtplay_dl/tests/test_stream.py @@ -152,7 +152,7 @@ class streamSubtile(unittest.TestCase): subtitle(setup_defaults(), "wrst", "http://example.com", "sv"), ] subs = subtitle_filter(test_subs) - assert len(subs) == 1 + assert len(subs) == 3 def test_subtitleFilter2(self): config = setup_defaults() diff --git a/lib/svtplay_dl/utils/stream.py b/lib/svtplay_dl/utils/stream.py index 7b275a8..59e4a41 100644 --- a/lib/svtplay_dl/utils/stream.py +++ b/lib/svtplay_dl/utils/stream.py @@ -85,7 +85,10 @@ def subtitle_filter(subtitles) -> List: subs.append(sub) languages.append(sub.subfix) else: - if sub.subfix == preferred: + if preferred is None: + subs.append(sub) + languages.append(sub.subfix) + if preferred and sub.subfix == preferred: subs.append(sub) languages.append(sub.subfix) return subs