mirror of
https://github.com/morpheus65535/bazarr
synced 2025-03-15 00:18:48 +00:00
Merge remote-tracking branch 'origin/development' into development
This commit is contained in:
commit
9fbc58b56b
2 changed files with 39 additions and 5 deletions
|
@ -1,11 +1,14 @@
|
|||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import os
|
||||
import io
|
||||
import time
|
||||
import urllib.parse
|
||||
|
||||
from json.decoder import JSONDecodeError
|
||||
|
||||
from zipfile import ZipFile
|
||||
from guessit import guessit
|
||||
from requests import Session
|
||||
|
@ -91,7 +94,14 @@ class ArgenteamProvider(Provider, ProviderSubtitleArchiveMixin):
|
|||
r = self.session.get(API_URL + "search", params={"q": query}, timeout=10)
|
||||
r.raise_for_status()
|
||||
|
||||
results = r.json()
|
||||
try:
|
||||
results = r.json()
|
||||
except JSONDecodeError:
|
||||
return []
|
||||
|
||||
if not results.get("results"):
|
||||
return []
|
||||
|
||||
match_ids = []
|
||||
for result in results["results"]:
|
||||
if result["type"] == "movie" and is_episode:
|
||||
|
@ -194,11 +204,13 @@ class ArgenteamProvider(Provider, ProviderSubtitleArchiveMixin):
|
|||
for aid in argenteam_ids:
|
||||
response = self.session.get(url, params={"id": aid}, timeout=10)
|
||||
response.raise_for_status()
|
||||
content = response.json()
|
||||
if not content:
|
||||
|
||||
try:
|
||||
content = response.json()
|
||||
except JSONDecodeError:
|
||||
continue
|
||||
|
||||
if not content.get("releases"):
|
||||
if not content or not content.get("releases"):
|
||||
continue
|
||||
|
||||
imdb_id = year = None
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue