神秘代码直链下载API

2020年03月1日

转自:https://www.hostloc.com/thread-642335-1-1.html

1.解析磁力.
https://bt.i0x0.cn/?hash=40位磁力链
如:https://bt.i0x0.cn/?hash=3BE5C938BCB4B541446C60C0E369E9060D5E82D2

返回以下数据

{
    "code": 0,
    "msg": "成功",
    "data": [
        {
            "file_key": "BA7B0FE821E08052634E6FA6B73238C22C02B201D155B8C1E9F2AD42A63175FC2E623D60E7372683EE3C274B3125A3758FAAFF3A8B0F999004EC7BFAE548F15E27BADB38877768CE8849B6E8547E0322D57889384C1E66",
            "name": "1.jpg",
            "size": "155.58KB",
            "ico": ""
        },
        {
            "file_key": "C6080FE924E1FE54644B6FA5B5323AC52B03B271D152B8C4EC80AD40A632098029173A67E7422789943F204D3424A3018FAFFF4E8B79E79301EF07FCE53EF65E27BADB4280766DBB8849B69E547D0420D5788A31471669A0E0FB06",
            "name": "十面埋伏[bbs.3e-online.com][1280高清].rmvb",
            "size": "1.50GB",
            "ico": ""
        }
    ],
}

 

2.获取直链.
https://bt.i0x0.cn/?key=解析处理的file_key值
如:https://bt.i0x0.cn/?key=C6080FE924E1FE54644B6FA5B5323AC52B03B271D152B8C4EC80AD40A632098029173A67E7422789943F204D3424A3018FAFFF4E8B79E79301EF07FCE53EF65E27BADB4280766DBB8849B69E547D0420D5788A31471669A0E0FB06

返回以下数据

{
    "code": 0,
    "data": {
        "download_url": "https://cd-ctfs.ftn.qq.com/ftn_handler/771cd0950ccf68289318f82e091e3a833a18dbf6c224c23109b626076bc088f7c3c4e86364436bcd4c28954e2ec002cdb079b3ba4a0f28a8509e0be9642f4269",
        "download_cookie": "FTN5K=74c8875c"
    },
    "msg": "下载重命名:只需要在链接后面添加- /testName.mp4(后缀名称请根据实际文件后缀填写),如:https://**-***.ftn.qq.com/ftn_handler/cc1fe46baf99c7409****************/testName.mp4"
}

 

直接复制 download_url的值就可以下载了.IDM或者浏览器都可以.名字乱码就在链接后面/testName.mp4加一下就行.

网友更新的脚本,只支持python3,执行粘贴种子的hash码就行了

多线程

import json
import time
import pyperclip
import requests
import threading
from queue import Queue


def get_download_url(file_key, file_name, file_size):
    print(f"成功获取到文件名: {file_name} 的file_key! \n文件大小: {file_size}\n")

    download_url_in_json = requests.get(file_key, proxies=proxies)
    download_url_in_json = json.loads(download_url_in_json.text)
    if download_url_in_json["code"] == 1:
        print("无法获取下载链接! 返回中...")
        return ""
    else:
        download_url = download_url_in_json["data"]["download_url"]
        download_url_with_name = download_url + "/" + file_name
        return download_url_with_name


def return_download_url(result_data):
    global url
    while not qurl.empty():
        index = qurl.get()
        file_key = analyze_download_url + result_data[index]["file_key"]
        file_name = result_data[index]["name"]
        file_size = result_data[index]["size"]
        file_download_url = get_download_url(file_key, file_name, file_size)

        if "" != file_download_url:
            lock.acquire()
            url = url + file_download_url + "\r"
            lock.release()


def get_file_key(hash_key):
    hash_url = torrent_hash + hash_key
    analyze_result = requests.get(hash_url)
    analyze_result = json.loads(analyze_result.text)
    if analyze_result["code"] == 1:
        print("该hash无法解析! 返回中...")
        return None
    else:
        if len(analyze_result["data"]) >= 1:
            for i in range(len(analyze_result["data"])):
                print(str(i) + ": " + analyze_result["data"][i]["size"] + ": " + analyze_result["data"][i]["name"])
            try:
                index = int(input("\n\n请输入文件前面的序列号,如果需要下载全部文件,请直接回车: "))
                if index > len(analyze_result["data"]):
                    print("\n你输入了错误的序号!")
                    return None
                qurl.put(index)
            except ValueError:
                print("\n您选择下载全部文件, 开始获取下载链接\n")
                for x in range(len(analyze_result["data"])):
                    qurl.put(x)
            finally:
                ths = list([])
                for _ in range(thread_num):
                    th = threading.Thread(target=return_download_url, args=(analyze_result["data"],))  
                    th.start()
                    ths.append(th)
                for th in ths:
                    th.join()
                return url


proxies = None
thread_num = 8  # 指定线程数量,如果设置的过高会获取不到下载链接
analyze_download_url = "https://bt.i0x0.cn/?key="  # 后面加上上面返回的file_key
torrent_hash = "https://bt.i0x0.cn/?hash="  # 后面加上hash值
qurl = Queue()
lock = threading.Lock()
url = ""
if __name__ == '__main__':
    key = input("请输入种子的hash值: ")
    result = get_file_key(key)
    if result:
        pyperclip.copy(result)
        print("成功将下载链接复制到粘贴板! 去下载吧")
    time.sleep(2)

 

单线程

import json
import time
import pyperclip
import requests


def return_download_url(result_data, index):
    analyze_download_url = "https://bt.i0x0.cn/?key="  # 后面加上上面返回的file_key
    url = str()
    if -1 == index:  # 全部文件
        for file in result_data:
            file_key = analyze_download_url + file["file_key"]
            file_name = file["name"]
            file_size = file["size"]
            url = url + get_download_url(file_key, file_name, file_size) + "\r"
    else:
        file_key = analyze_download_url + result_data[index]["file_key"]
        file_name = result_data[index]["name"]
        file_size = result_data[index]["size"]
        url = get_download_url(file_key, file_name, file_size)

    return url


def get_download_url(file_key, file_name, file_size):
    print(f"成功获取到file_key! \n文件名: {file_name} \n文件大小: {file_size}\n")

    download_url_in_json = requests.get(file_key, proxies=proxies)
    download_url_in_json = json.loads(download_url_in_json.text)
    if download_url_in_json["code"] == 1:
        print("无法获取下载链接! 返回中...")
        return ""
    else:
        download_url = download_url_in_json["data"]["download_url"]
        download_url_with_name = download_url + "/" + file_name
        return download_url_with_name


def get_file_key(hash_key):
    torrent_hash = "https://bt.i0x0.cn/?hash="  # 后面加上hash值

    hash_url = torrent_hash + hash_key
    analyze_result = requests.get(hash_url)
    analyze_result = json.loads(analyze_result.text)
    if analyze_result["code"] == 1:
        print("该hash无法解析! 返回中...")
        return None
    else:
        index = 0
        if len(analyze_result["data"]) >= 1:
            for i in range(len(analyze_result["data"])):
                print(str(i) + ": " + analyze_result["data"][i]["size"] + ": " + analyze_result["data"][i]["name"])
            try:
                index = int(input("\n\n请输入文件前面的序列号,如果需要下载全部文件,请直接回车: "))
                if index > len(analyze_result["data"]):
                    print("你输入了错误的序号!")
                    return None
            except:
                print("您选择下载全部文件, 开始获取下载链接\n")
                index = -1
            finally:
                return return_download_url(analyze_result["data"], index)


proxies = None
open_thread = False
if __name__ == '__main__':
    key = input("请输入种子的hash值: ")
    result = get_file_key(key)
    if result:
        pyperclip.copy(result)
        print("成功将下载链接复制到粘贴板! 去下载吧")
    time.sleep(2)

 


sicnature ---------------------------------------------------------------------
I P 地 址: 18.97.14.84
区 域 位 置: 美国马萨诸塞
系 统 信 息: 美国
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source http://myzhenai.com/post/3153.html

没有评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注