From 18bbfa0d2fc6553eeee59a7a60258eeeed819c91 Mon Sep 17 00:00:00 2001 From: Rhilip Date: Mon, 11 Jun 2018 10:23:40 +0800 Subject: [PATCH] :recycle: fix date_raw_update and data_raw2tuple in class NexusPHP --- extractors/base/nexusphp.py | 16 ++++++++-------- extractors/byrbt.py | 7 ++++--- extractors/hudbt.py | 7 ++++--- extractors/npubits.py | 7 ++++--- extractors/nwsuaf6.py | 7 ++++--- extractors/tjupt.py | 8 ++++---- 6 files changed, 28 insertions(+), 24 deletions(-) diff --git a/extractors/base/nexusphp.py b/extractors/base/nexusphp.py index a389c3a..7121a29 100644 --- a/extractors/base/nexusphp.py +++ b/extractors/base/nexusphp.py @@ -163,7 +163,7 @@ def torrent_reseed(self, torrent): torrent_raw_info_dict = self.torrent_clone(clone_id) if not torrent_raw_info_dict: raise ValueError("The clone torrent for tid in db-record is not exist.") - Logger.debug("Get clone torrent info from \"DataBase\" OK, Which id: {}".format(clone_id)) + Logger.debug("Get clone torrent info from \"DataBase\" OK, Which id: {}".format(clone_id)) else: raise KeyError("Set not get clone torrent id from \"Database.\"") except (KeyError, ValueError) as e: @@ -186,8 +186,8 @@ def torrent_reseed(self, torrent): raise NoCloneTorrentError("The clone torrent's category is not allowed.") Logger.info("Begin post The torrent {0},which name: {1}".format(torrent.id, torrent.name)) - new_dict = self.date_raw_update(torrent_name_search=name_pattern, raw_info=torrent_raw_info_dict) - multipart_data = self.data_raw2tuple(torrent, raw_info=new_dict) + new_dict = self.date_raw_update(torrent, name_pattern, torrent_raw_info_dict) + multipart_data = self.data_raw2tuple(new_dict) flag = self.torrent_upload(torrent=torrent, data=multipart_data) else: raise NoCloneTorrentError("Can't find any clone torrent to used.".format(self.name)) @@ -210,21 +210,21 @@ def torrent_clone(self, tid) -> dict: """ raise NotImplementedError - def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: + def date_raw_update(self, torrent, torrent_name_search, raw_info: dict) -> dict: """ Update the raw dict due to the pre-reseed torrent's info (main from `torrent_name_search`) - + + :param torrent: class transmissionrpc.Torrent :param torrent_name_search: class '_sre.SRE_Match' :param raw_info: dict, The information dict about the clone torrent :return: dict, The information dict about the pre-reseed torrent """ raise NotImplementedError - def data_raw2tuple(self, torrent, raw_info: dict) -> tuple: + def data_raw2tuple(self, raw_info: dict) -> tuple: """ Sort the information dict to the post tuple. - - :param torrent: class transmissionrpc.Torrent + :param raw_info: dict, The information dict about the pre-reseed torrent :return: tuple, The prepared tuple used to upload to the site """ diff --git a/extractors/byrbt.py b/extractors/byrbt.py index e0d3457..273bc46 100644 --- a/extractors/byrbt.py +++ b/extractors/byrbt.py @@ -233,7 +233,8 @@ def torrent_clone(self, tid) -> dict: Logger.error("Error,this torrent may not exist or ConnectError") return return_dict - def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: + def date_raw_update(self, torrent, torrent_name_search, raw_info: dict) -> dict: + raw_info["descr"] = self.enhance_descr(torrent=torrent, info_dict=raw_info) filetype = torrent_name_search.group("filetype") if raw_info["type"] == 401: # Series raw_info["tv_ename"] = torrent_name_search.group("full_name") @@ -250,7 +251,7 @@ def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: return raw_info - def data_raw2tuple(self, torrent, raw_info: dict): + def data_raw2tuple(self, raw_info: dict): begin_list = [ ("type", raw_info["type"]), ("second_type", raw_info["second_type"]), @@ -264,7 +265,7 @@ def data_raw2tuple(self, torrent, raw_info: dict): ("url", raw_info["url"]), ("dburl", raw_info["dburl"]), ("nfo", ''), - ("descr", self.enhance_descr(torrent=torrent, info_dict=raw_info)), + ("descr", raw_info["descr"]), ("uplver", self._UPLVER), ] diff --git a/extractors/hudbt.py b/extractors/hudbt.py index 6e78a80..4f51e8d 100644 --- a/extractors/hudbt.py +++ b/extractors/hudbt.py @@ -97,7 +97,8 @@ def torrent_clone(self, tid) -> dict: return return_dict - def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: + def date_raw_update(self, torrent, torrent_name_search, raw_info: dict) -> dict: + raw_info["descr"] = self.enhance_descr(torrent=torrent, info_dict=raw_info) type_ = int(raw_info["type"]) if type_ == 418: # 欧美剧集 torrent_raw_name = torrent_name_search.group("full_name") @@ -111,14 +112,14 @@ def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: return raw_info - def data_raw2tuple(self, torrent, raw_info: dict) -> tuple: + def data_raw2tuple(self, raw_info: dict) -> tuple: return ( ("dl-url", ''), # 下载链接 ("name", raw_info["name"]), # 主标题 ("small_descr", raw_info["small_descr"]), # 副标题 ("url", raw_info["url"]), # IMDb链接 ("nfo", ''), # NFO文件 - ("descr", self.enhance_descr(torrent=torrent, info_dict=raw_info)), # 简介 + ("descr", raw_info["descr"]), # 简介 ("type", raw_info["type"]), # 类型 ("data[Tcategory][Tcategory][]", ''), # 分类 ("standard_sel", raw_info["standard_sel"]) # 质量 diff --git a/extractors/npubits.py b/extractors/npubits.py index e2fc324..29519c6 100644 --- a/extractors/npubits.py +++ b/extractors/npubits.py @@ -53,7 +53,8 @@ def torrent_clone(self, tid) -> dict: Logger.info("Get clone torrent's info,id: {tid},title:\"{ti}\"".format(tid=tid, ti=res_dic["name"])) return res_dic - def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: + def date_raw_update(self, torrent, torrent_name_search, raw_info: dict) -> dict: + raw_info["descr"] = self.enhance_descr(torrent=torrent, info_dict=raw_info) if int(raw_info["category"]) == 402: # Series raw_info["name"] = torrent_name_search.group("full_name") season_episode_info = episode_eng2chs(torrent_name_search.group("episode")) @@ -65,7 +66,7 @@ def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: return raw_info - def data_raw2tuple(self, torrent, raw_info): + def data_raw2tuple(self, raw_info): return ( # Submit form ("transferred_url", raw_info["transferred_url"]), ("type", raw_info["category"]), @@ -75,7 +76,7 @@ def data_raw2tuple(self, torrent, raw_info): ("color", 0), # Tell me those three key's function~ ("font", 0), ("size", 0), - ("descr", string2base64(self.enhance_descr(torrent=torrent, info_dict=raw_info))), + ("descr", string2base64(raw_info["descr"])), ("nfo", ""), # 实际上并不是这样的,但是nfo一般没有,故这么写 ("uplver", self._UPLVER), ("transferred_torrent_file_base64", ""), diff --git a/extractors/nwsuaf6.py b/extractors/nwsuaf6.py index 48c83c1..45945ae 100644 --- a/extractors/nwsuaf6.py +++ b/extractors/nwsuaf6.py @@ -129,7 +129,7 @@ def torrent_clone(self, tid) -> dict: Logger.info("Get clone torrent's info,id: {tid},title:\"{ti}\"".format(tid=tid, ti=res_dic["name"])) return res_dic - def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: + def date_raw_update(self, torrent, torrent_name_search, raw_info: dict) -> dict: raw_title = raw_info["name"] cat = raw_info["category"] @@ -171,10 +171,11 @@ def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: # Assign raw info raw_info["name"] = new_title + raw_info["descr"] = self.enhance_descr(torrent=torrent, info_dict=raw_info) return raw_info - def data_raw2tuple(self, torrent, raw_info): + def data_raw2tuple(self, raw_info): return ( # Submit form ("cite_torrent", raw_info["clone_id"]), ("ismttv", "no"), @@ -189,6 +190,6 @@ def data_raw2tuple(self, torrent, raw_info): ("color", 0), # Tell me those three key's function~ ("font", 0), ("size", 0), - ("descr", self.enhance_descr(torrent=torrent, info_dict=raw_info)), + ("descr", raw_info["descr"]), ("uplver", self._UPLVER), ) diff --git a/extractors/tjupt.py b/extractors/tjupt.py index faef8c7..93dbedb 100644 --- a/extractors/tjupt.py +++ b/extractors/tjupt.py @@ -100,8 +100,8 @@ def torrent_clone(self, tid): return res_dic - def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: - # TODO Change info due to reseed torrent's name information + def date_raw_update(self, torrent, torrent_name_search, raw_info: dict) -> dict: + raw_info["descr"] = self.enhance_descr(torrent=torrent, info_dict=raw_info) type_ = int(raw_info["type"]) if type_ == 401: # 电影 pass @@ -114,7 +114,7 @@ def date_raw_update(self, torrent_name_search, raw_info: dict) -> dict: return raw_info - def data_raw2tuple(self, torrent, raw_info: dict): + def data_raw2tuple(self, raw_info: dict): begin_post_list = [ ("id", raw_info["clone_id"]), ("quote", raw_info["clone_id"]), @@ -130,7 +130,7 @@ def data_raw2tuple(self, torrent, raw_info: dict): ("color", 0), # Tell me those three key's function~ ("font", 0), ("size", 0), - ("descr", self.enhance_descr(torrent=torrent, info_dict=raw_info)), # 简介* + ("descr", raw_info["descr"]), # 简介* ("getDescByTorrentId", ""), ("source_sel", raw_info["source_sel"]), # 质量 ("team_sel", raw_info["team_sel"]), # 内容