mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-30 04:00:31 +08:00
👽️ 修复因为米游社API变动导致的开始获取米游币
失败
This commit is contained in:
parent
c8035ddbd2
commit
0683a4240f
@ -518,19 +518,22 @@ def old_version_get_ds_token(mysbbs=False):
|
||||
if mysbbs:
|
||||
n = 'dWCcD2FsOUXEstC5f9xubswZxEeoBOTc'
|
||||
else:
|
||||
n = 'h8w582wxwgqvahcdkpvdhbh2w9casgfl'
|
||||
n = 'z8DRIUjNDT7IT5IZXvrUAxyupA1peND9'
|
||||
i = str(int(time.time()))
|
||||
r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6))
|
||||
c = md5('salt=' + n + '&t=' + i + '&r=' + r)
|
||||
return i + ',' + r + ',' + c
|
||||
|
||||
|
||||
def get_ds_token(q='', b=None):
|
||||
def get_ds_token(q='', b=None, salt=None):
|
||||
if b:
|
||||
br = json.dumps(b)
|
||||
else:
|
||||
br = ''
|
||||
s = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
|
||||
if salt:
|
||||
s = salt
|
||||
else:
|
||||
s = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
|
||||
t = str(int(time.time()))
|
||||
r = str(random.randint(100000, 200000))
|
||||
c = md5('salt=' + s + '&t=' + t + '&r=' + r + '&b=' + br + '&q=' + q)
|
||||
|
@ -1,55 +1,43 @@
|
||||
import time
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
from copy import deepcopy
|
||||
|
||||
from httpx import AsyncClient
|
||||
from nonebot import logger
|
||||
|
||||
from get_data import old_version_get_ds_token, random_hex
|
||||
from httpx import AsyncClient
|
||||
from get_data import random_hex, get_ds_token, old_version_get_ds_token
|
||||
|
||||
# 米游社的API列表
|
||||
bbs_Cookieurl = 'https://webapi.account.mihoyo.com/Api/cookie_accountinfo_by_loginticket?login_ticket={}'
|
||||
bbs_Cookieurl2 = 'https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?' \
|
||||
'login_ticket={}&token_types=3&uid={}'
|
||||
bbs_Cookieurl2 = (
|
||||
'https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?'
|
||||
'login_ticket={}&token_types=3&uid={}'
|
||||
)
|
||||
bbs_Taskslist = 'https://bbs-api.mihoyo.com/apihub/sapi/getUserMissionsState' # 获取任务列表
|
||||
bbs_Signurl = 'https://bbs-api.mihoyo.com/apihub/sapi/signIn?gids={}' # post
|
||||
bbs_Listurl = 'https://bbs-api.mihoyo.com/post/api/getForumPostList?' \
|
||||
'forum_id={}&is_good=false&is_hot=false&page_size=20&sort_type=1'
|
||||
bbs_Signurl = 'https://bbs-api.mihoyo.com/apihub/app/api/signIn' # post
|
||||
bbs_Listurl = (
|
||||
'https://bbs-api.mihoyo.com/post/api/getForumPostList?'
|
||||
'forum_id={}&is_good=false&is_hot=false&page_size=20&sort_type=1'
|
||||
)
|
||||
bbs_Detailurl = 'https://bbs-api.mihoyo.com/post/api/getPostFull?post_id={}'
|
||||
bbs_Shareurl = 'https://bbs-api.mihoyo.com/apihub/api/getShareConf?entity_id={}&entity_type=1'
|
||||
bbs_Likeurl = 'https://bbs-api.mihoyo.com/apihub/sapi/upvotePost' # post json
|
||||
bbs_Shareurl = (
|
||||
'https://bbs-api.mihoyo.com/apihub/api/getShareConf?entity_id={}&entity_type=1'
|
||||
)
|
||||
bbs_Likeurl = 'https://bbs-api.mihoyo.com/apihub/sapi/upvotePost' # post json
|
||||
|
||||
mihoyobbs_List = [{
|
||||
'id' : '1',
|
||||
'forumId': '1',
|
||||
'name' : '崩坏3',
|
||||
'url' : 'https://bbs.mihoyo.com/bh3/'
|
||||
}, {
|
||||
'id' : '2',
|
||||
'forumId': '26',
|
||||
'name' : '原神',
|
||||
'url' : 'https://bbs.mihoyo.com/ys/'
|
||||
}, {
|
||||
'id' : '3',
|
||||
'forumId': '30',
|
||||
'name' : '崩坏2',
|
||||
'url' : 'https://bbs.mihoyo.com/bh2/'
|
||||
}, {
|
||||
'id' : '4',
|
||||
'forumId': '37',
|
||||
'name' : '未定事件簿',
|
||||
'url' : 'https://bbs.mihoyo.com/wd/'
|
||||
}, {
|
||||
'id' : '5',
|
||||
'forumId': '34',
|
||||
'name' : '大别野',
|
||||
'url' : 'https://bbs.mihoyo.com/dby/'
|
||||
}, {
|
||||
'id' : '6',
|
||||
'forumId': '52',
|
||||
'name' : '崩坏:星穹铁道',
|
||||
'url' : 'https://bbs.mihoyo.com/sr/'
|
||||
}]
|
||||
mihoyobbs_List = [
|
||||
{'id': '1', 'forumId': '1', 'name': '崩坏3', 'url': 'https://bbs.mihoyo.com/bh3/'},
|
||||
{'id': '2', 'forumId': '26', 'name': '原神', 'url': 'https://bbs.mihoyo.com/ys/'},
|
||||
{'id': '3', 'forumId': '30', 'name': '崩坏2', 'url': 'https://bbs.mihoyo.com/bh2/'},
|
||||
{'id': '4', 'forumId': '37', 'name': '未定事件簿', 'url': 'https://bbs.mihoyo.com/wd/'},
|
||||
{'id': '5', 'forumId': '34', 'name': '大别野', 'url': 'https://bbs.mihoyo.com/dby/'},
|
||||
{
|
||||
'id': '6',
|
||||
'forumId': '52',
|
||||
'name': '崩坏:星穹铁道',
|
||||
'url': 'https://bbs.mihoyo.com/sr/',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def random_text(num: int) -> str:
|
||||
@ -60,26 +48,26 @@ class MihoyoBBSCoin:
|
||||
def __init__(self, cookies):
|
||||
self.postsList = None
|
||||
self.headers = {
|
||||
'DS' : old_version_get_ds_token(True),
|
||||
'cookie' : cookies,
|
||||
'x-rpc-client_type' : '2',
|
||||
'x-rpc-app_version' : '2.28.1',
|
||||
'x-rpc-sys_version' : '6.0.1',
|
||||
'x-rpc-channel' : 'mihoyo',
|
||||
'x-rpc-device_id' : random_hex(32),
|
||||
'x-rpc-device_name' : random_text(random.randint(1, 10)),
|
||||
'DS': old_version_get_ds_token(),
|
||||
'cookie': cookies,
|
||||
'x-rpc-client_type': '2',
|
||||
'x-rpc-app_version': '2.34.1',
|
||||
'x-rpc-sys_version': '6.0.1',
|
||||
'x-rpc-channel': 'miyousheluodi',
|
||||
'x-rpc-device_id': random_hex(32),
|
||||
'x-rpc-device_name': random_text(random.randint(1, 10)),
|
||||
'x-rpc-device_model': 'Mi 10',
|
||||
'Referer' : 'https://app.mihoyo.com',
|
||||
'Host' : 'bbs-api.mihoyo.com',
|
||||
'User-Agent' : 'okhttp/4.8.0'
|
||||
'Referer': 'https://app.mihoyo.com',
|
||||
'Host': 'bbs-api.mihoyo.com',
|
||||
'User-Agent': 'okhttp/4.8.0',
|
||||
}
|
||||
self.Task_do = {
|
||||
'bbs_Sign' : False,
|
||||
'bbs_Read_posts' : False,
|
||||
'bbs_Sign': False,
|
||||
'bbs_Read_posts': False,
|
||||
'bbs_Read_posts_num': 3,
|
||||
'bbs_Like_posts' : False,
|
||||
'bbs_Like_posts': False,
|
||||
'bbs_Like_posts_num': 5,
|
||||
'bbs_Share' : False
|
||||
'bbs_Share': False,
|
||||
}
|
||||
self.mihoyobbs_List_Use = []
|
||||
self.Today_getcoins = 0
|
||||
@ -139,13 +127,17 @@ class MihoyoBBSCoin:
|
||||
if i['is_get_award']:
|
||||
self.Task_do['bbs_Read_posts'] = True
|
||||
else:
|
||||
self.Task_do['bbs_Read_posts_num'] -= i['happened_times']
|
||||
self.Task_do['bbs_Read_posts_num'] -= i[
|
||||
'happened_times'
|
||||
]
|
||||
# 60是给帖子点赞
|
||||
elif i['mission_id'] == 60:
|
||||
if i['is_get_award']:
|
||||
self.Task_do['bbs_Like_posts'] = True
|
||||
else:
|
||||
self.Task_do['bbs_Like_posts_num'] -= i['happened_times']
|
||||
self.Task_do['bbs_Like_posts_num'] -= i[
|
||||
'happened_times'
|
||||
]
|
||||
# 61是分享帖子
|
||||
elif i['mission_id'] == 61:
|
||||
if i['is_get_award']:
|
||||
@ -159,10 +151,18 @@ class MihoyoBBSCoin:
|
||||
temp_list = []
|
||||
logger.info('正在获取帖子列表......')
|
||||
async with AsyncClient() as client:
|
||||
req = await client.get(url=bbs_Listurl.format(self.mihoyobbs_List_Use[0]['forumId']), headers=self.headers)
|
||||
req = await client.get(
|
||||
url=bbs_Listurl.format(self.mihoyobbs_List_Use[0]['forumId']),
|
||||
headers=self.headers,
|
||||
)
|
||||
data = req.json()
|
||||
for n in range(5):
|
||||
temp_list.append([data['data']['list'][n]['post']['post_id'], data['data']['list'][n]['post']['subject']])
|
||||
temp_list.append(
|
||||
[
|
||||
data['data']['list'][n]['post']['post_id'],
|
||||
data['data']['list'][n]['post']['subject'],
|
||||
]
|
||||
)
|
||||
# log.info('已获取{}个帖子'.format(len(temp_list)))
|
||||
return temp_list
|
||||
|
||||
@ -171,9 +171,15 @@ class MihoyoBBSCoin:
|
||||
if self.Task_do['bbs_Sign']:
|
||||
return '讨论区任务已经完成过了~'
|
||||
else:
|
||||
header = deepcopy(self.headers)
|
||||
for i in self.mihoyobbs_List_Use:
|
||||
header['DS'] = get_ds_token(
|
||||
'', {'gids': i['id']}, 't0qEgfub6cvueAPgR5m9aQWWVciEer7v'
|
||||
)
|
||||
async with AsyncClient() as client:
|
||||
req = await client.post(url=bbs_Signurl.format(i['id']), data={}, headers=self.headers)
|
||||
req = await client.post(
|
||||
url=bbs_Signurl, json={"gids": i["id"]}, headers=header
|
||||
)
|
||||
data = req.json()
|
||||
if 'err' not in data['message']:
|
||||
time.sleep(random.randint(2, 8))
|
||||
@ -189,7 +195,10 @@ class MihoyoBBSCoin:
|
||||
num_ok = 0
|
||||
for i in range(self.Task_do['bbs_Read_posts_num']):
|
||||
async with AsyncClient() as client:
|
||||
req = await client.get(url=bbs_Detailurl.format(self.postsList[i][0]), headers=self.headers)
|
||||
req = await client.get(
|
||||
url=bbs_Detailurl.format(self.postsList[i][0]),
|
||||
headers=self.headers,
|
||||
)
|
||||
data = req.json()
|
||||
if data['message'] == 'OK':
|
||||
num_ok += 1
|
||||
@ -205,8 +214,11 @@ class MihoyoBBSCoin:
|
||||
num_cancel = 0
|
||||
for i in range(self.Task_do['bbs_Like_posts_num']):
|
||||
async with AsyncClient() as client:
|
||||
req = await client.post(url=bbs_Likeurl, headers=self.headers,
|
||||
json={'post_id': self.postsList[i][0], 'is_cancel': False})
|
||||
req = await client.post(
|
||||
url=bbs_Likeurl,
|
||||
headers=self.headers,
|
||||
json={'post_id': self.postsList[i][0], 'is_cancel': False},
|
||||
)
|
||||
data = req.json()
|
||||
if data['message'] == 'OK':
|
||||
num_ok += 1
|
||||
@ -214,8 +226,11 @@ class MihoyoBBSCoin:
|
||||
if True:
|
||||
time.sleep(random.randint(2, 8))
|
||||
async with AsyncClient() as client:
|
||||
req = await client.post(url=bbs_Likeurl, headers=self.headers,
|
||||
json={'post_id': self.postsList[i][0], 'is_cancel': True})
|
||||
req = await client.post(
|
||||
url=bbs_Likeurl,
|
||||
headers=self.headers,
|
||||
json={'post_id': self.postsList[i][0], 'is_cancel': True},
|
||||
)
|
||||
data = req.json()
|
||||
if data['message'] == 'OK':
|
||||
num_cancel += 1
|
||||
@ -229,7 +244,10 @@ class MihoyoBBSCoin:
|
||||
else:
|
||||
for _ in range(3):
|
||||
async with AsyncClient() as client:
|
||||
req = await client.get(url=bbs_Shareurl.format(self.postsList[0][0]), headers=self.headers)
|
||||
req = await client.get(
|
||||
url=bbs_Shareurl.format(self.postsList[0][0]),
|
||||
headers=self.headers,
|
||||
)
|
||||
data = req.json()
|
||||
if data['message'] == 'OK':
|
||||
return 'ShareM:完成!'
|
||||
|
Loading…
x
Reference in New Issue
Block a user