mirror of
https://github.com/daiyanan1992/qinglongtest
synced 2025-12-18 07:44:51 +08:00
增加腾讯视频每月会员红包活动
This commit is contained in:
@@ -229,7 +229,7 @@ class Iqiyi:
|
||||
self.genRedNo()
|
||||
if len(self.redNo) == 28:
|
||||
self.last_num = self.last_redNo(self.redNo)
|
||||
if self.last_num >= 0:
|
||||
if self.last_num > 0:
|
||||
self.print_now(f"您的红包码为{self.redNo}, 正在尝试提交")
|
||||
self.post_redNo()
|
||||
else:
|
||||
|
||||
259
txsp_vipRed.py
Normal file
259
txsp_vipRed.py
Normal file
@@ -0,0 +1,259 @@
|
||||
#!/usr/bin/python3
|
||||
# -- coding: utf-8 --
|
||||
# -------------------------------
|
||||
# @Author : github@limoruirui https://github.com/limoruirui
|
||||
# @Time : 22/5/2022 10:48
|
||||
# -------------------------------
|
||||
|
||||
"""
|
||||
1.腾讯视频每月领取会员天数红包 请低调使用 请不要用于商业牟利
|
||||
2.活动时间为每个月的 8号到13号 的 10点到24点
|
||||
3.活动期间内一天一次 每天限制领取两次 每个月限制次数暂时未知 请自行探索 请自行斟酌crontab
|
||||
4.cookie获取方式
|
||||
1.cookie可以用别人loon、qx等软件的mitm类自动获取再去boxjs里复制出来填写到环境变量或本脚本中
|
||||
2.也可以自行抓包 电脑或者手机都可以 抓链接为https://access.video.qq.com/user/auth_refresh?的 要整段url和对应headers下的cookie
|
||||
5.cookie食用方式: cookie和url都要整段 青龙运行可新建并分别放入到环境变量 V_COOKIE和V_REF_URL 中
|
||||
6.推荐抓取腾讯视频app端随便一条链接的headers下的user-agent 并放入环境变量 TX_UA 中 不填写会使用随机的chrome浏览器的user-agent
|
||||
7.推送支持tgbot和pushplus 会读取环境变量 青龙若之前有设置 则不需要额外设置
|
||||
"""
|
||||
from time import time, sleep
|
||||
from re import findall
|
||||
from os import environ, system
|
||||
from sys import exit, stdout
|
||||
from json import dumps, load
|
||||
from datetime import datetime
|
||||
|
||||
try:
|
||||
from requests import Session, get, post
|
||||
from fake_useragent import UserAgent
|
||||
except:
|
||||
print(
|
||||
"你还没有安装requests库和fake_useragent库 正在尝试自动安装 请在安装结束后重新执行此脚本\n若还是提示本条消息 请自行运行pip3 install requests和pip3 install fake-useragent或者在青龙的依赖管理里安装python的requests和fake-useragent")
|
||||
system("pip3 install fake-useragent")
|
||||
system("pip3 install requests")
|
||||
print("安装完成 脚本退出 请重新执行")
|
||||
exit(0)
|
||||
|
||||
|
||||
class Txsp_vipRed:
|
||||
def __init__(self):
|
||||
self.cookie = environ.get("V_COOKIE")
|
||||
self.ref_url = environ.get("V_REF_URL")
|
||||
if self.cookie == "" or self.ref_url == "":
|
||||
self.print_now("未填写腾讯V_COOKIE或者V_REF_URL")
|
||||
exit(0)
|
||||
|
||||
self.msg = ""
|
||||
self.actId = ""
|
||||
self.laisee_id = ""
|
||||
self.session = Session()
|
||||
self.ua = environ.get("TX_UA") if environ.get("TX_UA") else UserAgent().chrome
|
||||
self.own_ex = environ.get("TX_EGG_OWN") if environ.get("TX_EGG_OWN") else False
|
||||
self.headers = {
|
||||
"user-agent": self.ua
|
||||
}
|
||||
|
||||
"""推送相关"""
|
||||
self.pushplus_token = environ.get("PUSH_PLUS_TOKEN") if environ.get("PUSH_PLUS_TOKEN") else ""
|
||||
self.tgbot_token = environ.get("TG_BOT_TOKEN") if environ.get("TG_BOT_TOKEN") else ""
|
||||
self.tg_userId = environ.get("TG_USER_ID") if environ.get("TG_USER_ID") else ""
|
||||
self.tg_push_api = environ.get("TG_API_HOST") if environ.get("TG_API_HOST") else ""
|
||||
|
||||
"""工具"""
|
||||
|
||||
def pushplus(self, title, content):
|
||||
url = "http://www.pushplus.plus/send"
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
data = {
|
||||
"token": self.pushplus_token,
|
||||
"title": title,
|
||||
"content": content
|
||||
}
|
||||
try:
|
||||
post(url, headers=headers, data=dumps(data))
|
||||
except:
|
||||
self.print_now('推送失败')
|
||||
|
||||
def tgpush(self, content):
|
||||
url = f"https://api.telegram.org/bot{self.tgbot_token}/sendMessage"
|
||||
if self.tg_push_api != "":
|
||||
url = f"https://{self.tg_push_api}/bot{self.tgbot_token}/sendMessage"
|
||||
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
|
||||
data = {'chat_id': str(self.tg_userId), 'text': content, 'disable_web_page_preview': 'true'}
|
||||
try:
|
||||
post(url, headers=headers, data=data, timeout=10)
|
||||
except:
|
||||
self.print_now('推送失败')
|
||||
|
||||
def push(self, msg):
|
||||
if self.pushplus_token != "":
|
||||
self.pushplus("腾讯视频每月领取会员", msg)
|
||||
if self.tgbot_token != "" and self.tg_userId != "":
|
||||
self.tgpush(f"腾讯视频每月领取会员\n{msg}")
|
||||
|
||||
def timestamp(self, short=False):
|
||||
if (short):
|
||||
return int(time())
|
||||
return int(time() * 1000)
|
||||
|
||||
def print_now(self, content):
|
||||
print(content)
|
||||
stdout.flush()
|
||||
|
||||
"""重置cookie有效期"""
|
||||
|
||||
def refresh_cookie(self):
|
||||
headers = {
|
||||
'Referer': 'https://v.qq.com',
|
||||
"Cookie": self.cookie,
|
||||
"User-Agent": self.ua
|
||||
}
|
||||
req = self.session.get(self.ref_url, headers=headers)
|
||||
if req.headers.get("Set-Cookie") == None:
|
||||
if self.pushplus_token != "":
|
||||
self.pushplus("腾讯视频碰蛋活动", "cookie过期或填写错误")
|
||||
if self.tgbot_token != "" and self.tg_userId != "":
|
||||
self.tgpush(f"腾讯视频碰蛋活动\ncookie过期或填写错误")
|
||||
self.print_now("cookie过期或者填写错误, 退出")
|
||||
exit(0)
|
||||
# data = loads(req.text[42:-2])
|
||||
data = req.text
|
||||
# self.head = data["head"]
|
||||
# self.nickname = data["nick"]
|
||||
self.head = findall(r"\"head\":\"(.*?)\"", data)[0]
|
||||
self.nickname = findall(r"\"nick\":\"(.*?)\"", data)[0]
|
||||
|
||||
"""碰了别人的则上报别人的次数+1 用于计数别人的蛋有没有碰完 暂时未使用 后续观察情况再说"""
|
||||
|
||||
def laisee_id_success(self, laisee_id):
|
||||
url = "https://api.ruirui.fun/txsp/laisee_id_success"
|
||||
body = {
|
||||
"laisee_id": laisee_id
|
||||
}
|
||||
try:
|
||||
post(url, json=body)
|
||||
except:
|
||||
self.print_now("上报失败")
|
||||
|
||||
def get_laisee_id(self):
|
||||
url = "https://api.ruirui.fun/txsp/get_laisee_id"
|
||||
try:
|
||||
data = get(url).json()
|
||||
if data.get("msg") == "success":
|
||||
self.print_now(f"获取到的助力码为{data['data']}")
|
||||
return data["data"]
|
||||
else:
|
||||
self.print_now("从获取助力码失败,最大可能是助力池为空")
|
||||
self.msg += "本次运行没有获取到红包码, 可能是池子为空"
|
||||
return False
|
||||
except:
|
||||
self.print_now("获取助力码失败, 可能是api炸了, 也可能你的网络有问题")
|
||||
return False
|
||||
|
||||
def post_laisee_id(self, laisee_id):
|
||||
url = "https://api.ruirui.fun/txsp/post_laisee_id"
|
||||
body = {
|
||||
"laisee_id": laisee_id,
|
||||
"last_num": "1"
|
||||
}
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
try:
|
||||
data = post(url, headers=headers, json=body).json()
|
||||
if data.get("data") == "success":
|
||||
self.msg += "互助码提交成功"
|
||||
self.print_now("互助码提交成功")
|
||||
except:
|
||||
self.print_now("互助码提交失败,跳过提交,获取助力码")
|
||||
|
||||
def get_level(self):
|
||||
url = f'https://vip.video.qq.com/fcgi-bin/comm_cgi?name=payvip&cmd=1&otype=json&getannual=1&geticon=1&getsvip=1&g_tk=610014353&_={self.timestamp()}&callback=Zepto{self.timestamp()}'
|
||||
headers = {
|
||||
"referer": "https://film.qq.com/x/autovue/grade/?ptag=user.h5",
|
||||
"host": "vip.video.qq.com",
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"user-agent": self.ua}
|
||||
response = self.session.get(url=url, headers=headers)
|
||||
response.encoding = "utf-8"
|
||||
try:
|
||||
level = response.text.split('level')[1].split(',')[0].split(':')[1]
|
||||
return level
|
||||
except:
|
||||
self.print_now("获取等级信息失败, 最大可能是cookie过期或者格式不对, 也可能为网络原因")
|
||||
exit(0)
|
||||
|
||||
def getActId(self):
|
||||
url = 'https://film.qq.com/x/autovue/privilege/?pid=privilege&hidetitlebar=1&hidestatusbar=0&style=titlecolor%3D%23ffffff%26contentbkcolor%3D%23fdf6e2&aid=V0$$1:0$2:7$3:8.4.77.25550$4:0$8:4$12:&isDarkMode=0&uiType=MAX'
|
||||
headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 15_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11A465 QQLiveBrowser /8.4.55 AppType/UN WebKitCore/WKWebView iOS GDTTangramMobSDK/4.370.6 GDTMobSDK/4.370.6 cellPhone/iPad 1G'
|
||||
}
|
||||
req = self.session.get(url, headers=headers)
|
||||
req.encoding = 'utf-8'
|
||||
actId = findall(r'"laiSeeActId":"(.*?)",', req.text)[0]
|
||||
if len(actId) == 26:
|
||||
return actId
|
||||
else:
|
||||
self.msg += '活动id获取失败,请检查'
|
||||
return None
|
||||
|
||||
def gen_laisee_id(self, actId):
|
||||
url = f'https://vip.video.qq.com/rpc/trpc.vip_red_group.vip_red_qualification.VipRedQualification/RedQualificationSend?rpc_data=%7B%22act_id%22:%22{actId}%22%7D'
|
||||
headers = {
|
||||
'User-Agent': self.ua,
|
||||
'Referer': 'https://film.qq.com/x/autovue/privilege/route/homepage/take?pid=privilege&hidetitlebar=1&hidestatusbar=0&style=titlecolor%3D%23ffffff%26contentbkcolor%3D%23fdf6e2&aid=V0%24%241%3A0%242%3A7%243%3A8.4.77.25550%244%3A0%248%3A4%2412%3A&isDarkMode=0&uiType=MAX'
|
||||
}
|
||||
data = self.session.get(url, headers=headers).json()
|
||||
order_id = data['orderid']
|
||||
url2 = f'https://vip.video.qq.com/fcgi-bin/comm_cgi?callback=jQuery31008352113707502279_1636423447311&name=spp_vipred_route_write&cmd=1&head=https%3A%2F%2Ftvpic.gtimg.cn%2Fhead%2F053408c7084bcafd5d98078c89e38c6cc1d29fd1176fb3a8bd6b04d4e2d97f911f20c441%2F369&nick=(*%40%CE%BF%40*)%20%E5%93%87&order_id={order_id}&_={self.timestamp()}'
|
||||
data = get(url2, headers=headers).text
|
||||
self.print_now(data)
|
||||
self.laisee_id = findall(r'"laisee_id":"(.*?)",', data)[0]
|
||||
if self.laisee_id != "":
|
||||
self.msg += (f"腾讯视频红包分享链接",
|
||||
f"https://m.film.qq.com/magic-act/{actId}/1_index_index.html?ptag=redshare&redenvelopeId={self.laisee_id}&ovscroll=0&page=index 点击链接领取几天腾讯视频会员")
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def receive(self, laisee_id):
|
||||
url = f'https://vip.video.qq.com/fcgi-bin/comm_cgi?name=spp_vipred_route_write&cmd=2&laisee_id={laisee_id}&nick={self.nickname}&head={self.head}&act_id={self.actId}&otype=xjson&_ts={self.timestamp()}'
|
||||
headers = {
|
||||
'Origin': 'https://m.film.qq.com',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Host': 'vip.video.qq.com',
|
||||
'User-Agent': self.ua,
|
||||
'Referer': f'https://m.film.qq.com/magic-act/{self.actId}/index_index.html?ovscroll=0&page=index&isDarkMode=0&uiType=MAX'
|
||||
}
|
||||
data = self.session.get(url, headers=headers).text
|
||||
self.print_now(data)
|
||||
sleep(1)
|
||||
|
||||
def main(self):
|
||||
today = datetime.today().day
|
||||
hour = datetime.today().hour
|
||||
if today < 8 or today > 13 or hour < 10:
|
||||
self.print_now("当前不在活动时间 活动时间为每个月的8号到13号的10点到24点")
|
||||
exit(0)
|
||||
self.refresh_cookie()
|
||||
self.actId = self.getActId()
|
||||
if self.actId is None:
|
||||
self.print_now(self.msg)
|
||||
self.push(self.msg)
|
||||
exit(0)
|
||||
if int(self.get_level()) >= 6:
|
||||
self.print_now("您当前账号大于等于6级, 领取红包码并分享")
|
||||
if self.gen_laisee_id(self.actId):
|
||||
self.post_laisee_id(self.laisee_id)
|
||||
laisee_id_list = self.get_laisee_id()
|
||||
if laisee_id_list:
|
||||
self.print_now(f"本次获取到的红包码为\n{laisee_id_list}")
|
||||
for laisee_id in laisee_id_list:
|
||||
self.receive(laisee_id)
|
||||
self.push(self.msg)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Txsp_vipRed().main()
|
||||
Reference in New Issue
Block a user