diff --git a/README.md b/README.md
index b454a2f..0082c83 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
Bilibili-Toolkit
-
+
@@ -15,7 +15,7 @@
|组件 |版本 |描述 |
|--------------------|---------------|------------------------------|
-|login |2018/8/10 |登录 |
+|login |2018/8/26 |登录 |
|query |2018/6/20 |获取用户信息 |
|setPrivacy |2018/7/24 |修改隐私设置 |
|silver2Coins |2018/8/8 |银瓜子兑换硬币 |
@@ -26,7 +26,7 @@
|share |2018/6/20 |分享 |
|follow |2018/7/8 |关注 |
|commentLike |2018/6/27 |评论点赞 |
-|commentRush |2018/6/29 |评论抢楼 |
+|commentPost |2018/8/26 |评论发表 |
|dynamicLike |2018/6/29 |动态点赞 |
|dynamicRepost |2018/6/29 |动态转发 |
|mallRush |2018/7/19 |会员购抢购 |
@@ -34,9 +34,9 @@
|mallLottery |2018/6/23 |会员购周年庆活动抽奖 |
|mallPrize |2018/6/23 |会员购周年庆活动中奖查询 |
|mi6XLottery |2018/6/30 |小米6X抢F码活动抽奖 |
-|liveTool |2018/8/9 |直播助手 |
+|liveTool |2018/8/25 |直播助手 |
-*注:liveTool组件编译自[yjqiang/bili2.0](https://github.com/yjqiang/bili2.0)*
+*注:liveTool直播助手组件编译自[yjqiang/bili2.0](https://github.com/yjqiang/bili2.0)*
## 使用指南
diff --git a/bilibili.py b/bilibili.py
index 26316ce..64e1b86 100644
--- a/bilibili.py
+++ b/bilibili.py
@@ -185,41 +185,44 @@ def usePassword():
headers = {'Content-type': "application/x-www-form-urlencoded"}
response = self.post(url, data=data, headers=headers)
if response:
- while response.get("code") == -105:
- self.cookie = f"sid={''.join(random.choices(string.ascii_lowercase + string.digits, k=8))}"
- url = "https://passport.bilibili.com/captcha"
- headers = {'Cookie': self.cookie,
- 'Host': "passport.bilibili.com",
- 'User-Agent': Bilibili.ua}
- response = self.get(url, headers=headers, decodeLevel=1)
- if response is None:
- self.log("验证码获取失败")
- continue
- url = "http://47.95.255.188:5000/code"
- data = {'image': base64.b64encode(response)}
- response = self.post(url, data=data, decodeLevel=1, timeout=30)
- if response is None:
- self.log("验证码识别失败")
- continue
- captcha = response.decode()
- self.log(f"验证码识别结果为: {captcha}")
- url = "https://passport.bilibili.com/api/v2/oauth2/login"
- param = f"appkey={Bilibili.appKey}&captcha={captcha}&password={parse.quote_plus(base64.b64encode(rsa.encrypt(f'{keyHash}{self.password}'.encode(), pubKey)))}&username={parse.quote_plus(self.username)}"
- data = f"{param}&sign={self.getSign(param)}"
- headers = {'Content-type': "application/x-www-form-urlencoded",
- 'Cookie': self.cookie}
- response = self.post(url, data=data, headers=headers)
- if response.get("code") == 0:
- self.cookie = "".join(f"{i['name']}={i['value']};" for i in response['data']['cookie_info']['cookies'])
- self.csrf = response['data']['cookie_info']['cookies'][0]['value']
- self.uid = response['data']['cookie_info']['cookies'][1]['value']
- self.accessToken = response['data']['token_info']['access_token']
- self.refreshToken = response['data']['token_info']['refresh_token']
- self.log(f"{self.username}登录成功")
- return True
- else:
- self.log(f"{self.username}登录失败 {response}")
- return False
+ while True:
+ if response["code"] == -105:
+ self.cookie = f"sid={''.join(random.choices(string.ascii_lowercase + string.digits, k=8))}"
+ url = "https://passport.bilibili.com/captcha"
+ headers = {'Cookie': self.cookie,
+ 'Host': "passport.bilibili.com",
+ 'User-Agent': Bilibili.ua}
+ response = self.get(url, headers=headers, decodeLevel=1)
+ url = "http://47.95.255.188:5000/code"
+ data = {'image': base64.b64encode(response)}
+ response = self.post(url, data=data, decodeLevel=1, timeout=15)
+ captcha = response.decode() if response and len(response) == 5 else None
+ if captcha:
+ self.log(f"验证码识别结果为: {captcha}")
+ url = "https://passport.bilibili.com/api/v2/oauth2/login"
+ param = f"appkey={Bilibili.appKey}&captcha={captcha}&password={parse.quote_plus(base64.b64encode(rsa.encrypt(f'{keyHash}{self.password}'.encode(), pubKey)))}&username={parse.quote_plus(self.username)}"
+ data = f"{param}&sign={self.getSign(param)}"
+ headers = {'Content-type': "application/x-www-form-urlencoded",
+ 'Cookie': self.cookie}
+ response = self.post(url, data=data, headers=headers)
+ else:
+ self.log(f"验证码识别服务暂时不可用, {'尝试更换代理' if self.proxy else '30秒后重试'}")
+ if self.proxy:
+ self.setProxy()
+ else:
+ time.sleep(30)
+ break
+ elif response["code"] == 0:
+ self.cookie = "".join(f"{i['name']}={i['value']};" for i in response['data']['cookie_info']['cookies'])
+ self.csrf = response['data']['cookie_info']['cookies'][0]['value']
+ self.uid = response['data']['cookie_info']['cookies'][1]['value']
+ self.accessToken = response['data']['token_info']['access_token']
+ self.refreshToken = response['data']['token_info']['refresh_token']
+ self.log(f"{self.username}登录成功")
+ return True
+ else:
+ self.log(f"{self.username}登录失败 {response}")
+ return False
else:
if not freeze:
self.log("当前IP登录过于频繁, 进入冷却模式")
@@ -332,7 +335,7 @@ def setPrivacy(self, showFavourite=None, showBangumi=None, showTag=None, showRew
return False
# 银瓜子兑换硬币
- def silver2Coins(self, app=True, pc=True):
+ def silver2Coins(self, app=True, pc=False):
# app = APP通道
# pc = PC通道
if app:
@@ -413,7 +416,7 @@ def like(self, aid):
return False
# 投币
- def reward(self, aid, double):
+ def reward(self, aid, double=True):
# aid = 稿件av号
# double = 双倍投币
url = "https://api.bilibili.com/x/web-interface/coin/add"
@@ -487,7 +490,7 @@ def share(self, aid):
return False
# 关注
- def follow(self, mid, secret):
+ def follow(self, mid, secret=False):
# mid = 被关注用户UID
# secret = 悄悄关注
url = "https://api.bilibili.com/x/relation/modify"
@@ -546,12 +549,13 @@ def commentLike(self, otype, oid, rpid):
self.log(f"评论{rpid}点赞失败 {response}")
return False
- # 评论抢楼
- def commentRush(self, otype, oid, floor, message):
+ # 评论发表
+ def commentPost(self, otype, oid, message, floor=0, critical=1):
# otype = 作品类型
# oid = 作品ID
- # floor = 抢楼楼层
# message = 评论内容
+ # floor = 目标楼层
+ # critical = 临界范围
patterns = {'video': {'id': 1,
'prefix': "https://www.bilibili.com/video/av"},
'activity': {'id': 4,
@@ -560,7 +564,6 @@ def commentRush(self, otype, oid, floor, message):
'prefix': "https://h.bilibili.com/"},
'article': {'id': 12,
'prefix': "https://www.bilibili.com/read/cv"}}
- critical = 3
if patterns.get(otype) is None:
self.log("不支持的作品类型")
return False
@@ -572,12 +575,12 @@ def commentRush(self, otype, oid, floor, message):
response = self.get(url, headers=headers)
if response and response.get("code") == 0:
currentFloor = response['data']['replies'][0]['floor']
- deltaFloor = floor - currentFloor
- if deltaFloor > critical:
+ deltaFloor = floor - currentFloor if floor else 1
+ if deltaFloor > max(1, critical):
self.log(f"当前评论楼层数为{currentFloor}, 距离目标楼层还有{deltaFloor}层")
time.sleep(min(3, max(0, (deltaFloor - 10) * 0.1)))
elif deltaFloor > 0:
- self.log(f"当前评论楼层数为{currentFloor}, 开始抢楼")
+ self.log(f"当前评论楼层数为{currentFloor}, 开始提交评论")
url = "https://api.bilibili.com/x/v2/reply/add"
data = {'oid': oid,
'type': patterns[otype]['id'],
@@ -592,16 +595,15 @@ def commentRush(self, otype, oid, floor, message):
'Referer': f"{patterns[otype]['prefix']}{oid}",
'User-Agent': Bilibili.ua}
success = 0
- while True:
+ while success < deltaFloor:
response = self.post(url, data=data, headers=headers)
if response and response.get("code") == 0:
success += 1
self.log(f"评论({success}/{deltaFloor})提交成功")
else:
self.log(f"评论({success}/{deltaFloor})提交失败 {response}")
- if success >= deltaFloor:
- self.log("停止抢楼")
- break
+ if not floor:
+ break
else:
self.log(f"当前评论楼层数为{currentFloor}, 目标楼层已过")
break
@@ -915,11 +917,11 @@ def wrapper(arg):
addInterval = lambda func, delay: time.sleep(delay)
config, account = arg['config'], arg['account']
instance = Bilibili()
+ if config['proxy']['enable']:
+ instance.addProxy(config['proxy']['pool'])
+ instance.setProxy()
instance.importCredential(account)
if instance.login():
- if config['proxy']['enable']:
- instance.addProxy(config['proxy']['pool'])
- instance.setProxy()
threads = []
if config['query']['enable']:
threads.append(threading.Thread(target=instance.query))
@@ -941,9 +943,9 @@ def wrapper(arg):
threads.append(threading.Thread(target=lambda: [addInterval(instance.follow(mid, secret), 1) for mid, secret in zip(config['follow']['mid'], config['follow']['secret'])]))
if config['commentLike']['enable']:
threads.append(threading.Thread(target=lambda: [addInterval(instance.commentLike(otype, oid, rpid), 1) for otype, oid, rpid in zip(config['commentLike']['otype'], config['commentLike']['oid'], config['commentLike']['rpid'])]))
- if config['commentRush']['enable']:
- for comment in zip(config['commentRush']['otype'], config['commentRush']['oid'], config['commentRush']['floor'], config['commentRush']['message']):
- threads.append(threading.Thread(target=instance.commentRush, args=(comment[0], comment[1], comment[2], comment[3])))
+ if config['commentPost']['enable']:
+ for comment in zip(config['commentPost']['otype'], config['commentPost']['oid'], config['commentPost']['message'], config['commentPost']['floor'], config['commentPost']['critical']):
+ threads.append(threading.Thread(target=instance.commentPost, args=(comment[0], comment[1], comment[2], comment[3], comment[4])))
if config['dynamicLike']['enable']:
threads.append(threading.Thread(target=lambda: [addInterval(instance.dynamicLike(did), 1) for did in config['dynamicLike']['did']]))
if config['dynamicRepost']['enable']:
@@ -1048,7 +1050,7 @@ def main():
LiveToolCurrentCommit = f.read()
except:
LiveToolCurrentCommit = None
- liveToolLatestCommit = LiveToolCurrentCommit if LiveToolCurrentCommit else "e4d6c87"
+ liveToolLatestCommit = LiveToolCurrentCommit if LiveToolCurrentCommit else "77c4c85"
if config['liveTool']['autoUpdate']:
try:
liveToolLatestCommit = requests.get("https://api.github.com/repos/Hsury/Bilibili-Live-Tool/releases/latest").json()["tag_name"]
diff --git a/bilibili.toml b/bilibili.toml
index 5c6643b..d6ff92c 100644
--- a/bilibili.toml
+++ b/bilibili.toml
@@ -13,7 +13,7 @@ account = """
# 代理设置
[proxy]
enable = true # 开关
-pool = ["119.27.177.169:80", "113.207.44.70:3128", "113.200.56.13:8010", "180.101.146.174:3128", "221.7.255.167:8080", "221.7.255.167:80", "221.7.255.168:8080", "221.7.255.168:80", "111.47.192.141:8888", "39.135.35.19:80", "180.101.205.253:8888","39.135.35.18:80", "119.28.194.66:8888", "140.143.96.216:80", "39.106.160.36:3128", "116.62.194.248:3128", "114.215.95.188:3128", "219.142.69.246:8000", "123.59.206.208:8080", "218.60.8.83:3129", "121.43.170.207:3128", "218.207.212.86:80","121.31.192.138:8123", "111.155.116.208:8123", "115.231.254.116:80", "124.235.208.252:443", "125.62.26.197:3128", "119.28.142.148:8888", "124.193.37.5:8888", "1.71.188.37:3128", "218.54.201.168:80", "35.200.24.26:3128", "180.183.43.241:8080", "43.239.178.78:8888", "101.37.79.125:3128", "124.105.29.184:3128", "94.242.58.14:10010", "121.42.167.160:3128", "45.195.201.235:3128", "116.93.124.175:8080", "167.99.242.198:8080", "5.128.60.74:3128", "153.222.84.148:3128", "185.22.174.69:10010", "213.32.61.247:3128", "104.214.51.230:8080", "159.28.206.194:8080", "37.59.79.10:3128", "37.187.99.146:3128", "178.33.194.169:3128", "94.242.58.108:10010", "206.125.41.135:80", "94.242.58.142:10010", "78.194.96.9:3128", "121.156.109.92:8080", "91.121.108.164:3128", "37.187.121.205:3128", "185.216.35.170:3128", "217.112.143.65:3128", "167.99.187.164:8080", "37.187.110.165:8080", "173.212.219.151:3128", "94.242.59.245:10010", "178.128.39.212:8080", "221.228.17.172:8181", "5.196.224.39:8080", "46.101.235.97:8080", "83.146.67.32:8080", "185.230.157.12:3128", "46.21.72.68:8080", "94.244.41.41:8080", "206.189.189.126:8080", "206.189.210.240:3128", "159.89.0.95:80", "204.48.18.186:80", "178.128.249.72:80", "159.69.31.142:3128", "1.179.182.110:8088", "178.128.47.113:8080", "118.190.210.227:3128", "60.255.186.169:8888", "194.190.114.57:8080", "194.67.201.106:3128", "46.227.162.167:8080", "144.217.133.47:80", "46.4.162.119:3128", "172.246.241.60:3128", "190.85.82.90:3128", "109.197.188.9:8080", "178.128.40.193:8080", "188.166.33.184:8080", "128.199.179.107:8080", "201.116.199.243:3128", "178.88.99.236:8085", "93.190.57.153:8080", "81.5.119.157:9001", "83.175.166.234:9001", "176.120.212.168:41258", "167.99.214.181:8080", "202.29.238.161:3128"] # 代理池
+pool = ["211.95.2.37:3128", "39.106.160.36:3128", "120.78.215.151:808", "218.60.8.83:3129", "202.116.64.201:80", "123.56.151.10:9999", "154.8.182.226:3128", "112.126.65.236:80", "121.14.64.63:8080", "123.207.30.131:80", "221.204.48.167:3128", "58.240.172.110:3128", "121.14.64.143:8080", "118.31.223.194:3128", "119.27.177.169:80", "116.62.194.248:3128", "223.93.172.248:3128", "140.143.96.216:80", "221.219.147.182:3128", "14.116.179.185:3128", "183.62.22.220:3128", "123.56.169.22:3128", "113.200.56.13:8010", "218.60.8.99:3129", "183.62.196.10:3128", "218.60.8.98:3129", "101.236.41.207:3128", "125.62.26.197:3128", "150.109.37.122:3128", "39.104.175.142:3128", "183.2.212.2:3128", "54.234.23.77:3128", "206.189.204.62:8080", "218.207.212.86:80", "142.93.68.156:80", "142.93.204.190:8080", "159.203.58.149:8080", "45.77.168.217:80", "209.97.171.126:8080", "89.36.222.247:80", "159.89.118.85:8080", "178.128.104.199:8080", "199.119.1.132:80", "204.48.31.200:8080", "207.154.208.76:8080", "181.143.73.34:53281", "178.128.39.212:8080", "167.114.188.3:80", "218.60.58.66:80", "217.182.119.131:3128", "159.28.206.223:8080", "35.202.230.186:3128", "173.212.192.72:3128", "178.128.247.187:8080", "89.207.92.165:8080", "167.114.23.202:80", "5.228.244.36:21231", "157.65.167.40:3128", "195.13.190.64:21231", "178.128.37.162:8080", "80.211.154.220:8888", "190.85.82.91:3128", "206.189.86.49:3128", "51.15.13.86:8080", "206.189.144.21:8080", "190.120.24.9:53281", "200.233.136.177:20183", "51.15.218.114:3128", "91.203.88.42:8080", "139.129.207.72:808", "178.128.87.55:8080", "192.244.99.187:3129", "176.37.33.100:21213", "195.138.90.242:21213", "61.7.167.53:81", "185.22.174.69:10010", "66.70.147.196:3128", "194.44.12.55:8080", "203.86.26.9:3128", "84.17.1.107:21213", "181.129.41.60:8080", "122.116.130.208:8123", "185.93.3.123:8080", "200.122.209.78:8080", "149.3.91.202:3128", "94.242.58.14:10010", "202.137.25.8:8080", "123.249.88.153:9000", "37.187.121.205:3128", "37.187.110.165:8080", "66.235.8.178:3128", "185.42.231.186:3128", "91.219.253.115:21231", "209.97.171.128:8080", "200.105.209.250:8080", "95.86.57.82:2016", "177.21.221.132:20183", "201.249.199.198:3128", "93.118.243.19:8080", "46.16.225.76:41258"] # 代理池
# 获取用户信息
[query]
@@ -36,28 +36,28 @@ enable = true # 开关
# 观看
[watch]
enable = true # 开关
-aid = [20032006, 14594803, 14361946] # 稿件av号
+aid = [29278585, 20032006, 14594803] # 稿件av号
# 好评
[like]
enable = true # 开关
-aid = [20032006, 14594803, 14361946] # 稿件av号
+aid = [29278585, 20032006, 14594803] # 稿件av号
# 投币
[reward]
enable = true # 开关
-aid = [20032006, 14594803, 14361946] # 稿件av号
+aid = [29278585, 20032006, 14594803] # 稿件av号
double = [true, true, true] # 双倍投币
# 收藏
[favour]
enable = true # 开关
-aid = [20032006, 14594803, 14361946] # 稿件av号
+aid = [29278585, 20032006, 14594803] # 稿件av号
# 分享
[share]
-enable = false # 开关
-aid = [20032006, 14594803, 14361946] # 稿件av号
+enable = true # 开关
+aid = [29278585, 20032006, 14594803] # 稿件av号
# 关注
[follow]
@@ -72,24 +72,25 @@ otype = ["article"] # 作品类型(视频video; 活动activity; 相簿gallery;
oid = [617468] # 作品ID
rpid = [864171896] # 评论ID
-# 评论抢楼
-[commentRush]
+# 评论发表
+[commentPost]
enable = false # 开关
otype = ["video"] # 作品类型(视频video; 活动activity; 相簿gallery; 文章article)
oid = [25581792] # 作品ID
-floor = [2233] # 抢楼楼层
message = ["哔哩哔哩 (゜-゜)つロ 干杯~"] # 评论内容
+floor = [0] # 目标楼层(为0则直接发表一条评论)
+critical = [3] # 临界范围
# 动态点赞
[dynamicLike]
enable = false # 开关
-did = [134705258328201427] # 动态ID
+did = [155455735691418008] # 动态ID
# 动态转发
[dynamicRepost]
enable = false # 开关
-did = [134705258328201427] # 动态ID
-message = ["哔哩哔哩 (゜-゜)つロ 干杯~"] # 转发内容
+did = [155455735691418008] # 动态ID
+message = ["转发动态"] # 转发内容
# 会员购抢购
[mallRush]