From 003e033c937c111cb57684df897cdc9e917c815c Mon Sep 17 00:00:00 2001
From: Vitiko <averroista@protonmail.com>
Date: Thu, 6 Oct 2022 16:38:56 -0400
Subject: [PATCH 1/3] Embedded Subtitles provider: avoid KeyError

---
 libs/fese/stream.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/fese/stream.py b/libs/fese/stream.py
index 3c73b1d3c..1039cdd8b 100755
--- a/libs/fese/stream.py
+++ b/libs/fese/stream.py
@@ -20,7 +20,7 @@ class FFprobeSubtitleStream:
         :raises: LanguageNotFound, UnsupportedCodec
         """
         self.index = int(stream["index"])
-        self.codec_name = stream["codec_name"]
+        self.codec_name = stream.get("codec_name", "Unknown")
 
         try:
             self._codec = _codecs[self.codec_name]

From 582c2d9b3c373b531047bda4fbf4267a7f2b2942 Mon Sep 17 00:00:00 2001
From: Vitiko <averroista@protonmail.com>
Date: Thu, 6 Oct 2022 16:40:45 -0400
Subject: [PATCH 2/3] no log: update conftest.py

---
 tests/subliminal_patch/conftest.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/subliminal_patch/conftest.py b/tests/subliminal_patch/conftest.py
index d60a807aa..7f72a4814 100644
--- a/tests/subliminal_patch/conftest.py
+++ b/tests/subliminal_patch/conftest.py
@@ -6,6 +6,7 @@ import os
 import pytest
 
 from subliminal_patch.core import Movie, Episode
+from subzero.language import Language
 
 
 logging.getLogger("vcr").setLevel(logging.WARNING)
@@ -148,6 +149,11 @@ def episodes():
     }
 
 
+@pytest.fixture
+def languages():
+    return {"en": Language.fromietf("en"), "es-MX": Language("spa", "MX")}
+
+
 @pytest.fixture
 def data():
     return os.path.join(os.path.abspath(os.path.dirname(__file__)), "data")

From a82ab6769d9f508151c1cc438a6ab637d65bd7e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20Bart=C3=ADk?=
 <63553146+sambartik@users.noreply.github.com>
Date: Sun, 9 Oct 2022 15:17:16 +0200
Subject: [PATCH 3/3] Fix titulky's subtitle downloading logic

---
 libs/subliminal_patch/providers/titulky.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libs/subliminal_patch/providers/titulky.py b/libs/subliminal_patch/providers/titulky.py
index aedbe7906..9fdc1661c 100644
--- a/libs/subliminal_patch/providers/titulky.py
+++ b/libs/subliminal_patch/providers/titulky.py
@@ -452,7 +452,11 @@ class TitulkyProvider(Provider, ProviderSubtitleArchiveMixin):
         else:
             subtitle_content = fix_line_ending(res.content)
 
-        if not subtitle_content:
+        if archive and len(archive.infolist()) > 1 and not subtitle_content:
+            logger.info(f"Titulky.com: Couldn't find a proper subtitle file in the downloaded archive.")
+        elif archive and len(archive.infolist()) == 1 and not subtitle_content:
             raise DownloadLimitExceeded("Subtitles download limit has been exceeded")
+        elif not subtitle_content:
+            raise ProviderError("No subtitles provided from titulky")
 
         subtitle.content = subtitle_content