在家封城已经快两个月了,硬盘已经满了。
早在2202年,迅雷就一直闹鬼,打发时间写了一本手工的班迅雷剧本。
借助WebUI提供的API,手动获取peer信息吸血莱恩下载,并按照一定的规则进行过滤。
from urllib import request, parse
import json
import time
#本地+端口
weburl = "http://127.0.0.1:22222/"
sync_maindata = "api/v2/sync/maindata"
sync_torrentPeers = "api/v2/sync/torrentPeers?hash="
transfer_banpeers = "api/v2/transfer/banPeers?peers="
while True:
req = request.Request(url = weburl + sync_maindata)
res = request.urlopen(req)
resjson = res.read()
metas = json.loads(resjson)
for v in metas['torrents']:
#print(v)
req = request.Request(url = weburl + sync_torrentPeers + v)
res = request.urlopen(req)
resjson = res.read()
peer = json.loads(resjson)
for p in peer['peers']:
b = 0
l = peer['peers'][p]
#吸血雷上报的进度永远是0,且大部分不上传
if not (l['progress'] > 0 and l['downloaded'] > 0):
if l['client'].find('XL') != -1:
print('Find Client: ' + l['client'])
b += 2
if l['client'].find('Xunlei') != -1:
print('Find Client: ' + l['client'])
b += 2
#if l['client'].find('7.') == 0:
# print('Find Client: ' + l['client'])
# b += 1
#可疑的端口
if l['port'] in [12345, 2011, 2013, 54321]:
print('Find Port: ' + str(l['port']))
b += 1
#默认端口是15000
if l['port'] in [15000]:
print('Find Port: ' + str(l['port']))
b += 2
#if l['port'] 1024 * 1024 * 16 and l['flags'].lower().find('u') != -1:
print("Find Progess | Uploaded: " + l['client'] + " " + str(l['progress']) + " | " + str(l['uploaded']))
b += 1
if l['progress'] == 0 and l['uploaded'] > 1024 * 1024 * 64 and l['flags'].lower().find('u') != -1:
print("Find Progess | Uploaded: " + l['client'] + " " + str(l['progress']) + " | " + str(l['uploaded']))
b += 2
#原来打算按分值判断的,但还是基本一刀切了
if b > 1:
req = request.Request(url=weburl + transfer_banpeers + p)
res = request.urlopen(req)
print(metas['torrents'][v]['name'])
print(time.asctime( time.localtime(time.time())) + " | Ban: " + l['ip'] + ":" + str(l['port']) + " Client: [" + l['client'] + "]")
elif b > 0:
print(metas['torrents'][v]['name'])
print(time.asctime( time.localtime(time.time())) + " | Find: " + l['ip'] + ":" + str(l['port']) + " Client: [" + l['client'] + "]")
#每5秒获取一次
time.sleep(5)
世界更安静
另外吸血莱恩下载,我发现经常有整个IP段的peer,怀疑是哪些离线下载,等模具快长大的时候再做。