Browse Source

跟随上游更新

pull/15/head
余弦 2 years ago
parent
commit
c7f7df0854
  1. 2
      checksendNotify.py
  2. 64
      dailycheckin_scripts/ck_52pojie.py
  3. 188
      dailycheckin_scripts/ck_music163.py
  4. 10
      dailycheckin_scripts/ck_tieba.py

2
checksendNotify.py

@ -558,7 +558,7 @@ def send(title: str, content: str) -> None: @@ -558,7 +558,7 @@ def send(title: str, content: str) -> None:
hitokoto = push_config.get("HITOKOTO")
text = one() if hitokoto else ""
content += "\n\n" + text
content += text
ts = [
threading.Thread(target=mode, args=(title, content), name=mode.__name__)

64
dailycheckin_scripts/ck_52pojie.py

@ -1,64 +0,0 @@ @@ -1,64 +0,0 @@
# -*- coding: utf-8 -*-
"""
new Env('吾爱破解');
"""
from utils import check
import re
import requests
class Pojie:
name = "吾爱破解"
def __init__(self, check_item):
self.check_item = check_item
@staticmethod
def sign(headers):
msg = ""
try:
session = requests.session()
session.get(url="https://www.52pojie.cn/home.php?mod=task&do=apply&id=2", headers=headers)
resp = session.get(url="https://www.52pojie.cn/home.php?mod=task&do=draw&id=2", headers=headers)
content = re.findall(r'<div id="messagetext".*?\n<p>(.*?)</p>', resp.text)[0]
if "您需要先登录才能继续本操作" in resp.text:
msg += "吾爱破解 cookie 失效"
elif "安域防护节点" in resp.text:
msg += "触发吾爱破解安全防护,访问出错。自行修改脚本运行时间和次数,总有能访问到的时间"
elif "恭喜" in resp.text:
msg += "吾爱破解签到成功"
else:
msg += content
except Exception as e:
print("签到错误", e)
msg += "吾爱破解出错"
return msg
def main(self):
cookie = self.check_item.get("cookie")
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36",
"Cookie": cookie,
"ContentType": "text/html;charset=gbk",
}
try:
uid = re.findall(r"htVD_2132_lastcheckfeed=(.*?);", cookie)[0].split("%7C")[0]
except Exception as e:
print(e)
uid = "未获取到用户 uid"
sign_msg = self.sign(headers=headers)
msg = [
{"name": "帐号信息", "value": f"{uid}"},
{"name": "签到信息", "value": f"{sign_msg}"},
]
msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg])
return msg
@check(run_script_name="吾爱破解", run_script_expression="POJIE")
def main(*args, **kwargs):
return Pojie(check_item=kwargs.get("value")).main()
if __name__ == "__main__":
main()

188
dailycheckin_scripts/ck_music163.py

@ -1,188 +0,0 @@ @@ -1,188 +0,0 @@
# -*- coding: utf-8 -*-
"""
new Env('网易云音乐');
"""
from utils import check
import base64
import hashlib
import json
import os
import random
import requests
import urllib3
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import algorithms, Cipher, modes
from requests import utils
urllib3.disable_warnings()
class Music163:
name = "网易云音乐"
def __init__(self, check_item):
self.check_item = check_item
self.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
"Referer": "http://music.163.com/",
"Accept-Encoding": "gzip, deflate",
}
@staticmethod
def _encrypt(key, text):
backend = default_backend()
cipher = Cipher(algorithms.AES(key.encode("utf8")), modes.CBC(b"0102030405060708"), backend=backend)
encryptor = cipher.encryptor()
length = 16
count = len(text.encode("utf-8"))
if count % length != 0:
add = length - (count % length)
else:
add = 16
pad = chr(add)
text1 = text + (pad * add)
ciphertext = encryptor.update(text1.encode("utf-8")) + encryptor.finalize()
crypted_str = str(base64.b64encode(ciphertext), encoding="utf-8")
return crypted_str
def encrypt(self, text):
return {
"params": self._encrypt("TA3YiYCfY2dDJQgg", self._encrypt("0CoJUm6Qyw8W8jud", text)),
"encSecKey": "84ca47bca10bad09a6b04c5c927ef077d9b9f1e37098aa3eac6ea70eb59df0aa28b691b7e75e4f1f9831754919ea784c8f74fbfadf2898b0be17849fd656060162857830e241aba44991601f137624094c114ea8d17bce815b0cd4e5b8e2fbaba978c6d1d14dc3d1faf852bdd28818031ccdaaa13a6018e1024e2aae98844210",
}
def login(self, session, phone, password):
login_url = "https://music.163.com/weapi/login/cellphone"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36",
"Referer": "http://music.163.com/",
"Accept-Encoding": "gzip, deflate",
"Cookie": "os=pc; osver=Microsoft-Windows-10-Professional-build-10586-64bit; appver=2.0.3.131777; channel=netease; __remember_me=true;",
}
hl = hashlib.md5()
hl.update(password.encode(encoding="utf-8"))
md5_password = str(hl.hexdigest())
login_data = self.encrypt(
json.dumps({"phone": phone, "countrycode": "86", "password": md5_password, "rememberLogin": "true"})
)
res = session.post(url=login_url, data=login_data, headers=headers, verify=False)
ret = res.json()
if ret["code"] == 200:
csrf = requests.utils.dict_from_cookiejar(res.cookies)["__csrf"]
nickname = ret["profile"]["nickname"]
level_data = self.get_level(session=session, csrf=csrf, login_data=login_data)
level = level_data["level"]
now_play_count = level_data["nowPlayCount"]
next_play_count = level_data["nextPlayCount"]
now_login_count = level_data["nowLoginCount"]
next_login_count = level_data["nextLoginCount"]
return csrf, nickname, level, now_play_count, next_play_count, now_login_count, next_login_count
else:
return False, ret.get("message"), 0, 0, 0
def sign(self, session):
sign_url = "https://music.163.com/weapi/point/dailyTask"
res = session.post(url=sign_url, data=self.encrypt('{"type":0}'), headers=self.headers, verify=False)
ret = res.json()
if ret["code"] == 200:
return "签到成功,经验+ " + str(ret["point"])
elif ret["code"] == -2:
return "今天已经签到过了"
else:
return "签到失败: " + ret["message"]
def task(self, session, csrf):
url = "https://music.163.com/weapi/v6/playlist/detail?csrf_token=" + csrf
recommend_url = "https://music.163.com/weapi/v1/discovery/recommend/resource"
music_lists = []
res = session.post(
url=recommend_url, data=self.encrypt('{"csrf_token":"' + csrf + '"}'), headers=self.headers, verify=False
)
ret = res.json()
if ret["code"] != 200:
print("获取推荐歌曲失败: ", str(ret["code"]), ":", ret["message"])
else:
lists = ret["recommend"]
music_lists = [(d["id"]) for d in lists]
music_id = []
for m in music_lists:
res = session.post(
url=url,
data=self.encrypt(json.dumps({"id": m, "n": 1000, "csrf_token": csrf})),
headers=self.headers,
verify=False,
)
ret = json.loads(res.text)
for i in ret["playlist"]["trackIds"]:
music_id.append(i["id"])
post_data = json.dumps(
{
"logs": json.dumps(
list(
map(
lambda x: {
"action": "play",
"json": {
"download": 0,
"end": "playend",
"id": x,
"sourceId": "",
"time": 240,
"type": "song",
"wifi": 0,
},
},
random.sample(music_id, 420 if len(music_id) > 420 else len(music_id)),
)
)
)
}
)
res = session.post(url="http://music.163.com/weapi/feedback/weblog", data=self.encrypt(post_data))
ret = res.json()
if ret["code"] == 200:
return "刷听歌量成功"
else:
return "刷听歌量失败: " + ret["message"]
def get_level(self, session, csrf, login_data):
url = "https://music.163.com/weapi/user/level?csrf_token=" + csrf
res = session.post(url=url, data=login_data, headers=self.headers)
ret = json.loads(res.text)
return ret["data"]
def main(self):
phone = self.check_item.get("phone")
password = self.check_item.get("password")
session = requests.session()
csrf, nickname, level, now_play_count, next_play_count, now_login_count, next_login_count = self.login(
session=session, phone=phone, password=password
)
res_sign = ""
res_task = ""
if csrf:
res_sign = self.sign(session=session)
res_task = self.task(session=session, csrf=csrf)
msg = [
{"name": "帐号信息", "value": f"{nickname}"},
{"name": "当前等级", "value": f"{level}"},
{"name": "签到信息", "value": f"{res_sign}"},
{"name": "刷歌信息", "value": f"{res_task}"},
{"name": "当前听歌", "value": f"{now_play_count}"},
{"name": "升级听歌", "value": f"{next_play_count - now_play_count}"},
{"name": "升级天数", "value": f"{next_login_count - now_login_count}"},
]
msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg])
return msg
@check(run_script_name="网易云音乐",run_script_expression="music163")
def main(*args, **kwargs):
return Music163(check_item=kwargs.get("value")).main()
if __name__ == "__main__":
main()

10
dailycheckin_scripts/ck_tieba.py

@ -12,7 +12,7 @@ from requests import utils @@ -12,7 +12,7 @@ from requests import utils
from utils import check
class Tieba:
class Tieba():
name = "百度贴吧"
def __init__(self, check_item):
@ -24,7 +24,7 @@ class Tieba: @@ -24,7 +24,7 @@ class Tieba:
def valid(self, session):
try:
content = session.get(url="http://tieba.baidu.com/dc/common/tbs")
content = session.get(url="https://tieba.baidu.com/dc/common/tbs")
except Exception as e:
return False, f"登录验证异常,错误信息: {e}"
data = json.loads(content.text)
@ -36,7 +36,7 @@ class Tieba: @@ -36,7 +36,7 @@ class Tieba:
@staticmethod
def tieba_list_more(session):
content = session.get(url="http://tieba.baidu.com/f/like/mylike?&pn=1", timeout=(5, 20), allow_redirects=False)
content = session.get(url="https://tieba.baidu.com/f/like/mylike?&pn=1", timeout=(5, 20), allow_redirects=False)
try:
pn = int(re.match(r".*/f/like/mylike\?&pn=(.*?)\">尾页.*", content.text, re.S | re.I).group(1))
except Exception as e:
@ -49,7 +49,7 @@ class Tieba: @@ -49,7 +49,7 @@ class Tieba:
yield x
next_page += 1
content = session.get(
url=f"http://tieba.baidu.com/f/like/mylike?&pn={next_page}", timeout=(5, 20), allow_redirects=False
url=f"https://tieba.baidu.com/f/like/mylike?&pn={next_page}", timeout=(5, 20), allow_redirects=False
)
def get_tieba_list(self, session):
@ -63,7 +63,7 @@ class Tieba: @@ -63,7 +63,7 @@ class Tieba:
md5 = hashlib.md5(f"kw={tb_name}tbs={tbs}tiebaclient!!!".encode("utf-8")).hexdigest()
data = {"kw": tb_name, "tbs": tbs, "sign": md5}
try:
response = session.post(url="http://c.tieba.baidu.com/c/c/forum/sign", data=data).json()
response = session.post(url="https://c.tieba.baidu.com/c/c/forum/sign", data=data,verify=False).json()
if response["error_code"] == "0":
success_count += 1
elif response["error_code"] == "160002":

Loading…
Cancel
Save