Skip to content

Commit

Permalink
修改 抖音解析已经支持GET请求
Browse files Browse the repository at this point in the history
  • Loading branch information
VarleyT committed Nov 16, 2022
1 parent 9298819 commit 6729715
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
22 changes: 13 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

## 功能

- 登录
- 登出
- 签到
- 注册(需验证码)
- 时间限制
- 登录限制
- 抖音解析
- 原神抽卡分析
- Epic每周白嫖
### 系统功能

- 登录 [POST]
- 登出 [GET]
- 签到 [GET]
- 注册(需验证码) [POST]

### 娱乐功能

- 抖音解析 [GET POST]
- 原神抽卡分析 [POST]
- Epic每周白嫖 [GET]

## TODO

> ~~大饼绘制区~~
- [x] Epic每周白嫖
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,51 @@
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Map;

/**
* @author VarleyT
* @date 2022/9/11
*/
@Slf4j
@RestController
@RequestMapping(value = "/API")
@RequestMapping(value = {"/API", "/api"})
public class ApiController {
/**
* 抖音视频解析
*
* @param url
* @param getUrl
* @param map
* @param response
* @return
*/
@LimitRequest
@PostMapping("/douyin")
public R<DouYin> douyin(@RequestBody @NotEmpty String url, HttpServletResponse response) {
@RequestMapping(value = "/douyin", method = {RequestMethod.GET, RequestMethod.POST})
public R<DouYin> douyin(@RequestParam(name = "url", required = false) String getUrl,
@RequestBody(required = false) Map<String, String> map,
HttpServletResponse response) {
log.info("getUrl: {}", getUrl);
log.info("map: {}", map);
final String REGEX = "https://v\\.douyin\\.com/\\w{7}/";
List<String> list = ReUtil.findAll(REGEX, url, 0);
if (list.isEmpty()) {
log.info("不是一个正确的链接:" + url);
List<String> list = null;
if (getUrl != null && getUrl.length() > 0) {
list = ReUtil.findAll(REGEX, getUrl, 0);
} else {
if (map != null && map.size() != 0) {
if (map.containsKey("url")) {
String url = map.get("url");
list = ReUtil.findAll(REGEX, url, 0);
}
} else {
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
return R.error("缺少请求参数!");
}
}
if (list != null && list.isEmpty()) {
log.info("不是一个正确的链接:getUrl: {}, map: {}", getUrl, map);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
return R.error("请输入正确的链接");
return R.error("错误的抖音链接!请检查链接是否正确或者是否包含(#、&)");
}
String originalUrl = list.get(0);
DouYin douyin = DouYinParse.parse(originalUrl);
Expand Down

0 comments on commit 6729715

Please sign in to comment.