summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorVitiko <[email protected]>2023-06-12 19:36:11 -0400
committerVitiko <[email protected]>2023-06-12 19:36:11 -0400
commite3c4def89acc185bdbb67f8dcb7a12531e209df7 (patch)
tree0e37cb51b7a53fc65ac352722e3bdd32a5adc377 /libs
parent1c1caeb78bc156777b4f8a5f95ebc896a3922ab4 (diff)
downloadbazarr-e3c4def89acc185bdbb67f8dcb7a12531e209df7.tar.gz
bazarr-e3c4def89acc185bdbb67f8dcb7a12531e209df7.zip
Subf2m Provider: add user-agent header configurationv1.2.2-beta.17
This change fixes empty queries.
Diffstat (limited to 'libs')
-rw-r--r--libs/subliminal_patch/providers/subf2m.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/libs/subliminal_patch/providers/subf2m.py b/libs/subliminal_patch/providers/subf2m.py
index 8a9807fff..7f8cb6bfd 100644
--- a/libs/subliminal_patch/providers/subf2m.py
+++ b/libs/subliminal_patch/providers/subf2m.py
@@ -115,6 +115,21 @@ _LANGUAGE_MAP = {
"turkish": "tur",
}
+_DEFAULT_HEADERS = {
+ "authority": "subf2m.co",
+ "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
+ "accept-language": "en-US,en;q=0.9",
+ "referer": "https://subf2m.co",
+ "sec-ch-ua": '"Chromium";v="111", "Not(A:Brand";v="8"',
+ "sec-ch-ua-mobile": "?0",
+ "sec-ch-ua-platform": '"Unknown"',
+ "sec-fetch-dest": "document",
+ "sec-fetch-mode": "navigate",
+ "sec-fetch-site": "same-origin",
+ "sec-fetch-user": "?1",
+ "upgrade-insecure-requests": "1",
+}
+
class Subf2mProvider(Provider):
provider_name = "subf2m"
@@ -138,15 +153,25 @@ class Subf2mProvider(Provider):
video_types = (Episode, Movie)
subtitle_class = Subf2mSubtitle
- def __init__(self, verify_ssl=True):
+ def __init__(self, verify_ssl=True, user_agent=None, session_factory=None):
super().__init__()
+ if not user_agent:
+ raise ValueError("User-agent config missing")
+
+ self._user_agent = user_agent
self._verify_ssl = verify_ssl
+ self._session_factory = session_factory
def initialize(self):
- self._session = Session()
- self._session.verify = self._verify_ssl
+ if self._session_factory is not None:
+ self._session = self._session_factory()
+ else:
+ logger.debug("No session factory set. Using default requests.Session.")
+ self._session = Session()
- self._session.headers.update({"user-agent": "Bazarr"})
+ self._session.verify = self._verify_ssl
+ self._session.headers.update(_DEFAULT_HEADERS)
+ self._session.headers.update({"user-agent": self._user_agent})
def terminate(self):
self._session.close()