From 5ba92b21425b1b50eec75d4bc295f25a1a8312b0 Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 28 Jan 2019 16:59:07 +0100 Subject: [PATCH 1/2] Change User-Agent for Titlovi provider --- bazarr/get_settings.py | 0 libs/subliminal_patch/providers/titlovi.py | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 bazarr/get_settings.py diff --git a/bazarr/get_settings.py b/bazarr/get_settings.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/libs/subliminal_patch/providers/titlovi.py b/libs/subliminal_patch/providers/titlovi.py index 8e2a31c65..c3e26069f 100644 --- a/libs/subliminal_patch/providers/titlovi.py +++ b/libs/subliminal_patch/providers/titlovi.py @@ -134,8 +134,8 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin): def initialize(self): self.session = Session() - self.session.headers['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3)' \ - 'Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)' + self.session.headers[ + 'User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' logger.debug('User-Agent set to %s', self.session.headers['User-Agent']) self.session.headers['Referer'] = self.server_url logger.debug('Referer set to %s', self.session.headers['Referer']) @@ -223,7 +223,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 From f1b7e28e57f32ed7a1011209ac360e16ee99f721 Mon Sep 17 00:00:00 2001 From: Halali Date: Mon, 28 Jan 2019 19:47:59 +0100 Subject: [PATCH 2/2] Change User-Agent to random User-Agent for Titlovi provider --- libs/subliminal_patch/providers/titlovi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/subliminal_patch/providers/titlovi.py b/libs/subliminal_patch/providers/titlovi.py index c3e26069f..8639cf6d9 100644 --- a/libs/subliminal_patch/providers/titlovi.py +++ b/libs/subliminal_patch/providers/titlovi.py @@ -4,6 +4,7 @@ import io import logging import math import re +from random import randint import rarfile @@ -24,6 +25,7 @@ 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 .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST # parsing regex definitions title_re = re.compile(r'(?P(?:.+(?= [Aa][Kk][Aa] ))|.+)(?:(?:.+)(?P<altitle>(?<= [Aa][Kk][Aa] ).+))?') @@ -134,8 +136,7 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin): def initialize(self): self.session = Session() - self.session.headers[ - 'User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36' + 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 logger.debug('Referer set to %s', self.session.headers['Referer'])