示例#1
0
    def torrent_clone(self, tid) -> dict:
        return_dict = {}

        api_res = self.post_data(self.url_host + "/api.php",
                                 data={
                                     "action": "getTorrentData",
                                     "torrentId": tid
                                 })
        api_json = api_res.json()

        if api_json["success"]:
            return_dict["clone_id"] = tid
            return_dict["name"] = api_json["name"]
            return_dict["small_descr"] = api_json["small_descr"]
            return_dict["url"] = ("https://www.imdb.com/title/tt" +
                                  api_json["url"]) if api_json["url"] else ""
            return_dict["dburl"] = (
                "https://movie.douban.com/subject/" +
                api_json["dburl"]) if api_json["dburl"] else ""
            return_dict["descr"] = ubb_clean(api_json["descr"])
            return_dict["type"] = api_json["category"]
            for i in [
                    "medium", "codec", "audiocodec", "standard", "processing",
                    "team"
            ]:
                return_dict[i + "_sel"] = api_json[i]
        else:
            Logger.error("Error,this torrent may not exist or ConnectError")
        return return_dict
示例#2
0
    def torrent_clone(self, tid) -> dict:
        """
        Use Internal API: https://npupt.com/transfer.php?url={url} ,Request Method: GET
        The url use base64 encryption, and will response a json dict.
        """
        res_dic = {}
        transferred_url = string2base64(
            "{host}/details.php?id={tid}&hit=1".format(host=self.url_host,
                                                       tid=tid))
        try:
            res_dic = self.get_data(url=self.url_host + "/transfer.php",
                                    params={"url": transferred_url},
                                    json=True)
        except ValueError:
            Logger.error("Error,this torrent may not exist or ConnectError")
        else:
            res_dic.update({
                "transferred_url": transferred_url,
                "clone_id": tid
            })
            res_dic["descr"] = ubb_clean(res_dic["descr"])

            Logger.info(
                "Get clone torrent's info,id: {tid},title:\"{ti}\"".format(
                    tid=tid, ti=res_dic["name"]))
        return res_dic
示例#3
0
    def torrent_clone(self, tid) -> dict:
        """
        Get the raw information about the clone torrent's depend on given id,
        and sort it into a dict which can be converted to the post tuple.

        :param tid: int, The clone torrent's id in this site
        :return: dict, The information dict about this clone torrent
        """
        return_dict = {}
        details_bs = self.page_torrent_detail(tid=tid, bs=True)

        if re.search("没有该ID的种子", str(details_bs)):
            Logger.error("Error,this torrent may not exist or ConnectError")
        else:  # 解析原种页面
            return_dict["clone_id"] = tid  # 传入引用种子号
            return_dict["name"] = details_bs.find("h1", id="page-title").text  # 标题
            return_dict["small_descr"] = details_bs.find("dt", text="副标题").next_sibling.text  # 副标题

            imdb_another = details_bs.find("a", href=re.compile("http://www.imdb.com/title/tt"))
            return_dict["url"] = imdb_another.text if imdb_another else ""  # IMDb

            for key_dict, key_search in [("type", "cat"), ("standard_sel", "standard")]:  # 类型, 质量
                temp_reg = re.compile("torrents.php\?{}=(\d+)".format(key_search))
                temp_tag = details_bs.find("a", href=temp_reg)
                return_dict[key_dict] = re.search(temp_reg, temp_tag["href"]).group(1)

            # 简介
            descr_html = str((details_bs.select("div#kdescr > div.bbcode") or "")[0])
            descr_ubb = html2ubb(descr_html)
            return_dict["descr"] = ubb_clean(descr_ubb)

        return return_dict
示例#4
0
    def torrent_clone(self, tid) -> dict:
        """
        Get the raw information about the clone torrent's depend on given id,
        and sort it into a dict which can be converted to the post tuple.

        :param tid: int, The clone torrent's id in this site
        :return: dict, The information dict about this clone torrent
        """
        return_dict = {}
        details_bs = self.page_torrent_detail(tid=tid, bs=True)

        # 解析原种页面
        return_dict["name"] = details_bs.find("h1", id="page-title").text  # 标题
        return_dict["small_descr"] = details_bs.find(
            "dt", text="副标题").next_sibling.text  # 副标题
        return_dict["url"] = details_bs.find(
            "a",
            href=re.compile("http://www.imdb.com/title/tt")).text or ""  # IMDb

        for key_dict, key_search in [("type", "cat"),
                                     ("standard_sel", "standard")]:  # 类型, 质量
            temp_reg = re.compile("torrents.php\?{}=(\d+)".format(key_search))
            temp_tag = details_bs.find("a", href=temp_reg)
            return_dict[key_dict] = re.search(temp_reg,
                                              temp_tag["href"]).group(1)

        # 简介
        descr_html = str((details_bs.select("div#kdescr > div.bbcode")
                          or "")[0])
        descr_ubb = self._descr_html2ubb(descr_html)
        return_dict["descr"] = ubb_clean(descr_ubb)

        return return_dict
示例#5
0
    def torrent_clone(self, tid):
        """
        Use Internal API: - /upsimilartorrent.php?id={tid} ,Request Method: GET
                          - /catdetail_edittorrents.php?torid={id} ,Request Method: GET
        Will response two pages about this clone torrent's information,
        And this function will sort those pages to a pre-reseed dict.
        """
        res_dic = {}

        page_clone = self.get_data(url=self.url_host + "/upsimilartorrent.php",
                                   params={"id": tid},
                                   bs=True)

        if not re.search(r"<h2>错误!</h2>", str(page_clone)):
            Logger.info("Got clone torrent's info,id: {tid}".format(tid=tid))

            type_select = page_clone.find("select", id="oricat")
            type_value = type_select.find("option",
                                          selected="selected")["value"]
            raw_descr = ubb_clean(page_clone.find("textarea", id="descr").text)
            url = page_clone.find("input", attrs={"name": "url"})
            res_dic.update({
                "clone_id": tid,
                "type": type_value,
                "descr": raw_descr,
                "url": url["value"]
            })

            for name in ["source_sel", "team_sel"]:
                tag = page_clone.find("select", attrs={"name": name})
                tag_selected = tag.find("option", selected=True)
                res_dic.update({name: tag_selected["value"]})

            # Get torrent_info page and sort this page's information into the pre-reseed dict.
            catdetail_page = self.get_data(url=self.url_host +
                                           "/catdetail_edittorrents.php",
                                           params={"torid": tid},
                                           bs=True)

            for ask_tag_name in ask_dict[type_value]:
                value = ""
                if catdetail_page.find("input", attrs={"name": ask_tag_name}):
                    tag = catdetail_page.find("input",
                                              attrs={"name": ask_tag_name})
                    value = tag["value"]
                elif catdetail_page.find("select",
                                         attrs={"name": ask_tag_name}):
                    tag = catdetail_page.find("select",
                                              attrs={"name": ask_tag_name})
                    tag_selected = tag.find("option", selected=True)
                    if tag_selected:
                        value = tag_selected["value"]
                res_dic.update({ask_tag_name: value})

        return res_dic
示例#6
0
    def torrent_clone(self, tid) -> dict:
        """
        Use Internal API: http://pt.nwsuaf6.edu.cn/citetorrent.php?torrent_id={tid} ,Request Method: GET
        Will response a json dict.
        """
        res_dic = {}
        try:
            res_dic = self.get_data(url=self.url_host + "/citetorrent.php", params={"torrent_id": tid}, json=True)
        except ValueError:
            Logger.error("Error,this torrent may not exist or ConnectError")
        else:
            res_dic["clone_id"] = tid
            res_dic["descr"] = ubb_clean(res_dic["descr"])
            res_dic["type"] = res_dic["category"]

            Logger.info("Get clone torrent's info,id: {tid},title:\"{ti}\"".format(tid=tid, ti=res_dic["name"]))
        return res_dic
示例#7
0
    def torrent_clone(self, tid) -> dict:
        """
        Use Internal API: https://npupt.com/transfer.php?url={url} ,Request Method: GET
        The url use base64 encryption, and will response a json dict.
        """
        res_dic = {}
        transferred_url = string2base64("{host}/details.php?id={tid}&hit=1".format(host=self.url_host, tid=tid))
        try:
            res_dic = self.get_data(url=self.url_host + "/transfer.php", params={"url": transferred_url}, json=True)
        except ValueError:
            Logger.error("Error,this torrent may not exist or ConnectError")
        else:
            res_dic.update({"transferred_url": transferred_url, "clone_id": tid})
            res_dic["descr"] = ubb_clean(res_dic["descr"])

            Logger.info("Get clone torrent's info,id: {tid},title:\"{ti}\"".format(tid=tid, ti=res_dic["name"]))
        return res_dic
示例#8
0
    def torrent_clone(self, tid) -> dict:
        """
        Use Internal API: http://pt.nwsuaf6.edu.cn/citetorrent.php?torrent_id={tid} ,Request Method: GET
        Will response a json dict.
        """
        res_dic = {}
        try:
            res_dic = self.get_data(url=self.url_host + "/citetorrent.php", params={"torrent_id": tid}, json=True)
        except ValueError:
            Logger.error("Error,this torrent may not exist or ConnectError")
        else:
            res_dic["clone_id"] = tid
            res_dic["descr"] = ubb_clean(res_dic["descr"])
            res_dic["type"] = res_dic["category"]

            Logger.info("Get clone torrent's info,id: {tid},title:\"{ti}\"".format(tid=tid, ti=res_dic["name"]))
        return res_dic
示例#9
0
    def torrent_clone(self, tid):
        """
        Use Internal API: - /upsimilartorrent.php?id={tid} ,Request Method: GET
                          - /catdetail_edittorrents.php?torid={id} ,Request Method: GET
        Will response two pages about this clone torrent's information,
        And this function will sort those pages to a pre-reseed dict.
        """
        res_dic = {}

        page_clone = self.get_data(url=self.url_host + "/upsimilartorrent.php", params={"id": tid}, bs=True)

        if not re.search(r"<h2>错误!</h2>", str(page_clone)):
            Logger.info("Got clone torrent's info,id: {tid}".format(tid=tid))

            type_select = page_clone.find("select", id="oricat")
            type_value = type_select.find("option", selected="selected")["value"]
            raw_descr = ubb_clean(page_clone.find("textarea", id="descr").text)
            url = page_clone.find("input", attrs={"name": "url"})
            res_dic.update({"clone_id": tid, "type": type_value, "descr": raw_descr, "url": url["value"]})

            for name in ["source_sel", "team_sel"]:
                tag = page_clone.find("select", attrs={"name": name})
                tag_selected = tag.find("option", selected=True)
                res_dic.update({name: tag_selected["value"]})

            # Get torrent_info page and sort this page's information into the pre-reseed dict.
            catdetail_page = self.get_data(url=self.url_host + "/catdetail_edittorrents.php", params={"torid": tid},
                                           bs=True)

            for ask_tag_name in ask_dict[type_value]:
                value = ""
                if catdetail_page.find("input", attrs={"name": ask_tag_name}):
                    tag = catdetail_page.find("input", attrs={"name": ask_tag_name})
                    value = tag["value"]
                elif catdetail_page.find("select", attrs={"name": ask_tag_name}):
                    tag = catdetail_page.find("select", attrs={"name": ask_tag_name})
                    tag_selected = tag.find("option", selected=True)
                    if tag_selected:
                        value = tag_selected["value"]
                res_dic.update({ask_tag_name: value})

        return res_dic