加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
xmly_speed.py 40.77 KB
一键复制 编辑 原始数据 按行查看 历史
hajiuhajiu 提交于 2021-03-01 05:28 . NEW
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090
import requests
import json
import rsa
import base64
import time
from itertools import groupby
import hashlib
from datetime import datetime, timedelta
import os
import re
# 喜马拉雅极速版
# 使用参考 https://github.com/Zero-S1/xmly_speed/blob/master/xmly_speed.md
###################################################
# 对应方案2: 下载到本地,需要此处填写
cookies1 = ""
cookies2 = ""
cookiesList = [cookies1, ] # 多账号准备
# 通知服务
BARK = '' # bark服务,自行搜索; secrets可填;形如jfjqxDx3xxxxxxxxSaK的字符串
SCKEY = '' # Server酱的SCKEY; secrets可填
TG_BOT_TOKEN = '' # telegram bot token 自行申请
TG_USER_ID = '' # telegram 用户ID
###################################################
# 对应方案1: GitHub action自动运行,此处无需填写;
if "XMLY_SPEED_COOKIE" in os.environ:
"""
判断是否运行自GitHub action,"XMLY_SPEED_COOKIE" 该参数与 repo里的Secrets的名称保持一致
"""
print("执行自GitHub action")
xmly_speed_cookie = os.environ["XMLY_SPEED_COOKIE"]
cookiesList = [] # 重置cookiesList
for line in xmly_speed_cookie.split('\n'):
if not line:
continue
cookiesList.append(line)
# GitHub action运行需要填写对应的secrets
if "BARK" in os.environ and os.environ["BARK"]:
BARK = os.environ["BARK"]
print("BARK 推送打开")
if "SCKEY" in os.environ and os.environ["SCKEY"]:
BARK = os.environ["SCKEY"]
print("serverJ 推送打开")
if "TG_BOT_TOKEN" in os.environ and os.environ["TG_BOT_TOKEN"] and "TG_USER_ID" in os.environ and os.environ["TG_USER_ID"]:
TG_BOT_TOKEN = os.environ["TG_BOT_TOKEN"]
TG_USER_ID = os.environ["TG_USER_ID"]
print("Telegram 推送打开")
###################################################
# 可选项
# 自定义设备命名,非必须 ;devices=["iPhone7P","huawei"];与cookiesList对应
devices = []
notify_time = 19 # 通知时间,24小时制,默认19
XMLY_ACCUMULATE_TIME = 1 # 希望刷时长的,此处置1,默认打开;关闭置0
UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iting/1.0.12 kdtunion_iting/1.0 iting(main)/1.0.12/ios_1"
# 非iOS设备的需要的自行修改,自己抓包 与cookie形式类似
def str2dict(str_cookie):
if type(str_cookie) == dict:
return str_cookie
tmp = str_cookie.split(";")
dict_cookie = {}
try:
for i in tmp:
j = i.split("=")
if not j[0]:
continue
dict_cookie[j[0].strip()] = j[1].strip()
assert dict_cookie["1&_token"].split("&")[0]
regex = r"&\d\.\d\.\d+"
appid = "&1.0.12"
dict_cookie["1&_device"] = re.sub(
regex, appid, dict_cookie["1&_device"], 0, re.MULTILINE)
print(dict_cookie["1&_device"])
except (IndexError, KeyError):
print("cookie填写出错 ❌,仔细查看说明")
raise
return dict_cookie
def get_time():
mins = int(time.time())
date_stamp = (mins-57600) % 86400
utc_dt = datetime.utcnow() # UTC时间
bj_dt = utc_dt+timedelta(hours=8) # 北京时间
_datatime = bj_dt.strftime("%Y%m%d", )
notify_time = bj_dt.strftime("%H %M")
print(f"\n当前时间戳: {mins}")
print(f"北京时间: {bj_dt}\n\n")
return mins, date_stamp, _datatime, notify_time
def read(cookies):
print("\n【阅读】")
headers = {
'Host': '51gzdhh.xyz',
'accept': 'application/json, text/plain, */*',
'origin': 'http://xiaokuohao.work',
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0.1; MI 6 Plus Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Mobile Safari/537.36 iting(main)/1.8.18/android_1 kdtUnion_iting/1.8.18',
'referer': 'http://xiaokuohao.work/static/web/dxmly/index.html',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,en-US;q=0.8',
'x-requested-with': 'com.ximalaya.ting.lite',
}
params = (
('hid', '233'),
)
try:
response = requests.get(
'https://51gzdhh.xyz/api/new/newConfig', headers=headers, params=params)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
result = response.json()
pid = str(result["pid"])
headers = {
'Host': '51gzdhh.xyz',
'content-length': '37',
'accept': 'application/json, text/plain, */*',
'origin': 'http://xiaokuohao.work',
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0.1; MI 6 Plus Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Mobile Safari/537.36 iting(main)/1.8.18/android_1 kdtUnion_iting/1.8.18',
'content-type': 'application/x-www-form-urlencoded',
'referer': 'http://xiaokuohao.work/static/web/dxmly/index.html',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,en-US;q=0.8',
'x-requested-with': 'com.ximalaya.ting.lite',
}
uid = get_uid(cookies)
data = {"pid": str(pid), "mtuserid": uid}
try:
response = requests.post(
'https://51gzdhh.xyz/api/new/hui/complete', headers=headers, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
result = response.json()
if result["status"] == -2:
# print("无法阅读,尝试从安卓端手动开启")
return
# print(result["completeList"])
if result["isComplete"] or result["count_finish"] == 9:
print("今日完成阅读")
return
headers = {
'Host': '51gzdhh.xyz',
'accept': 'application/json, text/plain, */*',
'origin': 'http://xiaokuohao.work',
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0.1; MI 6 Plus Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/52.0.2743.100 Mobile Safari/537.36 iting(main)/1.8.18/android_1 kdtUnion_iting/1.8.18',
'referer': 'http://xiaokuohao.work/static/web/dxmly/index.html',
'accept-encoding': 'gzip, deflate',
'accept-language': 'zh-CN,en-US;q=0.8',
'x-requested-with': 'com.ximalaya.ting.lite',
}
taskIds = set(['242', '239', '241', '240', '238', '236',
'237', '235', '234'])-set(result["completeList"])
params = (
('userid', str(uid)),
('pid', pid),
('taskid', taskIds.pop()),
('imei', ''),
)
try:
response = requests.get(
'https://51gzdhh.xyz/new/userCompleteNew', headers=headers, params=params)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return 0
result = response.json()
print(result)
def ans_receive(cookies, paperId, lastTopicId, receiveType):
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/quiz',
}
_checkData = f"""lastTopicId={lastTopicId}&numOfAnswers=3&receiveType={receiveType}"""
checkData = rsa_encrypt(str(_checkData), pubkey_str)
data = {
"paperId": paperId,
"checkData": checkData,
"lastTopicId": lastTopicId,
"numOfAnswers": 3,
"receiveType": receiveType
}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/topic/receive',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return 0
return response.json()
def stage(cookies):
# 新手任务
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 iting/2.0.9 kdtunion_iting/1.0 iting(main)/2.0.9/ios_1',
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/welfare',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/task/stage-rewards-daily', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
data = response.json()["data"]
if not data:
return
stageRewards = data["stageRewards"]
for k, v in enumerate(stageRewards, 1):
print(k, v)
if v["status"] == 1:
headers = {
'Host': 'm.ximalaya.com',
'Content-Type': 'application/json',
'Accept': '*/*',
'Connection': 'keep-alive',
'User-Agent': 'ting_v2.0.9_c5(CFNetwork, iOS 14.3, iPhone9,2)',
'Accept-Language': 'zh-Hans-CN;q=1, en-CN;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'X-Requested-With': 'XMLHttpRequest',
}
params = (('stage', f'{k}'),)
try:
response = requests.get('https://m.ximalaya.com/speed/web-earn/task/stage-reward/receive',
headers=headers, params=params, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print(response.text)
def ans_restore(cookies):
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/quiz',
}
checkData = rsa_encrypt("restoreType=2", pubkey_str)
data = {
"restoreType": 2,
"checkData": checkData,
}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/topic/restore',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return 0
result = response.json()
if "errorCode" in result:
return 0
return 1
def ans_getTimes(cookies):
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/quiz',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/topic/user', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return {"stamina": 0,
"remainingTimes": 0}
print(response.text)
result = response.json()
stamina = result["data"]["stamina"]
remainingTimes = result["data"]["remainingTimes"]
return {"stamina": stamina,
"remainingTimes": remainingTimes}
def ans_start(cookies):
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/quiz',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/topic/start', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return 0, 0, 0
# print(response.text)
result = response.json()
try:
paperId = result["data"]["paperId"]
dateStr = result["data"]["dateStr"]
lastTopicId = result["data"]["topics"][2]["topicId"]
print(paperId, dateStr, lastTopicId)
return paperId, dateStr, lastTopicId
except:
print("❌1 重新抓包 2 手动答题")
return 0, 0, 0
def _str2key(s):
b_str = base64.b64decode(s)
if len(b_str) < 162:
return False
hex_str = ''
for x in b_str:
h = hex(x)[2:]
h = h.rjust(2, '0')
hex_str += h
m_start = 29 * 2
e_start = 159 * 2
m_len = 128 * 2
e_len = 3 * 2
modulus = hex_str[m_start:m_start + m_len]
exponent = hex_str[e_start:e_start + e_len]
return modulus, exponent
def rsa_encrypt(s, pubkey_str):
key = _str2key(pubkey_str)
modulus = int(key[0], 16)
exponent = int(key[1], 16)
pubkey = rsa.PublicKey(modulus, exponent)
return base64.b64encode(rsa.encrypt(s.encode(), pubkey)).decode()
pubkey_str = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVhaR3Or7suUlwHUl2Ly36uVmboZ3+HhovogDjLgRE9CbaUokS2eqGaVFfbxAUxFThNDuXq/fBD+SdUgppmcZrIw4HMMP4AtE2qJJQH/KxPWmbXH7Lv+9CisNtPYOlvWJ/GHRqf9x3TBKjjeJ2CjuVxlPBDX63+Ecil2JR9klVawIDAQAB"
def lottery_info(cookies):
print("\n【幸运大转盘】")
"""
转盘信息查询
"""
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-ad-sweepstake-h5/home',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/inspire/lottery/info', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
result = response.json()
remainingTimes = result["data"]["remainingTimes"]
print(f'转盘info: {result["data"]}\n')
if remainingTimes in [0, 1]:
print("今日完毕")
return
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/inspire/lottery/token', headers=headers, cookies=cookies)
print("token", response.text)
token = response.json()["data"]["id"]
data = {
"token": token,
"sign": rsa_encrypt(f"token={token}&userId={get_uid(cookies)}", pubkey_str),
}
response = requests.post('https://m.ximalaya.com/speed/web-earn/inspire/lottery/chance',
headers=headers, cookies=cookies, data=json.dumps(data))
result = response.json()
print("chance", result)
data = {
"sign": rsa_encrypt(str(result["data"]["chanceId"]), pubkey_str),
}
response = requests.post('https://m.ximalaya.com/speed/web-earn/inspire/lottery/action',
headers=headers, cookies=cookies, data=json.dumps(data))
print(response.text)
def index_baoxiang_award(cookies):
print("\n 【首页、宝箱奖励及翻倍】")
headers = {
'User-Agent': UserAgent,
'Host': 'mobile.ximalaya.com',
}
uid = cookies["1&_token"].split("&")[0]
currentTimeMillis = int(time.time()*1000)-2
try:
response = requests.post('https://mobile.ximalaya.com/pizza-category/activity/getAward?activtyId=baoxiangAward',
headers=headers, cookies=cookies)
except:
return
result = response.json()
print("宝箱奖励: ", result)
if "ret" in result and result["ret"] == 0:
awardReceiveId = result["awardReceiveId"]
headers = {
'Host': 'mobile.ximalaya.com',
'Accept': '*/*',
'User-Agent': UserAgent,
'Accept-Language': 'zh-Hans-CN;q=1, en-CN;q=0.9',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
}
params = (
('activtyId', 'baoxiangAward'),
('awardReceiveId', awardReceiveId),
)
try:
response = requests.get('http://mobile.ximalaya.com/pizza-category/activity/awardMultiple',
headers=headers, params=params, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print("翻倍 ", response.text)
uid = get_uid(cookies)
###################################
params = (
('activtyId', 'indexSegAward'),
('ballKey', str(uid)),
('currentTimeMillis', str(currentTimeMillis)),
('sawVideoSignature', f'{currentTimeMillis}+{uid}'),
('version', '2'),
)
try:
response = requests.get('https://mobile.ximalaya.com/pizza-category/activity/getAward',
headers=headers, cookies=cookies, params=params)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
result = response.json()
print("首页奖励: ", result)
if "ret" in result and result["ret"] == 0:
awardReceiveId = result["awardReceiveId"]
headers = {
'Host': 'mobile.ximalaya.com',
'Accept': '*/*',
'User-Agent': UserAgent,
'Accept-Language': 'zh-Hans-CN;q=1, en-CN;q=0.9',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
}
params = (
('activtyId', 'indexSegAward'),
('awardReceiveId', awardReceiveId),
)
try:
response = requests.get('http://mobile.ximalaya.com/pizza-category/activity/awardMultiple',
headers=headers, params=params, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print("翻倍: ", response.text)
def checkin(cookies, _datatime):
print("\n【连续签到】")
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/welfare',
'Accept-Encoding': 'gzip, deflate, br',
}
params = (
('time', f"""{int(time.time()*1000)}"""),
)
try:
response = requests.get('https://m.ximalaya.com/speed/task-center/check-in/record',
headers=headers, params=params, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return 0
result = json.loads(response.text)
print(result)
print(f"""连续签到{result["continuousDays"]}/{result["historyDays"]}天""")
print(result["isTickedToday"])
if not result["isTickedToday"]:
print("!!!开始签到")
# if result["canMakeUp"]:
# print("canMakeUp 第30天需要手动")
# return
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/growth-ssr-speed-welfare-center/page/welfare',
}
uid = get_uid(cookies)
data = {
"checkData": rsa_encrypt(f"date={_datatime}&uid={uid}", pubkey_str),
"makeUp": False
}
response = requests.post('https://m.ximalaya.com/speed/task-center/check-in/check',
headers=headers, cookies=cookies, data=json.dumps(data))
print(response.text)
return result["continuousDays"]
def ad_score(cookies, businessType, taskId):
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain ,*/*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Content-Type': 'application/json;charset=utf-8',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/task-center/ad/token', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
result = response.json()
token = result["id"]
uid = get_uid(cookies)
data = {
"taskId": taskId,
"businessType": businessType,
"rsaSign": rsa_encrypt(f"""businessType={businessType}&token={token}&uid={uid}""", pubkey_str),
}
try:
response = requests.post(f'https://m.ximalaya.com/speed/task-center/ad/score',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print(response.text)
print("\n")
def bubble(cookies):
print("\n【bubble】")
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-open-components/bubble',
}
uid = get_uid(cookies)
data = {"listenTime": "41246", "signature": "2b1cc9e8831cff8874d9c",
"currentTimeMillis": "1596695606145", "uid": uid, "expire": False}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/listen/bubbles',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
result = response.json()
# print(result)
if not result["data"]["effectiveBubbles"]:
print("暂无有效气泡")
return
for i in result["data"]["effectiveBubbles"]:
print(i["id"])
tmp = receive(cookies, i["id"])
if "errorCode" in tmp:
print("❌ 每天手动收听一段时间,暂无其他方法")
return
time.sleep(1)
ad_score(cookies, 7, i["id"])
for i in result["data"]["expiredBubbles"]:
ad_score(cookies, 6, i["id"])
def receive(cookies, taskId):
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-open-components/bubble',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
f'https://m.ximalaya.com/speed/web-earn/listen/receive/{taskId}', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print("receive: ", response.text)
return response.json()
def getOmnipotentCard(cookies, mins, date_stamp, _datatime):
print("\n 【领取万能卡】")
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
}
try:
count = requests.get('https://m.ximalaya.com/speed/web-earn/card/omnipotentCardInfo',
headers=headers, cookies=cookies,).json()["data"]["count"]
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
if count == 5:
print("今日已满")
return
token = requests.get('https://m.ximalaya.com/speed/web-earn/card/token/1',
headers=headers, cookies=cookies,).json()["data"]["id"]
uid = get_uid(cookies)
data = {
"listenTime": mins-date_stamp,
"signData": rsa_encrypt(f"{_datatime}{token}{uid}", pubkey_str),
"token": token
}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/card/getOmnipotentCard',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print(response.text)
def cardReportTime(cookies, mins, date_stamp, _datatime):
print("\n【收听获得抽卡机会】")
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
}
listenTime = mins-date_stamp
uid = get_uid(cookies)
data = {"listenTime": listenTime,
"signData": rsa_encrypt(f"{_datatime}{listenTime}{uid}", pubkey_str), }
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/card/reportTime',
headers=headers, cookies=cookies, data=json.dumps(data)).json()
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
try:
response["data"]["upperLimit"]
print("今日已达上限")
except:
return
def account(cookies):
print("\n【 打印账号信息】")
headers = {
'Host': 'm.ximalaya.com',
'Content-Type': 'application/json;charset=utf-8',
'Connection': 'keep-alive',
'Accept': 'application/json, text/plain, */*',
'User-Agent': UserAgent,
'Referer': 'https://m.ximalaya.com/speed/web-earn/wallet',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/account/coin', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return '', '', ''
result = response.json()
total = result["total"]/10000
todayTotal = result["todayTotal"]/10000
historyTotal = result["historyTotal"]/10000
print(f"""
当前剩余:{total}
今日获得:{todayTotal}
累计获得:{historyTotal}
""")
return total, todayTotal, historyTotal
def answer(cookies):
print("\n【答题】")
ans_times = ans_getTimes(cookies)
if not ans_times:
return
if ans_times["stamina"] == 0:
print("时间未到")
for _ in range(ans_times["stamina"]):
paperId, _, lastTopicId = ans_start(cookies)
if paperId == 0:
return
tmp = ans_receive(cookies, paperId, lastTopicId, 1)
print(tmp)
if "errorCode" in tmp:
print("❌ 每天手动收听一段时间,暂无其他方法")
return
time.sleep(1)
tmp = ans_receive(cookies, paperId, lastTopicId, 2)
print(tmp)
if tmp == 0:
return
time.sleep(1)
if ans_times["remainingTimes"] > 0:
print("[看视频回复体力]")
if ans_restore(cookies) == 0:
return
for _ in range(5):
paperId, _, lastTopicId = ans_start(cookies)
if paperId == 0:
return
tmp = ans_receive(cookies, paperId, lastTopicId, 1)
print(tmp)
if "errorCode" in tmp:
print("❌ 每天手动收听一段时间,暂无其他方法")
return
time.sleep(1)
tmp = ans_receive(cookies, paperId, lastTopicId, 2)
print(tmp)
if tmp == 0:
return
time.sleep(1)
def saveListenTime(cookies, date_stamp):
print("\n【刷时长1】")
headers = {
'User-Agent': UserAgent,
'Host': 'mobile.ximalaya.com',
'Content-Type': 'application/x-www-form-urlencoded',
}
listentime = date_stamp
print(f"上传本地收听时长1: {listentime//60}分钟")
currentTimeMillis = int(time.time()*1000)-2
uid = get_uid(cookies)
sign = hashlib.md5(
f'currenttimemillis={currentTimeMillis}&listentime={listentime}&uid={uid}&23627d1451047b8d257a96af5db359538f081d651df75b4aa169508547208159'.encode()).hexdigest()
data = {
'activtyId': 'listenAward',
'currentTimeMillis': currentTimeMillis,
'listenTime': str(listentime),
'nativeListenTime': str(listentime),
'signature': sign,
'uid': uid
}
try:
response = requests.post('http://mobile.ximalaya.com/pizza-category/ball/saveListenTime',
headers=headers, cookies=cookies, data=data)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print(response.text)
def listenData(cookies, date_stamp):
print("\n【刷时长2】")
headers = {
'User-Agent': 'ting_v1.1.9_c5(CFNetwork, iOS 14.0.1, iPhone9,2)',
'Host': 'm.ximalaya.com',
'Content-Type': 'application/json',
}
listentime = date_stamp-1
print(f"上传本地收听时长2: {listentime//60}分钟")
currentTimeMillis = int(time.time()*1000)
uid = get_uid(cookies)
sign = hashlib.md5(
f'currenttimemillis={currentTimeMillis}&listentime={listentime}&uid={uid}&23627d1451047b8d257a96af5db359538f081d651df75b4aa169508547208159'.encode()).hexdigest()
data = {
'currentTimeMillis': currentTimeMillis,
'listenTime': str(listentime),
'signature': sign,
'uid': uid
}
try:
response = requests.post('http://m.ximalaya.com/speed/web-earn/listen/client/data',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print(response.text)
def card_exchangeCoin(cookies, themeId, cardIdList, _datatime):
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
'Accept-Encoding': 'gzip, deflate, br',
}
token = requests.get('https://m.ximalaya.com/speed/web-earn/card/token/3',
headers=headers, cookies=cookies,).json()["data"]["id"]
uid = get_uid(cookies)
data = {
"cardIdList": cardIdList,
"themeId": themeId,
"signData": rsa_encrypt(f"{_datatime}{token}{uid}", pubkey_str),
"token": token
}
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/card/exchangeCoin',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print("card_exchangeCoin: ", response.text)
def card_exchangeCard(cookies, toCardAwardId, fromRecordIdList):
fromRecordIdList = sorted(fromRecordIdList)
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
}
data = {
"toCardAwardId": toCardAwardId,
"fromRecordIdList": fromRecordIdList,
"exchangeType": 1,
}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/card/exchangeCard',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print(response.text)
def draw_5card(cookies, drawRecordIdList): # 五连抽
drawRecordIdList = sorted(drawRecordIdList)
headers = {
'User-Agent': UserAgent,
'Content-Type': 'application/json;charset=utf-8',
'Host': 'm.ximalaya.com',
'Origin': 'https://m.ximalaya.com',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
}
uid = get_uid(cookies)
data = {
"signData": rsa_encrypt(f"{''.join(str(i) for i in drawRecordIdList)}{uid}", pubkey_str),
"drawRecordIdList": drawRecordIdList,
"drawType": 2,
}
try:
response = requests.post('https://m.ximalaya.com/speed/web-earn/card/draw',
headers=headers, cookies=cookies, data=json.dumps(data))
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
print("五连抽: ", response.text)
def card(cookies, _datatime):
print("\n【抽卡】")
headers = {
'Host': 'm.ximalaya.com',
'Accept': 'application/json, text/plain, */*',
'Connection': 'keep-alive',
'User-Agent': UserAgent,
'Accept-Language': 'zh-cn',
'Referer': 'https://m.ximalaya.com/xmds-node-spa/apps/speed-growth-activities/card-collection/home',
'Accept-Encoding': 'gzip, deflate, br',
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/card/userCardInfo', headers=headers, cookies=cookies)
except:
print("网络请求异常,为避免GitHub action报错,直接跳过")
return
data = response.json()["data"]
#######
# 5连抽
drawRecordIdList = data["drawRecordIdList"]
print("抽卡机会: ", drawRecordIdList)
for _ in range(len(drawRecordIdList)//5):
tmp = []
for _ in range(5):
tmp.append(drawRecordIdList.pop())
draw_5card(cookies, tmp)
########
# 手牌兑换金币
# 1 万能卡 10 碎片
print("检查手牌,卡牌兑金币")
themeId_id_map = {
2: [2, 3],
3: [4, 5, 6, 7],
4: [8, 9, 10, 11, 12],
5: [13, 14, 15, 16, 17, 18],
6: [19, 20, 21, 22],
7: [23, 24, 25, 26, 27],
8: [28, 29, 30, 31, 32],
9: [33, 34, 35, 36, 37]
}
try:
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/card/userCardInfo', headers=headers, cookies=cookies)
except:
return
data = response.json()["data"]
userCardsList = data["userCardsList"] # 手牌
lstg = groupby(userCardsList, key=lambda x: x["themeId"])
for key, group in lstg:
if key in [1, 10]:
continue
themeId = key
ids = list(group)
tmp_recordId = []
tmp_id = []
for i in ids:
if i["id"] in tmp_id:
continue
tmp_recordId.append(i["recordId"])
tmp_id.append(i["id"])
if len(tmp_recordId) == len(themeId_id_map[key]):
print("可以兑换")
card_exchangeCoin(cookies, themeId, tmp_recordId, _datatime)
###############
# 万能卡兑换稀有卡
response = requests.get(
'https://m.ximalaya.com/speed/web-earn/card/userCardInfo', headers=headers, cookies=cookies)
data = response.json()["data"]
userCardsList = data["userCardsList"]
omnipotentCard = [i for i in userCardsList if i["id"] == 1]
cityCardId = [i["id"] for i in userCardsList if i["themeId"] == 9]
need = set(themeId_id_map[9])-set(cityCardId)
print("万能卡: ", [i['recordId'] for i in omnipotentCard])
for _ in range(len(omnipotentCard)//4):
tmp = []
for _ in range(4):
tmp.append(omnipotentCard.pop())
fromRecordIdList = [i['recordId'] for i in tmp]
if need:
print("万能卡兑换稀有卡:")
card_exchangeCard(cookies, need.pop(), fromRecordIdList)
def get_uid(cookies):
return cookies["1&_token"].split("&")[0]
def serverJ(title, content):
print("\n")
sckey = SCKEY
if "SCKEY" in os.environ:
"""
判断是否运行自GitHub action,"SCKEY" 该参数与 repo里的Secrets的名称保持一致
"""
sckey = os.environ["SCKEY"]
if not sckey:
print("server酱服务的SCKEY未设置!!\n取消推送")
return
print("serverJ服务启动")
data = {
"text": title,
"desp": content.replace("\n", "\n\n")+"\n\n [打赏作者](https://github.com/Zero-S1/xmly_speed/blob/master/thanks.md)"
}
response = requests.post(f"https://sc.ftqq.com/{sckey}.send", data=data)
print(response.text)
def bark(title, content):
print("\n")
bark_token = BARK
if "BARK" in os.environ:
bark_token = os.environ["BARK"]
if not bark_token:
print("bark服务的bark_token未设置!!\n取消推送")
return
print("bark服务启动")
response = requests.get(
f"""https://api.day.app/{bark_token}/{title}/{content}""")
print(response.text)
def telegram_bot(title, content):
print("\n")
tg_bot_token = TG_BOT_TOKEN
tg_user_id = TG_USER_ID
if "TG_BOT_TOKEN" in os.environ and "TG_USER_ID" in os.environ:
tg_bot_token = os.environ["TG_BOT_TOKEN"]
tg_user_id = os.environ["TG_USER_ID"]
if not tg_bot_token or not tg_user_id:
print("Telegram推送的tg_bot_token或者tg_user_id未设置!!\n取消推送")
return
print("Telegram 推送开始")
send_data = {"chat_id": tg_user_id, "text": title +
'\n\n'+content, "disable_web_page_preview": "true"}
response = requests.post(
url='https://api.telegram.org/bot%s/sendMessage' % (tg_bot_token), data=send_data)
print(response.text)
def run():
print(f"喜马拉雅极速版 (https://github.com/Zero-S1/xmly_speed/blob/master/xmly_speed.md ) ,欢迎打赏¯\(°_o)/¯")
mins, date_stamp, _datatime, _notify_time = get_time()
table = []
for k, v in enumerate(cookiesList):
print(f">>>>>>>【账号开始{k+1}\n")
cookies = str2dict(v)
if XMLY_ACCUMULATE_TIME == 1:
saveListenTime(cookies, date_stamp)
listenData(cookies, date_stamp)
stage(cookies)
read(cookies) # 阅读
bubble(cookies) # 收金币气泡
# continue
continuousDays = checkin(cookies, _datatime) # 自动签到
# lottery_info(cookies) # 大转盘4次
answer(cookies) # 答题赚金币
cardReportTime(cookies, mins, date_stamp, _datatime) # 卡牌
getOmnipotentCard(cookies, mins, date_stamp, _datatime) # 领取万能卡
card(cookies, _datatime) # 抽卡
index_baoxiang_award(cookies) # 首页、宝箱奖励及翻倍
total, todayTotal, historyTotal = account(cookies)
try:
device = devices[k]
except IndexError:
device = cookies['device_model']
else:
device = f"设备{k+1}"
table.append((device, total, todayTotal,
historyTotal, continuousDays,))
print("###"*20)
print("\n"*4)
if _notify_time.split()[0] == str(notify_time) and int(_notify_time.split()[1]) > 30:
# if 1:
message = ''
for i in table:
message += f"[{i[0].replace(' ',''):<9}]: {i[1]:<6.2f} (+{i[2]:<4.2f}) {i[3]:<7.2f} {i[4]}\\30\n"
message += "⭕tips:第30天需要手动签到 by zero_s1, (*^_^*)欢迎打赏 "
if len(table) <= 4:
message = "【设备】| 当前剩余 | 今天| 历史| 连续签到\n"+message
bark("⏰ 喜马拉雅极速版", message)
serverJ("⏰ 喜马拉雅极速版", message)
telegram_bot("⏰ 喜马拉雅极速版", message)
if __name__ == "__main__":
run()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化