forked from KimigaiiWuyi/GenshinUID
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetData.py
More file actions
151 lines (140 loc) · 5.99 KB
/
Copy pathgetData.py
File metadata and controls
151 lines (140 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# https://github.com/Womsxd/YuanShen_User_Info
#import hashlib
#import json
#import random
#import string
import sys
#import time
from httpx import AsyncClient
from .getDB import cookiesDB,cacheDB
from nonebot import *
import json
from random import randint
import requests,random,os,json,re
from hoshino import Service,R,priv,util
from hoshino.typing import MessageSegment,CQEvent, HoshinoBot
from hoshino.util import FreqLimiter,pic2b64
import hoshino
import asyncio
import time
import string
import random
import hashlib
import requests
import os
from PIL import Image,ImageFont,ImageDraw
from io import BytesIO
import base64
mhyVersion = "2.11.1"
def md5(text):
md5 = hashlib.md5()
md5.update(text.encode())
return md5.hexdigest()
def DSGet(q = "",b = None):
if b:
br = json.dumps(b)
else:
br = ""
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)
return t + "," + r + "," + c
async def GetInfo(Uid,ServerID="cn_gf01",Schedule_type="1",mysid = None):
if Uid[0] == '5':
ServerID = "cn_qd01"
try:
async with AsyncClient() as client:
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/index?role_id=" + Uid + "&server=" + ServerID,
headers={
#'Accept': 'application/json, text/plain, */*',
'DS': DSGet("role_id=" + Uid + "&server=" + ServerID),
#'Origin': 'https://webstatic.mihoyo.com',
'x-rpc-app_version': mhyVersion,
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer': 'https://webstatic.mihoyo.com/',
#'Accept-Encoding': 'gzip, deflate',
#'Accept-Language': 'zh-CN,en-US;q=0.8',
#'X-Requested-With': 'com.mihoyo.hyperion',
"Cookie": await cacheDB(Uid,1,mysid)})
data = json.loads(req.text)
return data
except:
print("访问失败,请重试!")
sys.exit(1)
async def GetSpiralAbyssInfo(Uid, ServerID="cn_gf01",Schedule_type="1",mysid = None):
if Uid[0] == '5':
ServerID = "cn_qd01"
try:
async with AsyncClient() as client:
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/app/genshin/api/spiralAbyss?schedule_type=" + Schedule_type + "&server="+ ServerID +"&role_id=" + Uid,
headers={
'Accept': 'application/json, text/plain, */*',
'DS': DSGet("role_id=" + Uid + "&schedule_type=" + Schedule_type + "&server="+ ServerID),
'Origin': 'https://webstatic.mihoyo.com',
'Cookie': await cacheDB(Uid,1,mysid),
'x-rpc-app_version': mhyVersion,
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer': 'https://webstatic.mihoyo.com/',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.8',
'X-Requested-With': 'com.mihoyo.hyperion'
}
)
data = json.loads(req.text)
return data
except:
print("1访问失败,请重试!")
sys.exit(1)
async def GetCharacter(Uid,Character_ids, ServerID="cn_gf01",mysid = None):
if Uid[0] == '5':
ServerID = "cn_qd01"
try:
req = requests.post(
url = "https://api-takumi.mihoyo.com/game_record/app/genshin/api/character",
headers={
'Accept': 'application/json, text/plain, */*',
'DS': DSGet('',{"character_ids": Character_ids ,"role_id": Uid ,"server": ServerID}),
'Origin': 'https://webstatic.mihoyo.com',
'Cookie': await cacheDB(Uid,1,mysid),
'x-rpc-app_version': mhyVersion,
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer': 'https://webstatic.mihoyo.com/',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'zh-CN,en-US;q=0.8',
'X-Requested-With': 'com.mihoyo.hyperion'
},
json = {"character_ids": Character_ids ,"role_id": Uid ,"server": ServerID}
)
data2 = json.loads(req.text)
return data2
except:
print("访问失败,请重试!")
sys.exit(1)
async def GetMysInfo(mysid):
try:
async with AsyncClient() as client:
req = await client.get(
url="https://api-takumi.mihoyo.com/game_record/card/wapi/getGameRecordCard?uid=" + mysid,
headers={
#'Accept': 'application/json, text/plain, */*',
'DS': DSGet("uid="+mysid),
#'Origin': 'https://webstatic.mihoyo.com',
'x-rpc-app_version': mhyVersion,
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1',
'x-rpc-client_type': '5',
'Referer': 'https://webstatic.mihoyo.com/',
#'Accept-Encoding': 'gzip, deflate',
#'Accept-Language': 'zh-CN,en-US;q=0.8',
#'X-Requested-With': 'com.mihoyo.hyperion',
"Cookie": await cacheDB(mysid,2)})
data = json.loads(req.text)
return [data,mysid]
except:
print ("访问失败,请重试!")
return