Solve SSL error with Podnapisi on Ubuntu and Debian machines (Fix #1251)

pull/1451/head
vitiko98 3 years ago
parent 38d2332c39
commit 1c7584d33a

@ -2,12 +2,19 @@
from __future__ import absolute_import
import logging
import re
import io
import re
import ssl
from urllib3 import poolmanager
from zipfile import ZipFile
from guessit import guessit
from requests import Session
from requests.adapters import HTTPAdapter
from subliminal.utils import sanitize
from subliminal_patch.subtitle import guess_matches
from subliminal_patch.providers.mixins import ProviderSubtitleArchiveMixin
@ -102,6 +109,17 @@ class PodnapisiSubtitle(_PodnapisiSubtitle):
return matches
class PodnapisiAdapter(HTTPAdapter):
def init_poolmanager(self, connections, maxsize, block=False):
ctx = ssl.create_default_context()
ctx.set_ciphers('DEFAULT@SECLEVEL=1')
self.poolmanager = poolmanager.PoolManager(
num_pools=connections,
maxsize=maxsize,
block=block,
ssl_version=ssl.PROTOCOL_TLS,
ssl_context=ctx
)
class PodnapisiProvider(_PodnapisiProvider, ProviderSubtitleArchiveMixin):
languages = ({Language('por', 'BR'), Language('srp', script='Latn'), Language('srp', script='Cyrl')} |
@ -124,6 +142,10 @@ class PodnapisiProvider(_PodnapisiProvider, ProviderSubtitleArchiveMixin):
super(PodnapisiProvider, self).__init__()
def initialize(self):
super().initialize()
self.session.mount('https://', PodnapisiAdapter())
def list_subtitles(self, video, languages):
if video.is_special:
logger.info("%s can't search for specials right now, skipping", self)

Loading…
Cancel
Save