Skip to content

Commit c425482

Browse files
author
danbai225
committed
直播功能
1 parent 4a2d68d commit c425482

30 files changed

+944
-446
lines changed

.idea/workspace.xml

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

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
+ 观看看影视的同时能发送弹幕
1818
+ 跨平台同步观看历史记录
1919
+ 跨平台同步观看进度
20-
+ 电视直播(开发中)
20+
+ 电视直播
21+
2122
## 项目所用到的
2223

2324
+ Spring Boot
@@ -27,15 +28,22 @@
2728
+ Docker
2829
## 版本内容更新
2930
### 2019-10-20
31+
3032
+ 弹幕获取功能,不用担心一个人看没弹幕啦,在一些人气较高的影视会自动获取弹幕
3133
+ 修复注册邮箱发送问题
34+
3235
### 2019-11-4
36+
3337
+ 更新搜索功能支持演员、导演搜索影视
3438
+ 弹幕tagid获取将不在服务器而是py采集
3539
+ 影视信息补全
3640
+ 配置功能
37-
## 计划开发功能
41+
### 2019-11-6
42+
3843
+ 电视直播功能
44+
45+
## 计划开发功能
46+
3947
+ 影视增加评论、评分功能
4048
+ 弹幕管理
4149
+ 淡白影视APP(开发中)

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
<groupId>org.springframework.boot</groupId>
8484
<artifactId>spring-boot-starter-data-mongodb</artifactId>
8585
</dependency>
86+
<dependency>
87+
<groupId>org.springframework.boot</groupId>
88+
<artifactId>spring-boot-starter-websocket</artifactId>
89+
</dependency>
8690
</dependencies>
8791
<build>
8892
<plugins>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.danbai.ys.async;
2+
3+
import com.danbai.ys.websocket.TvDmSocket;
4+
import org.springframework.scheduling.annotation.Async;
5+
import org.springframework.stereotype.Component;
6+
7+
import java.io.IOException;
8+
9+
/**
10+
* @author danbai
11+
* @date 2019-11-04 21:36
12+
*/
13+
@Component
14+
public class AsyncDmAllSend {
15+
/**
16+
* 群发自定义消息
17+
* */
18+
@Async
19+
public void sendInfo(String message) throws IOException {
20+
for (TvDmSocket item : TvDmSocket.webSocketSet) {
21+
try {
22+
item.sendMessage(message);
23+
} catch (IOException e) {
24+
continue;
25+
}
26+
}
27+
}
28+
@Async
29+
public void sendInfo(String message,String dmid) throws IOException {
30+
for (TvDmSocket item : TvDmSocket.webSocketSet) {
31+
if(item.getDmid().equals(dmid)){
32+
try {
33+
item.sendMessage(message);
34+
} catch (IOException e) {
35+
continue;
36+
}
37+
}
38+
}
39+
}
40+
@Async
41+
public void sendInfoNothis(String message,String dmid,TvDmSocket t) throws IOException {
42+
for (TvDmSocket item : TvDmSocket.webSocketSet) {
43+
if(item.getDmid().equals(dmid)&item!=t){
44+
try {
45+
item.sendMessage(message);
46+
} catch (IOException e) {
47+
continue;
48+
}
49+
}
50+
}
51+
}
52+
}

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", "https://dbys.vip")
26+
.allowedOrigins("http://m.dbys.vip", "https://dbys.vip","null")
2727
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
2828
.maxAge(3600)
2929
.allowCredentials(true);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.danbai.ys.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.scheduling.TaskScheduler;
6+
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
7+
8+
/**
9+
* @author danbai
10+
* @date 2019-11-04 20:41
11+
*/
12+
@Configuration
13+
public class ScheduledConfig {
14+
@Bean
15+
public TaskScheduler taskScheduler(){
16+
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
17+
taskScheduler.setPoolSize(20);
18+
taskScheduler.initialize();
19+
return taskScheduler;
20+
}
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.danbai.ys.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
6+
7+
/**
8+
* @author danbai
9+
* @date 2019-11-04 21:06
10+
*/
11+
@Configuration
12+
public class WebsocketAutoConfig {
13+
@Bean
14+
public ServerEndpointExporter endpointExporter() {
15+
return new ServerEndpointExporter();
16+
}
17+
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,26 @@
33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.JSONObject;
55
import com.danbai.ys.entity.*;
6+
import com.danbai.ys.service.YsService;
67
import com.danbai.ys.service.impl.AdminServiceImpl;
78
import com.danbai.ys.service.impl.YsServiceImpl;
9+
import com.danbai.ys.utils.HtmlUtils;
810
import com.github.pagehelper.PageInfo;
911
import org.springframework.beans.factory.annotation.Autowired;
1012
import org.springframework.data.redis.core.RedisTemplate;
13+
import org.springframework.http.HttpHeaders;
14+
import org.springframework.http.HttpStatus;
15+
import org.springframework.http.MediaType;
16+
import org.springframework.http.ResponseEntity;
1117
import org.springframework.stereotype.Controller;
1218
import org.springframework.ui.Model;
1319
import org.springframework.web.bind.annotation.*;
1420

1521
import javax.servlet.http.HttpServletRequest;
22+
import javax.servlet.http.HttpServletResponse;
23+
import java.io.FileInputStream;
24+
import java.io.IOException;
25+
import java.io.OutputStream;
1626
import java.util.HashMap;
1727
import java.util.List;
1828
import java.util.Map;
@@ -118,7 +128,11 @@ String dsj(int page, Model model) {
118128
model.addAttribute("page", page);
119129
return "type/dsj";
120130
}
121-
131+
@RequestMapping(value = "/type/tv", produces = "text/plain;charset=UTF-8", method = RequestMethod.GET)
132+
String dsj(Model model) {
133+
model.addAttribute("tvs",ysService.getAllTv());
134+
return "type/tv";
135+
}
122136
@RequestMapping(value = "/type/dm", produces = "text/plain;charset=UTF-8", method = RequestMethod.GET)
123137
String dm(int page, Model model) {
124138
PageInfo page1 = ysService.getYs("动漫", page, 24);

src/main/java/com/danbai/ys/controller/restful/v1/Ys.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public BaseResult ys() {
3131

3232
/**
3333
* 根据id获取影视
34-
*
3534
* @param id 影视id
3635
* @return BaseResult
3736
*/
@@ -50,5 +49,8 @@ public BaseResult ysOne(@PathVariable int id) {
5049
public BaseResult search(@PathVariable String gjc) {
5150
return ResultUtil.success(ysService.qcsy(ysService.selectYsByGjc(gjc)));
5251
}
53-
52+
@GetMapping("/ys/tv")
53+
public BaseResult tv(){
54+
return ResultUtil.success(ysService.getAllTv());
55+
}
5456
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.danbai.ys.entity;
22

3-
/**
3+
/**统计类
44
* @author danbai
55
* @date 2019-10-18 12:30
66
*/

0 commit comments

Comments
 (0)