libs: update subliminal_patch to current; revert fixed Bazarr/1 user agent

pull/380/head
panni 6 years ago
parent 171fd61116
commit c11ba2c76d

@ -147,7 +147,7 @@ class ArgenteamProvider(Provider, ProviderSubtitleArchiveMixin):
def initialize(self):
self.session = Session()
self.session.headers = {'User-Agent': "Bazarr/1"}
self.session.headers = {'User-Agent': os.environ.get("SZ_USER_AGENT", "Sub-Zero/2")}
def terminate(self):
self.session.close()

@ -103,7 +103,7 @@ class AssrtProvider(Provider):
def initialize(self):
self.session = Session()
self.session.headers = {'User-Agent': "Bazarr/1"}
self.session.headers = {'User-Agent': os.environ.get("SZ_USER_AGENT", "Sub-Zero/2")}
def terminate(self):
self.session.close()

@ -133,7 +133,7 @@ class HosszupuskaProvider(Provider, ProviderSubtitleArchiveMixin):
def initialize(self):
self.session = Session()
self.session.headers = {'User-Agent': "Bazarr/1"}
self.session.headers = {'User-Agent': os.environ.get("SZ_USER_AGENT", "Sub-Zero/2")}
def terminate(self):
self.session.close()

@ -121,7 +121,7 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider):
def get_server_proxy(self, url, timeout=None):
return ServerProxy(url, SubZeroRequestsTransport(use_https=self.use_ssl, timeout=timeout or self.timeout,
user_agent="Bazarr/1"))
user_agent=os.environ.get("SZ_USER_AGENT", "Sub-Zero/2")))
def log_in(self, server_url=None):
if server_url:
@ -132,7 +132,7 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider):
response = self.retry(
lambda: checked(
lambda: self.server.LogIn(self.username, self.password, 'eng',
"Bazarr/1")
os.environ.get("SZ_USER_AGENT", "Sub-Zero/2"))
)
)
@ -296,8 +296,8 @@ class OpenSubtitlesProvider(ProviderRetryMixin, _OpenSubtitlesProvider):
elif not only_foreign and not also_foreign and foreign_parts_only:
continue
# foreign/forced *also* wanted
elif also_foreign and foreign_parts_only:
# set subtitle language to forced if it's foreign_parts_only
elif (also_foreign or only_foreign) and foreign_parts_only:
language = Language.rebuild(language, forced=True)
if language not in languages:

@ -150,7 +150,7 @@ class SuperSubtitlesProvider(Provider, ProviderSubtitleArchiveMixin):
def initialize(self):
self.session = Session()
self.session.headers = {'User-Agent': "Bazarr/1"}
self.session.headers = {'User-Agent': os.environ.get("SZ_USER_AGENT", "Sub-Zero/2")}
def terminate(self):
self.session.close()

@ -4,7 +4,6 @@ import io
import logging
import math
import re
from random import randint
import rarfile
@ -12,7 +11,7 @@ from bs4 import BeautifulSoup
from zipfile import ZipFile, is_zipfile
from rarfile import RarFile, is_rarfile
from babelfish import language_converters, Script
from requests import Session
from requests import Session, RequestException
from guessit import guessit
from subliminal_patch.providers import Provider
from subliminal_patch.providers.mixins import ProviderSubtitleArchiveMixin
@ -25,6 +24,8 @@ from subliminal.subtitle import guess_matches
from subliminal.video import Episode, Movie
from subliminal.subtitle import fix_line_ending
from subzero.language import Language
from random import randint
from .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST
# parsing regex definitions
@ -136,6 +137,7 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin):
def initialize(self):
self.session = Session()
logger.debug("Using random user agents")
self.session.headers['User-Agent'] = AGENT_LIST[randint(0, len(AGENT_LIST) - 1)]
logger.debug('User-Agent set to %s', self.session.headers['User-Agent'])
self.session.headers['Referer'] = self.server_url
@ -179,7 +181,11 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin):
try:
r = self.session.get(self.search_url, params=params, timeout=10)
r.raise_for_status()
except RequestException as e:
logger.exception('RequestException %s', e)
break
try:
soup = BeautifulSoup(r.content, 'lxml')
# number of results
@ -224,7 +230,7 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin):
if match:
try:
# decode language
lang = Language.fromtitlovi(match.group('lang') + match.group('script'))
lang = Language.fromtitlovi(match.group('lang')+match.group('script'))
except ValueError:
continue

Loading…
Cancel
Save