This commit is contained in:
rainerosion 2024-05-14 17:10:26 +08:00
parent 157ddab519
commit 909621dea8
6 changed files with 1341 additions and 2 deletions

View File

@ -1,3 +1,17 @@
# qinglong # qinglong-script
<div align="center">
青龙脚本集合 青龙脚本集合
</div>
## ✨ 特性
- 网易云音乐合伙人自动评分 ✔
## 🔨 使用
由于青龙v2.12.0以后调整数据目录log、db、scripts、config等目录迁移到 /ql/data 目录,请使用下面命令的时候注意一下自己的青龙面板版本,看是否需要在路径上加/data
## 依赖
- `PyExecJS`
- `pycryptodome`

87
aliyundrive.py Normal file
View File

@ -0,0 +1,87 @@
#!/usr/bin/python3
# -- coding: utf-8 --
# @Time : 2023/4/8 10:23
# -------------------------------
# cron "30 5 * * *" script-path=xxx.py,tag=匹配cron用
# const $ = new Env('阿里云盘签到');
import json
import requests
import os
##变量export ali_refresh_token=''
ali_refresh_token=os.getenv("ali_refresh_token").split('&')
#refresh_token是一成不变的呢我们使用它来更新签到需要的access_token
#refresh_token获取教程https://github.com/bighammer-link/Common-scripts/wiki/%E9%98%BF%E9%87%8C%E4%BA%91%E7%9B%98refresh_token%E8%8E%B7%E5%8F%96%E6%96%B9%E6%B3%95
# ali_refresh_token = os.getenv("ali_refresh_token")
# 推送加
plustoken = os.getenv("plustoken")
#推送函数
def Push(contents):
# 推送加
headers = {'Content-Type': 'application/json'}
json = {"token": plustoken, 'title': 'aliyun签到', 'content': contents.replace('\n', '<br>'), "template": "json"}
resp = requests.post(f'http://www.pushplus.plus/send', json=json, headers=headers).json()
print('push+推送成功' if resp['code'] == 200 else 'push+推送失败')
#签到函数
for i in range(len(ali_refresh_token)):
print(f'开始帐号{i+1}签到')
def daily_check(access_token):
url = 'https://member.aliyundrive.com/v1/activity/sign_in_list'
headers = {
'Authorization': access_token,
'Content-Type': 'application/json'
}
response = requests.post(url=url, headers=headers, json={}).text
result = json.loads(response)
sign_days = result['result']['signInCount']
data ={
'signInDay':sign_days
}
url_reward ='https://member.aliyundrive.com/v1/activity/sign_in_reward'
resp2 = requests.post(url=url_reward, headers=headers, data=json.dumps(data))
result2=json.loads(resp2.text)
# print(result2)
if 'success' in result:
print('签到成功')
for i, j in enumerate(result['result']['signInLogs']):
if j['status'] == 'miss':
day_json = result['result']['signInLogs'][i-1]
# print(day_json)
if not day_json['isReward']:
contents = '签到成功,今日未获得奖励'
else:
contents = '本月累计签到{}天,今日签到获得{}{}'.format(result['result']['signInCount'],
day_json['reward']['name'],
day_json['reward']['description'])
print(contents)
return contents
# 使用refresh_token更新access_token
def update_token(refresh_token):
url = 'https://auth.aliyundrive.com/v2/account/token'
data = {
'grant_type': 'refresh_token',
'refresh_token': ali_refresh_token[i]
}
response = requests.post(url=url, json=data).json()
access_token = response['access_token']
# print('获取的access_token为{}'.format(access_token))
return access_token
def mian():
# print('更新access_token')
access_token = update_token(ali_refresh_token)
# print('更新成功,开始进行签到')
content = daily_check(access_token)
if plustoken != '':
Push(content)
if __name__ == '__main__':
mian()

950
bilibili.js Normal file
View File

@ -0,0 +1,950 @@
/*
作者https://github.com/lksky8/sign-ql
日期2022-8-3
软件B站签到
功能自动完成每日登录+5经验+1硬币 观看视频+5经验 分享视频+5经验 漫画签到 直播签到
可选自动投币银瓜子换硬币大会员每月领取B币或其他福利每月领取大会员漫画福利月底在 B 币券过期前进行充电等功能
Cookies通过扫码获取
变量
####################################################
export bzck='ck1@ck2 ' 多个账号用 @ 或者 换行 分割
export bztb="" #true开启随机投币false关闭随机投币
export bzdhyb="" #true开启银瓜子兑换硬币
export bzvipgift="" #B站大会员权益 1为B币劵2为会员购优惠券3为漫画福利券4为会员购运费券每个月28号自动领取(非会员默认跳过任务)
export bzbicd="" #true B币券过期前进行充电只会在每个月28号运行
export bzcdmid="" #充电up主id不填默认自己只会在每个月28号运行
export bztbdz="" #投币点赞true 默认不点赞
####################################################
定时一天一次
aid获取https://api.bilibili.com/x/web-interface/view?bvid=BVXXXXXXXX手动填入bvid或者抓包
cron: 5 10 * * *
*/
const $ = new Env('B站签到');
const notify = $.isNode() ? require('./sendNotify') : '';
const theday = new Date().getDate();
const {log} = console;
const Notify = 1; //0为关闭通知1为打开通知,默认为1
//////////////////////
bzck = process.env.bzck;
mid2 = process.env.bzcdmid;
tb = process.env.bztb;
dhyb = process.env.bzdhyb;
vipgift = process.env.bzvipgift;
bicd = process.env.bzbicd;
tbdz = process.env.bztbdz;
let bzckArr = [];
let msg = '';
!(async () => {
if (!(await Envs())) {
return;
} else {
log(`\n\n============================================= \n脚本执行 - 北京时间(UTC+8)${new Date(
new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 +
8 * 60 * 60 * 1000).toLocaleString()} \n=============================================\n`);
log(`\n=================== 共找到 ${bzckArr.length} 个账号 ===================`)
for (let index = 0; index < bzckArr.length; index++) {
let num = index + 1
log(`\n========= 开始【第 ${num} 个账号】=========\n`)
cookies = bzckArr[index];
bili_jct = cookies.match(/bili_jct=(.*?);/)[1]
header = JSON.parse(`{"Connection":"keep-alive","Accept-Encoding":"gzip, deflate, br","Cache-Contro":"max-age=0","Cookie":"${cookies}","User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36","Accept-Language":"zh-cn","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"}`);
msg += `\n${num}个账号运行结果:`
await getinfo();
if (loginb = 1) {
await getBvid();
await check_live_status();//查金银瓜子数量
await doSign();
await $.wait(5 * 1000);
await live_sign();//直播签到
await $.wait(5 * 1000);
await manga_sign();//漫画签到
await $.wait(5 * 1000);
await sharebv();//分享视频
await $.wait(5 * 1000);
await playbv();//播放视频
if (tb == 'true') {
log('已开启随机视频投币功能')
for (var i = 0; i < bvid.length; i++) {
await coin_add(bvid[i]);//投币
await $.wait(2 * 1000);
}
log('已完成投币任务')
msg += '\n【每日投币】已完成投币任务'
} else {
log('未开启投币功能')
}
if (dhyb == 'true') {
log('已开启银瓜子兑换硬币功能')
await silver2coin();
} else {
log('未开启银瓜子兑换硬币功能')
msg += '\n未开启银瓜子兑换硬币功能'
}
if (bzvip != '正式会员' && theday == 28) {
await vip_privilege_receive();//兑换礼品
await $.wait(3 * 1000);
await vip_manga_reward();//领漫画福利
}
if (bicd == 'true' && theday == 28) {
await elec_pay();//B币充电
} else {
log('日期未到28日或未开启B币充值')
msg += '\n日期未到28日或未开启B币充值'
}
await checktask();//查任务完成情况
await $.wait(2 * 1000);
}
}
await SendMsg(msg);
}
})()
.catch((e) => log(e))
.finally(() => $.done())
//获取个人信息
function getinfo() {
return new Promise((resolve) => {
let url = {
url: 'https://api.bilibili.com/x/web-interface/nav',
headers: header,
}
$.get(url, (err, resp, data) => {
try {
result = JSON.parse(data);
if (result.message == '账号未登录') {
log('B站账号未登录,需要重新获取cookie')
msg += '账号未登录,需要重新获取cookie'
loginb = 0
} else {
mid = result.data.mid
if (result.data.level_info.next_exp != '--') {
var exp = parseInt(result.data.level_info.next_exp) - parseInt(result.data.level_info.current_exp)
var needexp = exp.toString()
} else {
var needexp = '未知'
}
if (result.data.vipStatus == 0) {
bzvip = '正式会员'
var vipdate = '非会员'
} else if (result.data.vipStatus == 1 && result.data.vip_label.label_theme == 'vip') {
bzvip = '大会员'
var vipdate = getLocalTime(result.data.vipDueDate)
} else if (result.data.vipStatus == 1 && result.data.vip_label.label_theme == 'annual_vip') {
bzvip = '年度大会员'
var vipdate = getLocalTime(result.data.vipDueDate)
} else if (result.data.vipStatus == 1 && result.data.vip_label.label_theme == 'ten_annual_vip') {
bzvip = '十年大会员'
var vipdate = getLocalTime(result.data.vipDueDate)
} else if (result.data.vipStatus == 1 && result.data.vip_label.label_theme == 'hundred_annual_vip') {
bzvip = '百年大会员'
var vipdate = getLocalTime(result.data.vipDueDate)
}
login = 1
log(`【账号信息】${result.data.uname}(ID:${mid})\n【会员等级】${bzvip}\n【会员到期】${vipdate}\n【账号等级】Lv.${result.data.level_info.current_level}\n【账号经验】${result.data.level_info.current_exp}|还要${needexp}经验可以升级\n【账号资本】硬币${result.data.money}B币${result.data.wallet.bcoin_balance}`)
}
} catch (e) {
$.logErr(e, resp)
} finally {
resolve();
}
})
})
}
/**
* 登录+5经验+1硬币
*/
function doSign(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://www.bilibili.com/',
headers: header,
}
$.get(url, async (error, response, data) => {
try {
if (error) {
console.log(`${JSON.stringify(err)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else {
log('【B站每日登录】登录成功+5经验+1硬币')
msg += '\n【B站每日登录】登录成功+5经验+1硬币'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
/**
* B站直播签到
*/
function live_sign(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign',
headers: header,
}
$.get(url, async (error, response, data) => {
try {
let result = JSON.parse(data);
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else if (result.code == 0) {
log(`【B站直播】签到成功获得${result.data.text},今天是第${result.data.hadSignDays}天完成签到`)
msg += `\n【B站直播】签到成功获得${result.data.text},今天是第${result.data.hadSignDays}天完成签到`
} else if (result.code == 1011040 && result.message == '今日已签到过,无法重复签到') {
log('【B站直播】今日已签到过,无法重复签到')
msg += '\n【B站直播】今日已签到过'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
/**
* B站漫画签到
*/
function manga_sign(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn',
headers: header,
body: 'platform=ios'
}
$.post(url, async (error, response, data) => {
try {
let result = JSON.parse(data);
if (result.msg == 'clockin clockin is duplicate') {
log('【B站漫画签到】今日已签到过,无法重复签到')
msg += '\n【B站漫画签到】今日已签到过'
} else if (result.code == 0) {
log('【B站漫画签到】签到成功')
msg += `\n【B站漫画签到】签到成功`
} else {
log(`${JSON.stringify(error)}`)
log(`${$.name} API请求失败请检查网路重试`);
msg += `\n【B站漫画签到】签到失败`
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
/**
* 分享视频
*/
function sharebv(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.bilibili.com/x/web-interface/share/add',
headers: header,
body: `bvid=${BVid}&csrf=${bili_jct}`
}
$.post(url, async (error, response, data) => {
try {
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else {
log('【每日分享视频】任务完成+5经验')
msg += '\n【每日分享视频】任务完成+5经验'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
/**
* 播放视频
*/
function playbv(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.bilibili.com/x/click-interface/web/heartbeat',
headers: header,
body: `bvid=${BVid}&csrf=${bili_jct}&played_time=2`
}
$.post(url, async (error, response, data) => {
try {
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else {
log('【每日观看视频】任务完成+5经验')
msg += '\n【每日观看视频】任务完成+5经验'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
/**
* 投币
*/
function coin_add(id) {
return new Promise((resolve) => {
var dz = getdz();
let url = {
url: 'https://api.bilibili.com/x/web-interface/coin/add',
headers: {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
'content-type': 'application/x-www-form-urlencoded',
'referer': 'https://www.bilibili.com/video/' + BVid,
'cookie': cookies
},
body: `bvid=${id}&multiply=1&select_like=${dz}&cross_domain=true&csrf=${bili_jct}`
}
$.post(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else if (result.code == 0) {
log('【每日投币】投币成功')
msg += '\n【每日投币】投币成功'
} else if (result.code == 34005) {
log('【每日投币】超过投币上限啦')
msg += '\n【每日投币】超过投币上限啦'
} else if (result.code == -104) {
log('【每日投币】硬币不足无法投币')
msg += '\n【每日投币】硬币不足无法投币'
} else {
log(result.message)
msg += `\n${result.message}`
}
} catch (e) {
log(e)
} finally {
resolve();
}
})
})
}
//随机取一个bvid
function getBvid(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.bilibili.com/x/web-interface/dynamic/region?pn=3&ps=12&rid=129',
headers: header,
}
$.get(url, async (error, response, data) => {
try {
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else {
bvid = uniq(data.match(/(BV[A-Za-z0-9]{10})/g)).slice(0, 5)
BVid = data.match(/(BV[A-Za-z0-9]{10})/)[0]
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
//查任务完成状态
function checktask(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.bilibili.com/x/member/web/exp/reward',
headers: header,
}
$.get(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else {
log(`每日登录:${result.data.login},每日观看视频:${result.data.watch},每日投币获得:${result.data.coins}/50经验每日分享视频${result.data.share}\n有延迟,一般任务完成后过一段时间才会刷新`)
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
//查金银瓜子状态
function check_live_status(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.live.bilibili.com/pay/v1/Exchange/getStatus',
headers: header,
}
$.get(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else {
log(`B站直播金瓜子数${result.data.gold},银瓜子数:${result.data.silver}`)
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
//银瓜子换硬币
function silver2coin(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://api.live.bilibili.com/xlive/revenue/v1/wallet/silver2coin',
headers: header,
body: `csrf=${bili_jct}`
}
$.post(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else if (result.message == '每天最多能兑换 1 个') {
log('【B站银瓜子换硬币】今天已经兑换过了')
msg += '\n【B站银瓜子换硬币】今天已经兑换过了'
} else if (result.message == '兑换成功') {
log(`【B站银瓜子换硬币】兑换1个硬币成功剩余银瓜子${result.data.silver}`)
msg += `\n【B站银瓜子换硬币】兑换1个硬币成功剩余银瓜子${result.data.silver}`
} else {
log('【B站银瓜子换硬币】银瓜子不够兑换失败')
msg += '\n【B站银瓜子换硬币】银瓜子不够兑换失败'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
//大会员每月领福利
function vip_privilege_receive(timeout = 3 * 1000) {
return new Promise((resolve) => {
let gift = getvipgift();
let url = {
url: 'https://api.bilibili.com/x/vip/privilege/receive',
headers: header,
body: `type=${gift}&csrf=${bili_jct}`
}
$.post(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else if (result.message == '当前非大会员') {
log('【大会员每月领福利】领取失败,当前账号不是大会员')
msg += '\n【大会员每月领福利】领取失败当前账号不是大会员'
} else if (result.code == 0) {
log(`【大会员每月领福利】兑换奖励成功`)
msg += '\n【大会员每月领福利】兑换奖励成功'
} else if (result.code == 69801) {
log('【大会员每月领福利】你已领取过该权益')
msg += '【大会员每月领福利】你已领取过该权益'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
//大会员每月领漫画阅读券
function vip_manga_reward(timeout = 3 * 1000) {
return new Promise((resolve) => {
let url = {
url: 'https://manga.bilibili.com/twirp/user.v1.User/GetVipReward',
headers: header,
body: '{"reason_id": 1}'
}
$.post(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
} else if (result.msg == '已经领取过该奖励或者未达到领取条件哦~') {
log('【大会员每月领漫画福利】已经领取过该奖励或者未达到领取条件哦~')
msg += '\n【大会员每月领漫画福利】已经领取过该奖励或者未达到领取条件哦~'
} else if (result.code == 0) {
log(`【大会员每月领漫画福利】兑换奖励成功`)
msg += '\n【大会员每月领漫画福利】兑换奖励成功'
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
//B币券给指定up主充电可充自己
function elec_pay(timeout = 3 * 1000) {
return new Promise((resolve) => {
midd = getcdid();
let url = {
url: 'http://api.bilibili.com/x/ugcpay/web/v2/trade/elec/pay/quick',
headers: header,
body: `bp_num=2&is_bp_remains_prior=true&up_mid=${midd}&otype=up&oid=${midd}&csrf=${bili_jct}`
}
$.post(url, async (error, response, data) => {
try {
let result = JSON.parse(data)
if (result.code == 88214) {
log('【用B币给up主充电】up主未开通充电')
msg += '\n【用B币给up主充电】up主未开通充电'
} else if (result.data.status == 4) {
log(`【用B币给up主充电】充值${result.data.bp_num}个B币并获得${result.data.exp}经验`)
msg += `\n【用B币给up主充电】充了${result.data.bp_num}个B币并获得${result.data.exp}经验`
} else if (result.data.status == -2 || result.data.status == -4) {
log(`【用B币给up主充电】充电失败B币少于2或者是B币数量不足`)
msg += '\n【用B币给up主充电】充电失败B币少于2或者是B币数量不足'
} else if (error) {
console.log(`${JSON.stringify(error)}`)
console.log(`${$.name} API请求失败请检查网路重试`);
}
} catch (e) {
log(e)
} finally {
resolve();
}
}, timeout)
})
}
// ============================================变量检查============================================ \\
async function Envs() {
if (bzck) {
if (bzck.indexOf("@") != -1) {
bzck.split("@").forEach((item) => {
bzckArr.push(item);
});
} else if (bzck.indexOf("\n") != -1) {
bzck.split("\n").forEach((item) => {
bzckArr.push(item);
});
} else {
bzckArr.push(bzck);
}
} else {
log(`\n${$.name}】:未填写变量 bzck`)
return;
}
return true;
}
// ============================================发送消息============================================ \\
async function SendMsg(message) {
if (!message)
return;
if (Notify > 0) {
if ($.isNode()) {
var notify = require('./sendNotify');
await notify.sendNotify($.name, message);
} else {
$.msg(message);
}
} else {
log(message);
}
}
/**
* 时间戳转日期
*/
function getLocalTime(nS) {
return new Date(parseInt(nS)).toLocaleString().replace(/:\d{1,2}$/, ' ');
}
function getcdid() {
if (typeof (mid2) == 'undefined' || mid2 == '') {
log('检测到没有填写充电up主id默认为自己充电')
return mid
} else {
log(`指定为id${mid2}充电`)
return mid2
}
}
function getdz() {
if (tbdz == 'true') {
return ('1')
} else {
return ('0')
}
}
function getvipgift() {
if (typeof (vipgift) == 'undefined' || vipgift == '') {
log('检测到没有填写大会员福利默认选择B币券')
return ('1')
} else {
log(`你选择的福利是:${vipgift}`)
return vipgift
}
}
function uniq(array) {
var temp = [];
for (var i = 0; i < array.length; i++) {
if (temp.indexOf(array[i]) == -1) {
temp.push(array[i]);
}
}
return temp;
}
/**
* 修改配置文件
*/
function modify() {
fs.readFile('/ql/data/config/config.sh', 'utf8', function (err, dataStr) {
if (err) {
return log('读取文件失败!' + err)
} else {
var result = dataStr.replace(/regular/g, string);
fs.writeFile('/ql/data/config/config.sh', result, 'utf8', function (err) {
if (err) {
return log(err);
}
});
}
})
}
function Env(t, e) {
"undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0);
class s {
constructor(t) {
this.env = t
}
send(t, e = "GET") {
t = "string" == typeof t ? {url: t} : t;
let s = this.get;
return "POST" === e && (s = this.post), new Promise((e, i) => {
s.call(this, t, (t, s, r) => {
t ? i(t) : e(s)
})
})
}
get(t) {
return this.send.call(this.env, t)
}
post(t) {
return this.send.call(this.env, t, "POST")
}
}
return new class {
constructor(t, e) {
this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `ߔ䤻this.name}, 开始!`)
}
isNode() {
return "undefined" != typeof module && !!module.exports
}
isQuanX() {
return "undefined" != typeof $task
}
isSurge() {
return "undefined" != typeof $httpClient && "undefined" == typeof $loon
}
isLoon() {
return "undefined" != typeof $loon
}
toObj(t, e = null) {
try {
return JSON.parse(t)
} catch {
return e
}
}
toStr(t, e = null) {
try {
return JSON.stringify(t)
} catch {
return e
}
}
getjson(t, e) {
let s = e;
const i = this.getdata(t);
if (i) try {
s = JSON.parse(this.getdata(t))
} catch {
}
return s
}
setjson(t, e) {
try {
return this.setdata(JSON.stringify(t), e)
} catch {
return !1
}
}
getScript(t) {
return new Promise(e => {
this.get({url: t}, (t, s, i) => e(i))
})
}
runScript(t, e) {
return new Promise(s => {
let i = this.getdata("@chavy_boxjs_userCfgs.httpapi");
i = i ? i.replace(/\n/g, "").trim() : i;
let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");
r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r;
const [o, h] = i.split("@"), n = {
url: `http://${h}/v1/scripting/evaluate`,
body: {script_text: t, mock_type: "cron", timeout: r},
headers: {"X-Key": o, Accept: "*/*"}
};
this.post(n, (t, e, i) => s(i))
}).catch(t => this.logErr(t))
}
loaddata() {
if (!this.isNode()) return {};
{
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile),
s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e);
if (!s && !i) return {};
{
const i = s ? t : e;
try {
return JSON.parse(this.fs.readFileSync(i))
} catch (t) {
return {}
}
}
}
}
writedata() {
if (this.isNode()) {
this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path");
const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile),
s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data);
s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r)
}
}
lodash_get(t, e, s) {
const i = e.replace(/\[(\d+)\]/g, ".$1").split(".");
let r = t;
for (const t of i) if (r = Object(r)[t], void 0 === r) return s;
return r
}
lodash_set(t, e, s) {
return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t)
}
getdata(t) {
let e = this.getval(t);
if (/^@/.test(t)) {
const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : "";
if (r) try {
const t = JSON.parse(r);
e = t ? this.lodash_get(t, i, "") : e
} catch (t) {
e = ""
}
}
return e
}
setdata(t, e) {
let s = !1;
if (/^@/.test(e)) {
const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i),
h = i ? "null" === o ? null : o || "{}" : "{}";
try {
const e = JSON.parse(h);
this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i)
} catch (e) {
const o = {};
this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i)
}
} else s = this.setval(t, e);
return s
}
getval(t) {
return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null
}
setval(t, e) {
return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null
}
initGotEnv(t) {
this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar))
}
get(t, e = (() => {
})) {
t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1})), $httpClient.get(t, (t, s, i) => {
!t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
})) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => {
const {statusCode: s, statusCode: i, headers: r, body: o} = t;
e(null, {status: s, statusCode: i, headers: r, body: o}, o)
}, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => {
try {
if (t.headers["set-cookie"]) {
const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();
s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar
}
} catch (t) {
this.logErr(t)
}
}).then(t => {
const {statusCode: s, statusCode: i, headers: r, body: o} = t;
e(null, {status: s, statusCode: i, headers: r, body: o}, o)
}, t => {
const {message: s, response: i} = t;
e(s, i, i && i.body)
}))
}
post(t, e = (() => {
})) {
if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, {"X-Surge-Skip-Scripting": !1})), $httpClient.post(t, (t, s, i) => {
!t && s && (s.body = i, s.statusCode = s.status), e(t, s, i)
}); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, {hints: !1})), $task.fetch(t).then(t => {
const {statusCode: s, statusCode: i, headers: r, body: o} = t;
e(null, {status: s, statusCode: i, headers: r, body: o}, o)
}, t => e(t)); else if (this.isNode()) {
this.initGotEnv(t);
const {url: s, ...i} = t;
this.got.post(s, i).then(t => {
const {statusCode: s, statusCode: i, headers: r, body: o} = t;
e(null, {status: s, statusCode: i, headers: r, body: o}, o)
}, t => {
const {message: s, response: i} = t;
e(s, i, i && i.body)
})
}
}
time(t, e = null) {
const s = e ? new Date(e) : new Date;
let i = {
"M+": s.getMonth() + 1,
"d+": s.getDate(),
"H+": s.getHours(),
"m+": s.getMinutes(),
"s+": s.getSeconds(),
"q+": Math.floor((s.getMonth() + 3) / 3),
S: s.getMilliseconds()
};
/(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length)));
for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length)));
return t
}
msg(e = t, s = "", i = "", r) {
const o = t => {
if (!t) return t;
if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? {"open-url": t} : this.isSurge() ? {url: t} : void 0;
if ("object" == typeof t) {
if (this.isLoon()) {
let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"];
return {openUrl: e, mediaUrl: s}
}
if (this.isQuanX()) {
let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl;
return {"open-url": e, "media-url": s}
}
if (this.isSurge()) {
let e = t.url || t.openUrl || t["open-url"];
return {url: e}
}
}
};
if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) {
let t = ["", "==============ߓ㧳맻懲꧟尟㣽============="];
t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t)
}
}
log(...t) {
t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator))
}
logErr(t, e) {
const s = !this.isSurge() && !this.isQuanX() && !this.isLoon();
s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t)
}
wait(t) {
return new Promise(e => setTimeout(e, t))
}
done(t = {}) {
const e = (new Date).getTime(), s = (e - this.startTime) / 1e3;
this.log("", `ߔ䤻this.name}, 结束! ߕ려{s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t)
}
}(t, e)
}

View File

@ -0,0 +1,10 @@
{
"MUSIC_COPARTNER": [
{
"cookie": "_ntes_nuid=xxx; _ns=xxx; _ntes_nnid=xxx; UM_distinctid=xxx; NMTID=xxx; WNMCID=xxx; WEVNSM=xxx; __csrf=xxx; MUSIC_U=xxx; ntes_kaola_ad=xxx; _iuqxldmzr_=xxx; JSESSIONID-WYYY=xxx;"
},
{
"cookie": "多账号 url 填写请参考上面url 以实际获取为准(遇到特殊字符如双引号\\\" 请加反斜杠转义)"
}
]
}

View File

@ -0,0 +1,184 @@
# -*- coding: utf-8 -*-
"""
cron: 0 8 * * *
new Env('网易音乐合伙人');
"""
import requests
import base64
import codecs
import execjs
import json
from Crypto.Cipher import AES
from notify import send
def to_16(key):
while len(key) % 16 != 0:
key += '\0'
return str.encode(key)
def aes_encrypt(text, key, iv):
bs = AES.block_size
pad2 = lambda s: s + (bs - len(s) % bs) * chr(bs - len(s) % bs)
encryptor = AES.new(to_16(key), AES.MODE_CBC, to_16(iv))
encrypt_aes = encryptor.encrypt(str.encode(pad2(text)))
encrypt_text = str(base64.encodebytes(encrypt_aes), encoding='utf-8')
return encrypt_text
def rsa_encrypt(text, pubKey, modulus):
text = text[::-1]
rs = int(codecs.encode(text.encode('utf-8'), 'hex_codec'), 16) ** int(pubKey, 16) % int(modulus, 16)
return format(rs, 'x').zfill(256)
# 获取i值的函数即随机生成长度为16的字符串
get_i = execjs.compile(r"""
function a(a) {
var d, e, b = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", c = "";
for (d = 0; a > d; d += 1)
e = Math.random() * b.length,
e = Math.floor(e),
c += b.charAt(e);
return c
}
""")
class Copartner():
name = "音乐合伙人"
def __init__(self, check_item):
self.csrf = None
self.musicDataUrl = "http://interface.music.163.com/api/music/partner/daily/task/get"
self.userInfoUrl = "https://music.163.com/api/nuser/account/get"
self.signUrl = "https://interface.music.163.com/weapi/music/partner/work/evaluate?csrf_token="
self.g = '0CoJUm6Qyw8W8jud' # buU9L(["爱心", "女孩", "惊恐", "大笑"])的值
self.b = "010001" # buU9L(["流泪", "强"])的值
# buU9L(Rg4k.md)的值
self.c = '00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7'
self.i = get_i.call('a', 16) # 随机生成长度为16的字符串
self.iv = "0102030405060708" # 偏移量
self.headers = {
"Accept": "application/json, text/javascript",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
"Content-Type": "application/x-www-form-urlencoded",
"Origin": "http://mp.music.163.com",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 CloudMusic/0.1.1 NeteaseMusic/8.8.01"
}
self.musicTags = "3-A-1"
self.musicScore = "3"
self.check_item = check_item
def get_enc_sec_key(self):
return rsa_encrypt(self.i, self.b, self.c)
def get_params(self, data):
enc_text = str(data)
return aes_encrypt(aes_encrypt(enc_text, self.g, self.iv), self.i, self.iv)
def sign(self, session, music_data, msg):
works = music_data['works']
task_id = music_data['id']
begin = False
for work in works:
_work = work['work']
if work['completed']:
msg.append({
"name": f"{_work['name']}{_work['authorName']}",
"value": f"评分完成:{work['score']}"
})
else:
if not begin:
msg.append({"name": "本次进度", "value": ""})
begin = True
data = {
"params": self.get_params({
"taskId": task_id,
"workId": _work['id'],
"score": self.musicScore,
"tags": self.musicTags,
"customTags": "%5B%5D",
"comment": "",
"syncYunCircle": "true",
"csrf_token": self.csrf
}).replace("\n", ""),
"encSecKey": self.get_enc_sec_key()
}
try:
response = session.post(
url=f"{self.signUrl}={self.csrf}",
data=data, headers=self.headers).json()
if response["code"] == 200:
msg.append({
"name": f"{_work['name']}{_work['authorName']}",
"value": f"评分完成:{self.musicScore}"
})
except Exception as e:
print(f"歌曲 {_work['name']} 评分异常,原因{str(e)}")
def valid(self, session):
try:
content = session.get(url=self.musicDataUrl,
headers={**self.headers, "Referer": "https://mp.music.163.com/"})
except Exception as e:
return False, f"登录验证异常,错误信息: {e}"
data = content.json()
if data["code"] == 301:
return False, data["message"]
if data["code"] == 200:
music_data = data["data"]
user_name = self.login_info(session=session)["profile"]["nickname"]
return music_data, user_name
return False, "登录信息异常"
def login_info(self, session):
try:
return session.get(url=self.userInfoUrl, headers=self.headers).json()
except Exception as e:
print(e)
return {
"profile": {
"nickname": "获取用户信息异常"
}
}
def main(self):
session = requests.session()
cookie = self.check_item.get("cookie")
music_cookie = {item.split("=")[0]: item.split("=")[1] for item in cookie.split("; ")}
self.csrf = music_cookie['__csrf']
requests.utils.add_dict_to_cookiejar(session.cookies, music_cookie)
music_data, user_name = self.valid(session)
if music_data:
completed = music_data['completed']
msg = [
{"name": "帐号信息", "value": f"{user_name}"},
{"name": "当前进度", "value": ""},
{"name": "今日完成状态", "value": f"{'已完成' if completed else '未完成'}"},
{"name": "当前获得积分", "value": music_data['integral']},
{"name": "已完成评定数", "value": music_data["completedCount"]},
]
if not completed:
self.sign(session, music_data, msg)
else:
msg = [
{"name": "帐号信息", "value": user_name},
{"name": "cookie信息", "value": "Cookie 可能过期"},
]
msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg])
return msg
if __name__ == "__main__":
with open("/ql/config/netease_music_cookie.json", "r", encoding="utf-8") as f:
all_data = json.loads(f.read())
_check_item = all_data.get("MUSIC_COPARTNER", [])
res = ""
for index, item in enumerate(_check_item):
res = f'{res}账号{index + 1}\n{Copartner(item).main()}\n'
print(res)
send('网易音乐合伙人', res)

94
wps.py Normal file
View File

@ -0,0 +1,94 @@
import os
import time
from fun import wpswx
from fun import wpspc
from fun import pu
import notify
sen=''
def SenWx():
global sen
senp=''
wps_wx = os.getenv("wps_wx")
if not wps_wx:
senp='🙃wps 微信 CK 变量未设置'
exit()
wps_wx_list = wps_wx.split('&')
senp=senp+'\n'+"-------------------总共" + str(int(len(wps_wx_list))) + "个wps_微信CK-------------------"
for mt_token in wps_wx_list:
ck = pu.convert_cookies_to_dict(mt_token)
try:
wx = wpswx.wps(ck["csrftoken"], ck["wps_sid"])
Ch = wx.GetCheck()
Da = None
IsOK = False
senp=senp+'\n'+f"👇👇👇在打卡中👇👇👇"
for i in range(1, 20):
wx.GetCode()
time.sleep(0.5)
if wx.SenSign():
time.sleep(0.5)
Da = wx.get_data()
IsOK = True
break
time.sleep(1)
senp=senp+'\n'+"昵称:" + Ch['nickname']
if IsOK:
senp=senp+'\n'+"打卡成功"
else:
senp=senp+'\n'+"打卡失败"
senp=senp+'\n'+f"我成功打卡{str(Da['total_add_day'])}"
senp=senp+'\n'+f"今日共计{Da['pool_day']}人参与"
senp=senp+'\n'+f"共计{Da['statistics']['success']}人成功,共计{Da['statistics']['fail']}人失败"
senp=senp+'\n'+f'累计人{Da["total_sign_up"]}领取奖励'
senp=senp+'\n'+f"👆👆👆打卡完毕👆👆👆\n"
except Exception as e:
senp=senp+'\n'+"出错了详细错误👇错误CK👉" + mt_token
senp=senp+'\n'+str(e)
print(senp)
sen=sen+senp
def SenPC():
global sen
senp = ''
wps_pc = os.getenv("wps_pc")
if not wps_pc:
senp='🙃wps PC CK 变量未设置'
exit()
wps_pc_list = wps_pc.split('&')
senp=senp+'\n'+"-------------------总共" + str(int(len(wps_pc_list))) + "个wps_PC CK-------------------"
for mt_token in wps_pc_list:
ck = pu.convert_cookies_to_dict(mt_token)
try:
pc = wpspc.wps(ck["wpsua"], ck["wps_sid"])
Ch = pc.GetCheck()
senp=senp+'\n'+f"👇👇👇在打卡中👇👇👇"
senp=senp+'\n'+"🎁开始👉会员时效签到👇"
senp=senp+'\n'+"昵称:" + Ch['nickname']
if pc.Signin():
senp=senp+'\n'+"打卡成功"
else:
senp=senp+'\n'+"打卡失败"
Q = pc.GetQuota() // 3600
senp=senp+'\n'+pc.Index()
senp=senp+'\n'+f"当前时间额度为{str(Q)}小时({Q//24}天)"
senp=senp+'\n'+"🎁开始👉空间签到👇"
if pc.SenSpace():
senp=senp+'\n'+"签到成功"
else:
senp=senp+'\n'+"签到失败"
senp=senp+'\n'+pc.GetSpace()
senp=senp+'\n'+f"👆👆👆打卡完毕👆👆👆\n"
except Exception as e:
senp=senp+'\n'+"出错了详细错误👇错误CK👉" + mt_token
senp=senp+'\n'+str(e)
print(senp)
sen=sen+senp
if __name__ == '__main__':
SenWx()
SenPC()
notify.send('WPS打卡',sen)