summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLouis Vézina <[email protected]>2019-09-22 22:27:23 -0400
committerLouis Vézina <[email protected]>2019-09-22 22:27:23 -0400
commitbcc4183ef3092d50dae78a6179dd9d88569a0730 (patch)
treeea0741b2effe33eee8b4682983f919d04bd65c31
parentb055d89b4ff5690ada95d1be7967f02a451e80f1 (diff)
downloadbazarr-bcc4183ef3092d50dae78a6179dd9d88569a0730.tar.gz
bazarr-bcc4183ef3092d50dae78a6179dd9d88569a0730.zip
WIP
-rw-r--r--bazarr.py9
-rw-r--r--libs/subliminal/providers/subscenter.py2
-rw-r--r--libs/subliminal_patch/http.py6
-rw-r--r--libs/subliminal_patch/providers/subscene.py12
-rw-r--r--views/movie.tpl2
5 files changed, 17 insertions, 14 deletions
diff --git a/bazarr.py b/bazarr.py
index 04ef801e7..d0c983a0b 100644
--- a/bazarr.py
+++ b/bazarr.py
@@ -19,9 +19,12 @@ def check_python_version():
minimum_python_version = ".".join(str(i) for i in minimum_python_version_tuple)
minimum_python3_version = ".".join(str(i) for i in minimum_python3_version_tuple)
- if int(python_version[0]) == minimum_python3_version_tuple[0] and int(python_version[1]) < minimum_python3_version_tuple[1]:
- print("Python " + minimum_python3_version + " or greater required. Current version is " + platform.python_version() + ". Please upgrade Python.")
- os._exit(0)
+ if int(python_version[0]) == minimum_python3_version_tuple[0]:
+ if int(python_version[1]) >= minimum_python3_version_tuple[1]:
+ pass
+ else:
+ print("Python " + minimum_python3_version + " or greater required. Current version is " + platform.python_version() + ". Please upgrade Python.")
+ os._exit(0)
elif int(python_version[1]) < minimum_python_version_tuple[1] or int(re.search(r'\d+', python_version[2]).group()) < minimum_python_version_tuple[2]:
print("Python " + minimum_python_version + " or greater required. Current version is " + platform.python_version() + ". Please upgrade Python.")
diff --git a/libs/subliminal/providers/subscenter.py b/libs/subliminal/providers/subscenter.py
index b1a5cc02b..0ea896d76 100644
--- a/libs/subliminal/providers/subscenter.py
+++ b/libs/subliminal/providers/subscenter.py
@@ -122,7 +122,7 @@ class SubsCenterProvider(Provider):
self.session.close()
- @region.cache_on_arguments(expiration_time=SHOW_EXPIRATION_TIME)
+ @region.cache_on_arguments(expiration_time=SHOW_EXPIRATION_TIME, should_cache_fn=lambda value: value)
def _search_url_titles(self, title):
"""Search the URL titles by kind for the given `title`.
diff --git a/libs/subliminal_patch/http.py b/libs/subliminal_patch/http.py
index 5018b3b27..7ed8ef4ef 100644
--- a/libs/subliminal_patch/http.py
+++ b/libs/subliminal_patch/http.py
@@ -148,7 +148,7 @@ class CFSession(CloudScraper):
cache_key = "cf_data3_%s" % domain
if not self.cookies.get("cf_clearance", "", domain=domain):
- cf_data = str(region.get(cache_key))
+ cf_data = region.get(cache_key)
if cf_data is not NO_VALUE:
cf_cookies, hdrs = cf_data
logger.debug("Trying to use old cf data for %s: %s", domain, cf_data)
@@ -165,9 +165,9 @@ class CFSession(CloudScraper):
pass
else:
if cf_data and "cf_clearance" in cf_data[0] and cf_data[0]["cf_clearance"]:
- if cf_data != str(region.get(cache_key)):
+ if cf_data != region.get(cache_key):
logger.debug("Storing cf data for %s: %s", domain, cf_data)
- region.set(cache_key, bytearray(cf_data, encoding='utf-8'))
+ region.set(cache_key, cf_data)
elif cf_data[0]["cf_clearance"]:
logger.debug("CF Live tokens not updated")
diff --git a/libs/subliminal_patch/providers/subscene.py b/libs/subliminal_patch/providers/subscene.py
index fdfca1af8..04912447b 100644
--- a/libs/subliminal_patch/providers/subscene.py
+++ b/libs/subliminal_patch/providers/subscene.py
@@ -141,7 +141,7 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
logger.info("Creating session")
self.session = RetryingCFSession()
- prev_cookies = str(region.get("subscene_cookies2"))
+ prev_cookies = region.get("subscene_cookies2")
if prev_cookies != NO_VALUE:
logger.debug("Re-using old subscene cookies: %r", prev_cookies)
self.session.cookies.update(prev_cookies)
@@ -152,11 +152,11 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
def login(self):
r = self.session.get("https://subscene.com/account/login")
- if "Server Error" in r.content:
+ if "Server Error" in r.text:
logger.error("Login unavailable; Maintenance?")
raise ServiceUnavailable("Login unavailable; Maintenance?")
- match = re.search(r"<script id='modelJson' type='application/json'>\s*(.+)\s*</script>", r.content)
+ match = re.search(r"<script id='modelJson' type='application/json'>\s*(.+)\s*</script>", r.text)
if match:
h = six.moves.html_parser.HTMLParser()
@@ -178,7 +178,7 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
r"scope.+?value=\"(?P<scope>.+?)\".+?"
r"state.+?value=\"(?P<state>.+?)\".+?"
r"session_state.+?value=\"(?P<session_state>.+?)\"",
- r.content, re.MULTILINE | re.DOTALL)
+ r.text, re.MULTILINE | re.DOTALL)
if pep_content:
r = self.session.post(SITE_DOMAIN, pep_content.groupdict())
@@ -194,7 +194,7 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
del cj[cn]
logger.debug("Storing cookies: %r", cj)
- region.set("subscene_cookies2", bytearray(cj, encoding='utf-8'))
+ region.set("subscene_cookies2", bytearray(cj,encoding='utf-8'))
return
raise ProviderError("Something went wrong when trying to log in #1")
@@ -219,7 +219,7 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
acc_filters["SelectedIds"] = selected_ids
self.filters["LanguageFilter"] = ",".join(acc_filters["SelectedIds"])
- last_filters = str(region.get("subscene_filters"))
+ last_filters = region.get("subscene_filters")
if last_filters != acc_filters:
region.set("subscene_filters", bytearray(acc_filters, encoding='utf-8'))
logger.debug("Setting account filters to %r", acc_filters)
diff --git a/views/movie.tpl b/views/movie.tpl
index 2c0c6eb00..5acf2b14d 100644
--- a/views/movie.tpl
+++ b/views/movie.tpl
@@ -170,7 +170,7 @@
<tbody>
<%
subtitles_files = ast.literal_eval(str(details.subtitles))
- subtitles_files.sort()
+ subtitles_files.sort(key = lambda x: x[0])
if subtitles_files is not None:
for subtitles_file in subtitles_files:
if subtitles_file[0].endswith(':forced'):