Skip to content

Commit e7e1294

Browse files
author
danbai225
committed
弹幕tag获取移除,影视推荐增加
1 parent f9dd200 commit e7e1294

28 files changed

+537
-639
lines changed

.idea/workspace.xml

Lines changed: 324 additions & 412 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/danbai/ys/config/MyWebAppConfigurer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public void addInterceptors(InterceptorRegistry registry) {
2323
@Override
2424
public void addCorsMappings(CorsRegistry registry) {
2525
registry.addMapping("/**")
26-
.allowedOrigins("http://m.dbys.vip", "file://")
26+
.allowedOrigins("http://m.dbys.vip", "https://dbys.vip")
2727
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
2828
.maxAge(3600)
2929
.allowCredentials(true);

src/main/java/com/danbai/ys/controller/MainController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ String indexApi(HttpServletRequest request) {
6868
map.put(Ysb.DSJ, ysService.qcsy(ysbs1.getList()));
6969
map.put(Ysb.ZY, ysService.qcsy(ysbs2.getList()));
7070
map.put(Ysb.DM, ysService.qcsy(ysbs3.getList()));
71+
map.put(Ysb.TJ, ysService.qcsy(ysService.tuijian()));
7172
map.put(Config.GG, adminService.getConfig(Config.GG));
7273
return JSON.toJSONString(map);
7374
}

src/main/java/com/danbai/ys/controller/YsController.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ String ys(int id, Model model, HttpServletRequest request) {
4242
Ysb ysb = ysService.selectYsById(id);
4343
model.addAttribute("ys", ysb);
4444
String tagpm = ysb.getPm() + ysb.getDy() + ysb.getLx();
45-
model.addAttribute("tagpm", tagpm.replaceAll(" ", ""));
45+
model.addAttribute("tagpm", tagpm);
4646
List<Ji> list;
4747
String kong = "[]";
4848
if (kong.equals(ysb.getGkdz())) {
@@ -172,8 +172,7 @@ String ysGetTimeApi(VideoTime videoTime) {
172172

173173
@RequestMapping(value = "/ys/gettagid", produces = "text/plain;charset=UTF-8", method = RequestMethod.GET)
174174
@ResponseBody
175-
String ysGetTagIdApi(@RequestParam(value = "pm", required = true) String pm, @RequestParam(value = "id",
176-
required = true) int id, @RequestParam(value = "ysid", required = true) String ysid) {
177-
return ysService.getYsDanMu(pm, id, ysid);
175+
String ysGetTagIdApi(@RequestParam(value = "pm", required = true) String pm,@RequestParam(value = "ysid", required = true) String ysid) {
176+
return ysService.getYsDanMu(pm, ysid);
178177
}
179178
}

src/main/java/com/danbai/ys/entity/Ysb.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class Ysb implements Serializable {
1111
public static String DSJ="dsj";
1212
public static String DM="dm";
1313
public static String ZY="zy";
14+
public static String TJ="tj";
1415
@Id
1516
@GeneratedValue(strategy = GenerationType.IDENTITY)
1617
private Integer id;

src/main/java/com/danbai/ys/mapper/ConfigMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import com.danbai.ys.entity.Config;
44
import com.danbai.ys.utils.MyMapper;
55

6+
/**
7+
* @author danbai
8+
*/
69
public interface ConfigMapper extends MyMapper<Config> {
710
/**
811
* 清空数据

src/main/java/com/danbai/ys/service/YsService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,10 @@ public interface YsService {
123123
* 获取腾讯弹幕连接
124124
*
125125
* @param pm 片名
126-
* @param jid 集id
127126
* @param ysid 弹幕id
128-
* @return
127+
* @return String
129128
*/
130-
String getYsDanMu(String pm, int jid, String ysid);
129+
String getYsDanMu(String pm, String ysid);
131130

132131
/**
133132
* 获取所有影视
@@ -141,4 +140,9 @@ public interface YsService {
141140
* @return
142141
*/
143142
List<Ysb> qcsy(List<Ysb> list);
143+
/**
144+
* 获取推荐
145+
* @return
146+
*/
147+
List<Ysb> tuijian();
144148
}

src/main/java/com/danbai/ys/service/impl/YsServiceImpl.java

Lines changed: 31 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.danbai.ys.service.impl;
22

33
import com.alibaba.fastjson.JSON;
4-
import com.alibaba.fastjson.JSONArray;
5-
import com.alibaba.fastjson.JSONObject;
64
import com.danbai.ys.entity.*;
75
import com.danbai.ys.mapper.VideoTimeMapper;
86
import com.danbai.ys.mapper.YsbMapper;
97
import com.danbai.ys.service.YsService;
108
import com.danbai.ys.utils.DateUtils;
11-
import com.danbai.ys.utils.HtmlUtils;
129
import com.github.pagehelper.PageHelper;
1310
import com.github.pagehelper.PageInfo;
1411
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,14 +16,10 @@
1916
import org.springframework.stereotype.Service;
2017
import tk.mybatis.mapper.entity.Example;
2118

22-
import java.io.UnsupportedEncodingException;
23-
import java.net.URLEncoder;
19+
import java.text.ParseException;
2420
import java.util.ArrayList;
2521
import java.util.HashMap;
2622
import java.util.List;
27-
import java.util.concurrent.*;
28-
import java.util.regex.Matcher;
29-
import java.util.regex.Pattern;
3023

3124

3225
/**
@@ -44,11 +37,10 @@ public class YsServiceImpl implements YsService {
4437
RedisTemplate redisTemplate;
4538
@Autowired
4639
MongoTemplate mongoTemplate;
47-
static String DMTYPE = "2";
48-
static String PAY_TYPE = "payType";
40+
static String NULL = "null";
4941
static String KONG = "";
5042
static int MIN_DM = 100;
51-
43+
static int MAXTJ =8;
5244
@Override
5345
public List<Ysb> page(int page, int pagenum) {
5446
PageHelper.offsetPage(page, pagenum);
@@ -212,62 +204,24 @@ public HashMap getYsLs(String username, int ysid) {
212204
}
213205

214206
@Override
215-
public String getYsDanMu(String pm, int jid, String ysid) {
216-
String rr = (String) redisTemplate.opsForValue().get(pm + jid);
217-
if (rr != null && rr.equals(KONG)) {
207+
public String getYsDanMu(String pm ,String ysid) {
208+
String rr = String.valueOf(redisTemplate.opsForValue().get(pm + ysid));
209+
if(rr==NULL){
210+
return null;
211+
}
212+
if (rr != null && !rr.equals(KONG)) {
218213
if (redisTemplate.opsForSet().isMember(OKTAGIDS, rr)) {
219214
Query query = new Query(Criteria.where("player").is(ysid));
220215
if (mongoTemplate.count(query, Dan.class) < MIN_DM) {
221-
String json = "{tagid:" + rr + ",player:\"" + ysid + "\"}";
222-
redisTemplate.opsForSet().add("tagids", json);
223216
return rr;
224217
}
225218
return null;
226219
}
220+
String json = "{tagid:" + rr + ",player:\"" + ysid + "\"}";
221+
redisTemplate.opsForSet().add("tagids", json);
227222
return rr;
228223
}
229-
String encodePm = "";
230-
try {
231-
//对片面转码
232-
encodePm = URLEncoder.encode(pm, "utf-8");
233-
} catch (UnsupportedEncodingException e) {
234-
e.printStackTrace();
235-
}
236-
//获取搜索结果
237-
String urlStr = "http://v.qq.com/x/search/?q=" + encodePm;
238-
String content = HtmlUtils.getHtmlContent(urlStr);
239-
//匹配影视id
240-
String regEx = "data-id=\"(.*?)\"";
241-
Pattern pattern = Pattern.compile(regEx);
242-
Matcher matcher = pattern.matcher(content);
243-
String str = "";
244-
if (matcher.find()) {
245-
str = matcher.group(0);
246-
}
247-
//截取id
248-
if (str == "") {
249-
return null;
250-
}
251-
String id = str.substring(9, str.length() - 1);
252-
content = HtmlUtils.getHtmlContent("http://s.video.qq.com/get_playsource?plat=2&type=4&range=1&otype=json&id" +
253-
"=" + id);
254-
String json = content.substring(13, content.length() - 1);
255-
JSONObject jsonObject = JSONObject.parseObject(json);
256-
jsonObject = jsonObject.getJSONObject("PlaylistItem");
257-
if (jsonObject == null) {
258-
return null;
259-
}
260-
//解析为数组
261-
JSONArray jsonArray = jsonObject.getJSONArray("videoPlayList");
262-
urlStr =
263-
"http://bullet.video.qq.com/fcgi-bin/target/regist?otype=json&vid=" + jsonArray.getJSONObject(jsonArray.size() - jid - 1).getString("id");
264-
content = HtmlUtils.getHtmlContent(urlStr);
265-
json = content.substring(13, content.length() - 1);
266-
jsonObject = JSONObject.parseObject(json);
267-
String tagid = jsonObject.getString("targetid");
268-
redisTemplate.opsForValue().set(pm + jid, tagid, 30, TimeUnit.DAYS);
269-
redisTemplate.opsForSet().add("tagids", "{tagid:" + tagid + ",player:\"" + ysid + "\"}");
270-
return tagid;
224+
return null;
271225
}
272226

273227
@Override
@@ -287,4 +241,23 @@ public List<Ysb> qcsy(List<Ysb> list) {
287241
}
288242
return tmp;
289243
}
244+
245+
@Override
246+
public List<Ysb> tuijian() {
247+
Example example = new Example(Ysb.class);
248+
try {
249+
example.createCriteria().andGreaterThan("gxtime",DateUtils.dateAdd(null,-30,true)).andGreaterThan("pf",8);
250+
List<Ysb> ysbs = ysbMapper.selectByExample(example);
251+
ArrayList<Ysb> rys = new ArrayList<>();
252+
for(int i=0;i<MAXTJ;i++){
253+
int j=(int)(Math.random()*(ysbs.size()-1));
254+
rys.add(ysbs.get(j));
255+
ysbs.remove(j);
256+
}
257+
return rys;
258+
} catch (ParseException e) {
259+
e.printStackTrace();
260+
}
261+
return null;
262+
}
290263
}

src/main/resources/templates/admin/config.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<title>常规设置</title>
9-
<link href="http://cdn.p00q.cn:81/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
10-
<link href="http://cdn.p00q.cn:81/hAdmin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
11-
<link href="http://cdn.p00q.cn:81/hAdmin/css/plugins/iCheck/custom.css" rel="stylesheet">
12-
<link href="http://cdn.p00q.cn:81/hAdmin/css/animate.css" rel="stylesheet">
13-
<link href="http://cdn.p00q.cn:81/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">
14-
<link href="http://cdn.p00q.cn:81/hAdmin/css/plugins/toastr/toastr.min.css" rel="stylesheet">
9+
<link href="https://cdn.p00q.cn/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
10+
<link href="https://cdn.p00q.cn/hAdmin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
11+
<link href="https://cdn.p00q.cn/hAdmin/css/plugins/iCheck/custom.css" rel="stylesheet">
12+
<link href="https://cdn.p00q.cn/hAdmin/css/animate.css" rel="stylesheet">
13+
<link href="https://cdn.p00q.cn/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">
14+
<link href="https://cdn.p00q.cn/hAdmin/css/plugins/toastr/toastr.min.css" rel="stylesheet">
1515
</head>
1616

1717
<body class="gray-bg">
@@ -401,16 +401,16 @@
401401
</div>
402402

403403
<!-- 全局js -->
404-
<script src="http://cdn.p00q.cn:81/hAdmin/js/jquery.min.js?v=2.1.4"></script>
405-
<script src="http://cdn.p00q.cn:81/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>
404+
<script src="https://cdn.p00q.cn/hAdmin/js/jquery.min.js?v=2.1.4"></script>
405+
<script src="https://cdn.p00q.cn/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>
406406

407407
<!-- 自定义js -->
408-
<script src="http://cdn.p00q.cn:81/hAdmin/js/content.js?v=1.0.0"></script>
408+
<script src="https://cdn.p00q.cn/hAdmin/js/content.js?v=1.0.0"></script>
409409

410410
<!-- iCheck -->
411-
<script src="http://cdn.p00q.cn:81/hAdmin/js/plugins/iCheck/icheck.min.js"></script>
411+
<script src="https://cdn.p00q.cn/hAdmin/js/plugins/iCheck/icheck.min.js"></script>
412412
<!-- Toastr script -->
413-
<script src="http://cdn.p00q.cn:81/hAdmin/js/plugins/toastr/toastr.min.js"></script>
413+
<script src="https://cdn.p00q.cn/hAdmin/js/plugins/toastr/toastr.min.js"></script>
414414

415415
<script>
416416

src/main/resources/templates/admin/index.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
<meta http-equiv="refresh" content="0;ie.html"/>
1414
<![endif]-->
1515

16-
<link rel="shortcut icon" href="http://cdn.p00q.cn:81/favicon.ico">
17-
<link href="http://cdn.p00q.cn:81/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
18-
<link href="http://cdn.p00q.cn:81/hAdmin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
19-
<link href="http://cdn.p00q.cn:81/hAdmin/css/animate.css" rel="stylesheet">
20-
<link href="http://cdn.p00q.cn:81/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">
16+
<link rel="shortcut icon" href="https://cdn.p00q.cn/favicon.ico">
17+
<link href="https://cdn.p00q.cn/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
18+
<link href="https://cdn.p00q.cn/hAdmin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
19+
<link href="https://cdn.p00q.cn/hAdmin/css/animate.css" rel="stylesheet">
20+
<link href="https://cdn.p00q.cn/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">
2121
</head>
2222

2323
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
@@ -86,18 +86,18 @@
8686
</div>
8787

8888
<!-- 全局js -->
89-
<script src="http://cdn.p00q.cn:81/hAdmin/js/jquery.min.js?v=2.1.4"></script>
90-
<script src="http://cdn.p00q.cn:81/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>
91-
<script src="http://cdn.p00q.cn:81/hAdmin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
92-
<script src="http://cdn.p00q.cn:81/hAdmin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
93-
<script src="http://cdn.p00q.cn:81/hAdmin/js/plugins/layer/layer.min.js"></script>
89+
<script src="https://cdn.p00q.cn/hAdmin/js/jquery.min.js?v=2.1.4"></script>
90+
<script src="https://cdn.p00q.cn/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>
91+
<script src="https://cdn.p00q.cn/hAdmin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
92+
<script src="https://cdn.p00q.cn/hAdmin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
93+
<script src="https://cdn.p00q.cn/hAdmin/js/plugins/layer/layer.min.js"></script>
9494

9595
<!-- 自定义js -->
96-
<script src="http://cdn.p00q.cn:81/hAdmin/js/hAdmin.js?v=4.1.0"></script>
97-
<script type="text/javascript" src="http://cdn.p00q.cn:81/hAdmin/js/index.js"></script>
96+
<script src="https://cdn.p00q.cn/hAdmin/js/hAdmin.js?v=4.1.0"></script>
97+
<script type="text/javascript" src="https://cdn.p00q.cn/hAdmin/js/index.js"></script>
9898

9999
<!-- 第三方插件 -->
100-
<script src="http://cdn.p00q.cn:81/hAdmin/js/plugins/pace/pace.min.js"></script>
100+
<script src="https://cdn.p00q.cn/hAdmin/js/plugins/pace/pace.min.js"></script>
101101

102102
</body>
103103

0 commit comments

Comments
 (0)