From f788607ff771a47bc60d6a86e00b3433c40f3d2c Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 24 九月 2021 15:22:03 +0800 Subject: [PATCH] 接入视频直播 --- src/main/java/com/yeshi/buwan/job/LiveJob.java | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 101 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/job/LiveJob.java b/src/main/java/com/yeshi/buwan/job/LiveJob.java index 8441240..22f8794 100644 --- a/src/main/java/com/yeshi/buwan/job/LiveJob.java +++ b/src/main/java/com/yeshi/buwan/job/LiveJob.java @@ -4,14 +4,19 @@ import com.xxl.job.core.handler.annotation.XxlJob; import com.yeshi.buwan.domain.live.TVLiveChannel; import com.yeshi.buwan.domain.live.TVLiveChannelResourceMap; +import com.yeshi.buwan.domain.live.TVLiveProgramResource; import com.yeshi.buwan.domain.live.TVLiveResource; import com.yeshi.buwan.live.migu.MiGuLiveListInfo; import com.yeshi.buwan.live.migu.MiguLiveApiUtil; import com.yeshi.buwan.service.inter.live.MiGuLiveService; import com.yeshi.buwan.service.inter.live.TVLiveChannelResourceService; import com.yeshi.buwan.service.inter.live.TVLiveChannelService; +import com.yeshi.buwan.service.inter.live.TVLiveProgramResourceService; import com.yeshi.buwan.service.inter.system.SystemConfigService; +import com.yeshi.buwan.util.StringUtil; import com.yeshi.buwan.util.factory.live.TVLiveChannelFactory; +import com.yeshi.buwan.util.tvlive.DianShiMaoUtil; +import com.yeshi.buwan.util.tvlive.TVSOUUtil; import net.sf.json.JSONArray; import org.springframework.stereotype.Component; @@ -44,12 +49,17 @@ for (MiGuLiveListInfo info : mList) { miGuLiveService.saveChannelInfo(info); TVLiveChannel channel = TVLiveChannelFactory.create(info); - //娣诲姞鍒伴閬� - tvLiveService.save(channel); + TVLiveChannel old = tvLiveService.selectByPrimaryKey(channel.getId()); + if (old == null) { + //娣诲姞鍒伴閬� + tvLiveService.save(channel); + } else { + tvLiveService.update(channel); + } TVLiveChannelResourceMap map = new TVLiveChannelResourceMap(); map.setChannelId(channel.getId()); - map.setId(TVLiveChannelResourceMap.createId(channel.getId(), TVLiveResource.migu)); + map.setId(TVLiveChannelResourceMap.createId(channel.getId(), TVLiveResource.migu, null)); map.setResource(TVLiveResource.migu); map.setRid(info.getId()); map.setWeight(1); @@ -62,4 +72,92 @@ } + @Resource + private TVLiveProgramResourceService tvLiveProgramResourceService; + + @Resource + private TVLiveChannelService tvLiveChannelService; + + /** + * 鏇存柊鑺傜洰鍗� + * + * @param params + * @return + * @throws Exception + */ + @XxlJob("live-updateprograms") + public ReturnT<String> updatePrograms(String params) throws Exception { + updatePrograms_TVSOU(params); + return ReturnT.SUCCESS; + } + + + /** + * 鐢佃鐚� + * + * @param params + * @throws Exception + */ + public void updatePrograms_DianshiMao(String params) throws Exception { + if (StringUtil.isNullOrEmpty(params)) { + List<TVLiveProgramResource> list = tvLiveProgramResourceService.listByType(TVLiveProgramResource.TVLiveProgramResourceType.dianshimao, 1, 1000); + int count = 0; + for (TVLiveProgramResource resource : list) { + count++; + List<TVLiveChannel.TVLiveProgram> plist = DianShiMaoUtil.getProgramList(resource.getUrl()); + System.out.println(count); + Thread.sleep(1000); + if (plist != null && plist.size() > 0) { + tvLiveChannelService.savePrograms(resource.getChannelId(), plist); + } + } + } else { + //鏇存柊鍗曚釜鑺傜洰鍗� + List<TVLiveProgramResource> list = tvLiveProgramResourceService.listByChannelId(params, 1, 10); + for (TVLiveProgramResource resource : list) { + if (resource.getType() != TVLiveProgramResource.TVLiveProgramResourceType.dianshimao) + continue; + List<TVLiveChannel.TVLiveProgram> plist = DianShiMaoUtil.getProgramList(resource.getUrl()); + if (plist != null && plist.size() > 0) { + tvLiveChannelService.savePrograms(resource.getChannelId(), plist); + } + } + } + } + + + /** + * 鎼滆缃� + * + * @param params + * @throws Exception + */ + public void updatePrograms_TVSOU(String params) throws Exception { + if (StringUtil.isNullOrEmpty(params)) { + List<TVLiveProgramResource> list = tvLiveProgramResourceService.listByType(TVLiveProgramResource.TVLiveProgramResourceType.tvsou, 1, 1000); + int count = 0; + for (TVLiveProgramResource resource : list) { + count++; + List<TVLiveChannel.TVLiveProgram> plist = TVSOUUtil.getProgramList(resource.getUrl()); + System.out.println(count); + Thread.sleep(1000); + if (plist != null && plist.size() > 0) { + tvLiveChannelService.savePrograms(resource.getChannelId(), plist); + } + } + } else { + //鏇存柊鍗曚釜鑺傜洰鍗� + List<TVLiveProgramResource> list = tvLiveProgramResourceService.listByChannelId(params, 1, 10); + for (TVLiveProgramResource resource : list) { + if (resource.getType() != TVLiveProgramResource.TVLiveProgramResourceType.tvsou) + continue; + List<TVLiveChannel.TVLiveProgram> plist = TVSOUUtil.getProgramList(resource.getUrl()); + if (plist != null && plist.size() > 0) { + tvLiveChannelService.savePrograms(resource.getChannelId(), plist); + } + } + } + } + + } -- Gitblit v1.8.0