| | |
| | | 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; |
| | | |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | |
| | | @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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |