summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorVitiko <[email protected]>2022-04-18 16:58:11 -0400
committerVitiko <[email protected]>2022-04-18 16:58:11 -0400
commitd95d6b9d357541fccfd75011994e3983bc43a71e (patch)
tree2db7d5830fd4b98bd1a1473f398485e70ac64cc4 /libs
parent5e0461eee56b75fd546811dc880bec11ab84155c (diff)
downloadbazarr-d95d6b9d357541fccfd75011994e3983bc43a71e.tar.gz
bazarr-d95d6b9d357541fccfd75011994e3983bc43a71e.zip
no log: update subf2m provider
Diffstat (limited to 'libs')
-rw-r--r--libs/subliminal_patch/providers/subf2m.py21
1 files changed, 6 insertions, 15 deletions
diff --git a/libs/subliminal_patch/providers/subf2m.py b/libs/subliminal_patch/providers/subf2m.py
index 061976837..4f9c9b29f 100644
--- a/libs/subliminal_patch/providers/subf2m.py
+++ b/libs/subliminal_patch/providers/subf2m.py
@@ -1,11 +1,7 @@
# -*- coding: utf-8 -*-
-import io
import logging
-from zipfile import ZipFile, is_zipfile
-from rarfile import RarFile, is_rarfile
-
from guessit import guessit
from requests import Session
from bs4 import BeautifulSoup as bso
@@ -16,7 +12,8 @@ from subliminal_patch.core import Movie
from subliminal_patch.providers import Provider
from subliminal_patch.subtitle import Subtitle
from subliminal_patch.subtitle import guess_matches
-from subliminal_patch.providers.mixins import ProviderSubtitleArchiveMixin
+from subliminal_patch.providers.utils import get_archive_from_bytes
+from subliminal_patch.providers.utils import get_subtitle_from_archive
from subzero.language import Language
@@ -88,7 +85,7 @@ _LANGUAGE_MAP = {
}
-class Subf2mProvider(Provider, ProviderSubtitleArchiveMixin):
+class Subf2mProvider(Provider):
provider_name = "subf2m"
_supported_languages = {}
@@ -240,18 +237,12 @@ class Subf2mProvider(Provider, ProviderSubtitleArchiveMixin):
downloaded = self._session.get(download_url, allow_redirects=True)
- archive_stream = io.BytesIO(downloaded.content)
+ archive = get_archive_from_bytes(downloaded.content)
- if is_zipfile(archive_stream):
- logger.debug("Identified zip archive")
- archive = ZipFile(archive_stream)
- elif is_rarfile(archive_stream):
- logger.debug("Identified rar archive")
- archive = RarFile(archive_stream)
- else:
+ if archive is None:
raise APIThrottled(f"Invalid archive: {subtitle.page_link}")
- subtitle.content = self.get_subtitle_from_archive(subtitle, archive)
+ subtitle.content = get_subtitle_from_archive(archive, get_first_subtitle=True)
def _get_subtitle_from_item(item, language):