add:新增B站视频下载接口及页面

This commit is contained in:
2022-08-15 02:24:49 +08:00
parent 8160d64867
commit e19d1cdeda
4 changed files with 227 additions and 37 deletions

View File

@@ -0,0 +1,29 @@
package com.yutou.qqbot.Controllers;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.models.BiliBili.BiliVideo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class BiliBiliController {
@RequestMapping("/bilibili/down.do")
@ResponseBody
public JSONObject downloadBili(String data) {
new Thread(() -> {
JSONObject json = JSONObject.parseObject(data);
System.out.println("json = " + json);
String url = json.getString("url");
boolean downDanmu = json.containsKey("danmu") && "on".equals(json.getString("danmu"));
boolean merge = json.containsKey("merge") && "on".equals(json.getString("merge"));
BiliVideo video = new BiliVideo();
video.downVideo(url, downDanmu, merge);
}
).start();
JSONObject json = new JSONObject();
json.put("msg", "ok");
json.put("code", 0);
return json;
}
}