Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d4b8e58946 | |||
22416227d8 | |||
1705f4d752 | |||
af18663759 |
@ -3,4 +3,7 @@ package com.yutou.bilibili.api;
|
|||||||
public class VideoApi {
|
public class VideoApi {
|
||||||
|
|
||||||
public static final String VIDEO_AI = "https://api.bilibili.com/x/web-interface/view/conclusion/get";
|
public static final String VIDEO_AI = "https://api.bilibili.com/x/web-interface/view/conclusion/get";
|
||||||
|
@Deprecated
|
||||||
|
public static final String VIDEO_PLAY_URL = "https://api.bilibili.com/x/player/playurl";
|
||||||
|
public static final String VIDEO_PLAY_URL_V2 = "https://api.bilibili.com/x/player/wbi/playurl";
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.yutou.qqbot;
|
|||||||
|
|
||||||
import com.yutou.qqbot.utlis.AppTools;
|
import com.yutou.qqbot.utlis.AppTools;
|
||||||
import com.yutou.qqbot.utlis.RedisTools;
|
import com.yutou.qqbot.utlis.RedisTools;
|
||||||
|
import net.mamoe.mirai.Bot;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -33,4 +34,16 @@ public class QQBotController {
|
|||||||
AppTools.sendServer(title, msg);
|
AppTools.sendServer(title, msg);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/bot/test.do")
|
||||||
|
public String testLogin(){
|
||||||
|
Bot bot = QQBotManager.getInstance().getBot();
|
||||||
|
return bot.isOnline()+"";
|
||||||
|
}
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/bot/login.do")
|
||||||
|
public String login(){
|
||||||
|
QQBotManager.getInstance().reLogin();
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.yutou.qqbot.Listeners.QQMessageListener;
|
|||||||
import com.yutou.qqbot.utlis.*;
|
import com.yutou.qqbot.utlis.*;
|
||||||
import net.mamoe.mirai.Bot;
|
import net.mamoe.mirai.Bot;
|
||||||
import net.mamoe.mirai.BotFactory;
|
import net.mamoe.mirai.BotFactory;
|
||||||
import net.mamoe.mirai.auth.BotAuthorization;
|
|
||||||
import net.mamoe.mirai.event.GlobalEventChannel;
|
import net.mamoe.mirai.event.GlobalEventChannel;
|
||||||
import net.mamoe.mirai.message.MessageReceipt;
|
import net.mamoe.mirai.message.MessageReceipt;
|
||||||
import net.mamoe.mirai.message.data.*;
|
import net.mamoe.mirai.message.data.*;
|
||||||
@ -55,7 +54,11 @@ public class QQBotManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String test = HttpTools.get("http://192.168.31.88:7400/");
|
String url=ConfigTools.load(ConfigTools.CONFIG,"sign_url",String.class);
|
||||||
|
if(StringUtils.isEmpty(url)){
|
||||||
|
url="http://192.168.31.88:7400/";
|
||||||
|
}
|
||||||
|
String test = HttpTools.get(url);
|
||||||
try {
|
try {
|
||||||
JSONObject json = JSONObject.parseObject(test);
|
JSONObject json = JSONObject.parseObject(test);
|
||||||
if (json.getInteger("code") != 0) {
|
if (json.getInteger("code") != 0) {
|
||||||
@ -101,7 +104,6 @@ public class QQBotManager {
|
|||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
bot.join();
|
bot.join();
|
||||||
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
@ -266,4 +268,12 @@ public class QQBotManager {
|
|||||||
public Bot getBot() {
|
public Bot getBot() {
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reLogin() {
|
||||||
|
isInit=false;
|
||||||
|
if(bot.isOnline()){
|
||||||
|
bot.close();
|
||||||
|
}
|
||||||
|
init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,56 +13,61 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class QQNumberManager {
|
public class QQNumberManager {
|
||||||
private static QQNumberManager manager;
|
private static QQNumberManager manager;
|
||||||
private QQNumberManager(){
|
|
||||||
|
private QQNumberManager() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QQNumberManager getManager() {
|
public static QQNumberManager getManager() {
|
||||||
if(manager==null) {
|
if (manager == null) {
|
||||||
manager=new QQNumberManager();
|
manager = new QQNumberManager();
|
||||||
}
|
}
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
public void addNumber(Long qq,boolean isGroup){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public void addNumber(Long qq, boolean isGroup) {
|
||||||
|
if (RedisTools.exists(qq, null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("group",isGroup);
|
json.put("group", isGroup);
|
||||||
json.put("power",new JSONArray());
|
json.put("power", new JSONArray());
|
||||||
json.put("model",new JSONArray());
|
json.put("model", new JSONArray());
|
||||||
RedisTools.set(qq,json.toJSONString());
|
RedisTools.set(qq, json.toJSONString());
|
||||||
}
|
}
|
||||||
public List<Long> getNumber(){
|
|
||||||
List<Long> list =new ArrayList<>();
|
public List<Long> getNumber() {
|
||||||
Jedis jedis=RedisTools.getRedis();
|
List<Long> list = new ArrayList<>();
|
||||||
|
Jedis jedis = RedisTools.getRedis();
|
||||||
jedis.select(RedisTools.QQBOT_USER);
|
jedis.select(RedisTools.QQBOT_USER);
|
||||||
Set<String> set=jedis.keys("*");
|
Set<String> set = jedis.keys("*");
|
||||||
for (String s : set) {
|
for (String s : set) {
|
||||||
try {
|
try {
|
||||||
list.add(Long.parseLong(s));
|
list.add(Long.parseLong(s));
|
||||||
}catch (Exception ignored){
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jedis.close();
|
jedis.close();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public boolean addPower(Long qq, String power){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public boolean addPower(Long qq, String power) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONArray array=json.getJSONArray("power");
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
|
JSONArray array = json.getJSONArray("power");
|
||||||
array.add(power);
|
array.add(power);
|
||||||
json.put("power",array);
|
json.put("power", array);
|
||||||
return RedisTools.set(qq,json.toJSONString());
|
return RedisTools.set(qq, json.toJSONString());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public List<String> getPower(Long qq){
|
|
||||||
List<String> list=new ArrayList<>();
|
public List<String> getPower(Long qq) {
|
||||||
if(RedisTools.exists(qq,null)){
|
List<String> list = new ArrayList<>();
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONArray array=json.getJSONArray("power");
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
|
JSONArray array = json.getJSONArray("power");
|
||||||
for (Object power : array) {
|
for (Object power : array) {
|
||||||
list.add((String) power);
|
list.add((String) power);
|
||||||
}
|
}
|
||||||
@ -70,11 +75,12 @@ public class QQNumberManager {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUseModel(long qq) {
|
public List<String> getUseModel(long qq) {
|
||||||
List<String> list=new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
if(RedisTools.exists(qq,null)){
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
JSONArray array=json.getJSONArray("model");
|
JSONArray array = json.getJSONArray("model");
|
||||||
for (Object power : array) {
|
for (Object power : array) {
|
||||||
list.add((String) power);
|
list.add((String) power);
|
||||||
}
|
}
|
||||||
@ -82,43 +88,47 @@ public class QQNumberManager {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
public boolean delPower(Long qq, String power){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public boolean delPower(Long qq, String power) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONArray array=json.getJSONArray("power");
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
|
JSONArray array = json.getJSONArray("power");
|
||||||
array.remove(power);
|
array.remove(power);
|
||||||
json.put("power",array);
|
json.put("power", array);
|
||||||
return RedisTools.set(qq,json.toJSONString());
|
return RedisTools.set(qq, json.toJSONString());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean addUseModel(Long qq,Class<?> modelClass){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public boolean addUseModel(Long qq, Class<?> modelClass) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONArray array=json.getJSONArray("model");
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
|
JSONArray array = json.getJSONArray("model");
|
||||||
array.add(modelClass.getName());
|
array.add(modelClass.getName());
|
||||||
json.put("model",array);
|
json.put("model", array);
|
||||||
return RedisTools.set(qq,json.toJSONString());
|
return RedisTools.set(qq, json.toJSONString());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean delUseModel(Long qq,Class<?> modelClass){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public boolean delUseModel(Long qq, Class<?> modelClass) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONArray array=json.getJSONArray("model");
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
|
JSONArray array = json.getJSONArray("model");
|
||||||
array.remove(modelClass.getName());
|
array.remove(modelClass.getName());
|
||||||
json.put("model",array);
|
json.put("model", array);
|
||||||
return RedisTools.set(qq,json.toJSONString());
|
return RedisTools.set(qq, json.toJSONString());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean isExistsPower(Long qq, String... power){
|
|
||||||
|
public boolean isExistsPower(Long qq, String... power) {
|
||||||
//1
|
//1
|
||||||
if(RedisTools.exists(qq,null)){
|
if (RedisTools.exists(qq, null)) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
JSONArray array=json.getJSONArray("power");
|
JSONArray array = json.getJSONArray("power");
|
||||||
for (String key : power) {
|
for (String key : power) {
|
||||||
if(!array.contains(key)){
|
if (!array.contains(key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,19 +136,26 @@ public class QQNumberManager {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean isGroup(Long qq){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public boolean isGroup(Long qq) {
|
||||||
JSONObject json= JSON.parseObject(RedisTools.get(qq));
|
if (RedisTools.exists(qq, null)) {
|
||||||
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
return json.getBooleanValue("group");
|
return json.getBooleanValue("group");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public boolean isUseModel(Long qq,Class<?> modelClass){
|
|
||||||
if(RedisTools.exists(qq,null)){
|
public boolean isUseModel(Long qq, Class<?> modelClass) {
|
||||||
JSONObject json=JSON.parseObject(RedisTools.get(qq));
|
try {
|
||||||
JSONArray array=json.getJSONArray("model");
|
if (RedisTools.exists(qq, null)) {
|
||||||
|
JSONObject json = JSON.parseObject(RedisTools.get(qq));
|
||||||
|
JSONArray array = json.getJSONArray("model");
|
||||||
return array.contains(modelClass.getName());
|
return array.contains(modelClass.getName());
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.i("isUseModel", qq + " " + modelClass.getName());
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.yutou.qqbot.models.BiliBili;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSONArray;
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.yutou.bilibili.api.VideoApi;
|
||||||
import com.yutou.qqbot.Annotations.UseModel;
|
import com.yutou.qqbot.Annotations.UseModel;
|
||||||
import com.yutou.qqbot.QQBotManager;
|
import com.yutou.qqbot.QQBotManager;
|
||||||
import com.yutou.qqbot.QQNumberManager;
|
import com.yutou.qqbot.QQNumberManager;
|
||||||
@ -158,7 +159,7 @@ public class BiliVideo extends Model {
|
|||||||
json.put("avid", infoData.getLong("aid"));
|
json.put("avid", infoData.getLong("aid"));
|
||||||
if (eps.containsKey("cid")) {
|
if (eps.containsKey("cid")) {
|
||||||
json.put("cid", eps.getLong("cid"));
|
json.put("cid", eps.getLong("cid"));
|
||||||
json.put("qn", 127);
|
json.put("qn", 125);
|
||||||
json.put("fnval", 80);
|
json.put("fnval", 80);
|
||||||
json.put("fourk", 1);
|
json.put("fourk", 1);
|
||||||
downVideo(json, eps);
|
downVideo(json, eps);
|
||||||
@ -172,7 +173,7 @@ public class BiliVideo extends Model {
|
|||||||
JSONObject item = (JSONObject) o;
|
JSONObject item = (JSONObject) o;
|
||||||
json.put("avid", item.getLong("aid"));
|
json.put("avid", item.getLong("aid"));
|
||||||
json.put("cid", item.getLong("cid"));
|
json.put("cid", item.getLong("cid"));
|
||||||
json.put("qn", 127);
|
json.put("qn", 125);
|
||||||
json.put("fnval", 80);
|
json.put("fnval", 80);
|
||||||
json.put("fourk", 1);
|
json.put("fourk", 1);
|
||||||
item.put("title", eps.getString("title") + "$(File.separator)" + item.getString("title"));
|
item.put("title", eps.getString("title") + "$(File.separator)" + item.getString("title"));
|
||||||
@ -259,7 +260,8 @@ public class BiliVideo extends Model {
|
|||||||
if (tmp.exists()) {
|
if (tmp.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject http = biliUtils.http("https://api.bilibili.com/x/player/playurl?" + HttpTools.toUrlParams(json), BiliBiliUtils.HTTP.GET, null, BiliBiliUtils.RET_MODEL.JSON);
|
TreeMap<String,String> body=BiliBiliWbiSign.getWbiSign(json);
|
||||||
|
JSONObject http = biliUtils.http(VideoApi.VIDEO_PLAY_URL_V2+"?" + HttpTools.toUrlParams(body), BiliBiliUtils.HTTP.GET, null, BiliBiliUtils.RET_MODEL.JSON);
|
||||||
if (http.getInteger("code") == 0) {
|
if (http.getInteger("code") == 0) {
|
||||||
JSONObject data = http.getJSONObject("data");
|
JSONObject data = http.getJSONObject("data");
|
||||||
JSONObject dash = data.getJSONObject("dash");
|
JSONObject dash = data.getJSONObject("dash");
|
||||||
@ -399,14 +401,12 @@ public class BiliVideo extends Model {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
BiliVideo video = new BiliVideo(QQBotManager.defQQ);
|
BiliVideo video = new BiliVideo(QQBotManager.defQQ);
|
||||||
JSONObject login = new BiliLogin(QQBotManager.defQQ).login();
|
|
||||||
System.out.println(login);
|
|
||||||
//岚少 480
|
//岚少 480
|
||||||
//video.downVideo("https://www.bilibili.com/video/BV1Ps411m7pt?spm_id_from=333.999.0.0");
|
//video.downVideo("https://www.bilibili.com/video/BV1Ps411m7pt?spm_id_from=333.999.0.0");
|
||||||
//唐诱 合集
|
//唐诱 合集
|
||||||
//video.downVideo("https://www.bilibili.com/video/BV1Vv4y1K7ox?spm_id_from=444.41.top_right_bar_window_default_collection.content.click");
|
//video.downVideo("https://www.bilibili.com/video/BV1Vv4y1K7ox?spm_id_from=444.41.top_right_bar_window_default_collection.content.click");
|
||||||
//邦邦 长视频
|
//邦邦 长视频
|
||||||
// video.downVideo("https://www.bilibili.com/video/BV1w5411271A?spm_id_from=444.41.list.card_archive.click");
|
video.downVideo("https://www.bilibili.com/video/BV1w5411271A?spm_id_from=444.41.list.card_archive.click");
|
||||||
//LK 超清4k hdr
|
//LK 超清4k hdr
|
||||||
//video.downVideo("https://www.bilibili.com/video/BV1uZ4y1U7h8/?spm_id_from=333.788.recommend_more_video.-1");
|
//video.downVideo("https://www.bilibili.com/video/BV1uZ4y1U7h8/?spm_id_from=333.788.recommend_more_video.-1");
|
||||||
// hdr
|
// hdr
|
||||||
@ -423,7 +423,7 @@ public class BiliVideo extends Model {
|
|||||||
// int a=16|2048;
|
// int a=16|2048;
|
||||||
// System.out.println("a = " + a);
|
// System.out.println("a = " + a);
|
||||||
//video.downDanmu(428855000L,976216102L,"【都市_情感】《唐可可的诱惑》第一集",1);
|
//video.downDanmu(428855000L,976216102L,"【都市_情感】《唐可可的诱惑》第一集",1);
|
||||||
video.downVideo("https://www.bilibili.com/bangumi/play/ep776259", false, false);// ep5
|
//video.downVideo("https://www.bilibili.com/bangumi/play/ep776259", false, false);// ep5
|
||||||
System.out.println("事件结束");
|
System.out.println("事件结束");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,13 @@ public class BiliBiliWbiSign {
|
|||||||
body.put("w_rid", AppTools.getMD5(params + genMixinKey(rawWbiKey)));
|
body.put("w_rid", AppTools.getMD5(params + genMixinKey(rawWbiKey)));
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
public static TreeMap<String, String> getWbiSign(JSONObject json) {
|
||||||
|
TreeMap<String, String> body=new TreeMap<>();
|
||||||
|
for (String key : json.keySet()) {
|
||||||
|
body.put(key, json.getString(key));
|
||||||
|
}
|
||||||
|
return getWbiSign(body);
|
||||||
|
}
|
||||||
private static String genMixinKey(String rawWbiKey) {
|
private static String genMixinKey(String rawWbiKey) {
|
||||||
byte[] rawBytes = rawWbiKey.getBytes(StandardCharsets.UTF_8);
|
byte[] rawBytes = rawWbiKey.getBytes(StandardCharsets.UTF_8);
|
||||||
byte[] mixinKey = new byte[32];
|
byte[] mixinKey = new byte[32];
|
||||||
@ -71,4 +77,6 @@ public class BiliBiliWbiSign {
|
|||||||
//https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=BV1L94y1H7CV&cid=1335073288&up_mid=297242063&web_location=333.788&w_rid=a5d90f60ac6b6b6fc9d49be3ba3fee53&wts=1705394671
|
//https://api.bilibili.com/x/web-interface/view/conclusion/get?bvid=BV1L94y1H7CV&cid=1335073288&up_mid=297242063&web_location=333.788&w_rid=a5d90f60ac6b6b6fc9d49be3ba3fee53&wts=1705394671
|
||||||
//updateRawWbiKey();
|
//updateRawWbiKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user