Skip to content

Commit

Permalink
♻️ fix date_raw_update and data_raw2tuple in class NexusPHP
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Jun 11, 2018
1 parent 125fa72 commit 18bbfa0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
16 changes: 8 additions & 8 deletions extractors/base/nexusphp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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))
Expand All @@ -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
"""
Expand Down
7 changes: 4 additions & 3 deletions extractors/byrbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"]),
Expand All @@ -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),
]

Expand Down
7 changes: 4 additions & 3 deletions extractors/hudbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"]) # 质量
Expand Down
7 changes: 4 additions & 3 deletions extractors/npubits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"]),
Expand All @@ -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", ""),
Expand Down
7 changes: 4 additions & 3 deletions extractors/nwsuaf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"),
Expand All @@ -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),
)
8 changes: 4 additions & 4 deletions extractors/tjupt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]),
Expand All @@ -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"]), # 内容
Expand Down

0 comments on commit 18bbfa0

Please sign in to comment.