From 647863516334e69580fcae4a408e4fcff7af87e5 Mon Sep 17 00:00:00 2001 From: gyh1621 Date: Wed, 25 Mar 2020 07:29:45 +0000 Subject: [PATCH] stop sorting query results by language in zimuku --- libs/subliminal_patch/providers/zimuku.py | 26 ++++++++--------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/libs/subliminal_patch/providers/zimuku.py b/libs/subliminal_patch/providers/zimuku.py index 54105844c..5e3b917e3 100644 --- a/libs/subliminal_patch/providers/zimuku.py +++ b/libs/subliminal_patch/providers/zimuku.py @@ -96,7 +96,7 @@ class ZimukuProvider(Provider): r.content.decode("utf-8", "ignore"), ["html.parser"] ) subs_body = bs_obj.find("div", class_="subs box clearfix").find("tbody") - subs, lan_scores = [], {} + subs = [] for sub in subs_body.find_all("tr"): a = sub.find("a") name = _extract_name(a.text) @@ -104,20 +104,15 @@ class ZimukuProvider(Provider): 0 ] # remove ext because it can be an archive type - lan_score = 0 + language = Language("eng") for img in sub.find("td", class_="tac lang").find_all("img"): - if "uk" in img.attrs["src"]: - lan_score += 1 - elif "hongkong" in img.attrs["src"]: - lan_score += 2 - elif "china" in img.attrs["src"]: - lan_score += 4 - elif "jollyroger" in img.attrs["src"]: - lan_score += 8 - if lan_score == 1: - language = Language("eng") - else: - language = Language("zho") + if ( + "hongkong" in img.attrs["src"] + or "china" in img.attrs["src"] + or "jollyroger" in img.attrs["src"] + ): + language = Language("zho") + break sub_page_link = urljoin(self.server_url, a.attrs["href"]) backup_session = copy.deepcopy(self.session) backup_session.headers["Referer"] = link @@ -125,10 +120,7 @@ class ZimukuProvider(Provider): subs.append( self.subtitle_class(language, sub_page_link, name, backup_session) ) - lan_scores[name] = lan_score - # prefer double languages - subs.sort(key=lambda s: lan_scores[s.version], reverse=True) return subs def query(self, keyword, season=None, episode=None, year=None):