| | |
| | | import com.yeshi.buwan.exception.vip.VIPException; |
| | | import com.yeshi.buwan.funtv.FunTVUtil; |
| | | import com.yeshi.buwan.service.imp.DetailSystemConfigService; |
| | | import com.yeshi.buwan.service.imp.SearchService; |
| | | import com.yeshi.buwan.service.inter.vip.VIPService; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | |
| | | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @Resource |
| | | private SearchService searchService; |
| | | |
| | | Logger logger = LoggerFactory.getLogger(TestController.class); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("searchAlbum") |
| | | public void searchAlbum(String key, PrintWriter out) { |
| | | SearchService.SearchResult result = searchService.searchAlbum(0, key, 1, 20); |
| | | out.print(JsonUtil.loadTrueResult(result)); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @Controller |
| | | public class HomeParser { |
| | | |
| | | private Logger logger=LoggerFactory.getLogger(HomeParser.class); |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | |
| | | if (Integer.parseInt(resourceId) == YouKuUtil.RESOURCE_ID) { |
| | | try { |
| | | info = youKuUtil.getVideoInfo(internetSearchVideo); |
| | | |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:"+videoId); |
| | | e.printStackTrace(); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | |
| | | try { |
| | | info = mogoTVUtil.getVideoInfo(internetSearchVideo); |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:"+videoId); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | |
| | | try { |
| | | info = tencentVideoUtil.getVideoInfo(internetSearchVideo); |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:"+videoId); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | |
| | | System.out.println(clipInfo.getTitle() + ":" + clipInfo.getClipId()); |
| | | try { |
| | | MogoTVClipInfo detail = getClipDetail(clipInfo); |
| | | mogoTVService.save(detail); |
| | | mogoTVService.addToInternetSearch(detail); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | MogoTVClipInfo clipInfo = mogoTVService.getSimpleClipDetail(cid); |
| | | if (clipInfo != null) { |
| | | MogoTVClipInfo info = getClipDetail(clipInfo); |
| | | mogoTVService.save(info); |
| | | mogoTVService.addToInternetSearch(info); |
| | | } |
| | | } |
| | | return ReturnT.SUCCESS; |
| | |
| | | for (TencentCoverInfo coverInfo : coverInfoList) { |
| | | System.out.println(coverInfo.getTitle()+":"+coverInfo.getCover_id()); |
| | | try { |
| | | tencentVideoService.save(coverInfo); |
| | | tencentVideoService.addToInternetSearch(coverInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | for (String cid : cids) { |
| | | try { |
| | | TencentCoverInfo detail = getCoverDetail(cid); |
| | | tencentVideoService.save(detail); |
| | | tencentVideoService.addToInternetSearch(detail); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | System.out.println(simple.getName() + ":" + simple.getId()); |
| | | try { |
| | | YouKuShowDetail detail = getShowDetail(simple.getId()); |
| | | youKuService.save(detail); |
| | | youKuService.addToInternetSearch(detail); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | String[] ids = param.split(","); |
| | | for (String id : ids) { |
| | | YouKuShowDetail detail = getShowDetail(id); |
| | | youKuService.save(detail); |
| | | youKuService.addToInternetSearch(detail); |
| | | } |
| | | } |
| | | } else { |
| | |
| | | } |
| | | |
| | | |
| | | private SearchResult searchAlbum(int videoType, String key, int page, int pageSize) { |
| | | public SearchResult searchAlbum(int videoType, String key, int page, int pageSize) { |
| | | List<VideoInfo> localList = new ArrayList<>(); |
| | | //专辑视频集合 |
| | | Set<String> solrAlbumVids = new HashSet<>(); |
| | |
| | | } |
| | | } |
| | | } |
| | | //todo 按关键词的匹配度排序 |
| | | |
| | | //按关键词的匹配度排序 |
| | | Comparator<VideoInfo> cm = new Comparator<VideoInfo>() { |
| | | @Override |
| | | public int compare(VideoInfo o1, VideoInfo o2) { |
| | | float s1 = CompareStrSimUtil.getSimilarityRatio(o1.getName(), key, true); |
| | | float s2 = CompareStrSimUtil.getSimilarityRatio(o2.getName(), key, true); |
| | | return s2 > s1 ? 1 : -1; |
| | | if (s1 != s2)//相似度越高越靠前 |
| | | return s2 > s1 ? 1 : -1; |
| | | else |
| | | return o1.getDefinition() - o2.getDefinition();//高清排在前 |
| | | } |
| | | }; |
| | | |
| | | Collections.sort(localList,cm); |
| | | |
| | | Collections.sort(localList, cm); |
| | | } |
| | | //未搜索到内容 |
| | | if (localList == null || localList.size() == 0) { |
| | | logger.warn("专辑搜索无结果#{}", key); |
| | | } |
| | | return new SearchResult(albumCount, localList); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | class SearchResult { |
| | | public static class SearchResult { |
| | | private int totalCount; |
| | | private List<VideoInfo> videoInfoList; |
| | | |
| | |
| | | package com.yeshi.buwan.service.imp.juhe; |
| | | |
| | | import com.yeshi.buwan.dao.juhe.youku.InternetSearchVideoDao; |
| | | import com.yeshi.buwan.domain.system.SystemConfig; |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.dto.mq.InternetSearchVideoMQMsg; |
| | | import com.yeshi.buwan.exception.ParamsException; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.inter.system.SystemConfigService; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Resource |
| | | private InternetSearchVideoDao internetSearchVideoDao; |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | private boolean isCanSave(InternetSearchVideo video) { |
| | | SystemConfig systemConfig = systemConfigService.getConfigByKeyCache("internetSearchInvalidKeyForSave"); |
| | | if (systemConfig == null) |
| | | return true; |
| | | String value = systemConfig.getValue(); |
| | | String[] invalidNames = value.split("#"); |
| | | for (String st : invalidNames) { |
| | | if (video.getName().contains(st)) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | | @Validated |
| | | @Override |
| | | public void save(@Valid InternetSearchVideo video) throws ParamsException, Exception { |
| | | public InternetSearchVideo save(@Valid InternetSearchVideo video) throws ParamsException, Exception { |
| | | if (!isCanSave(video)) |
| | | return null; |
| | | |
| | | InternetSearchVideo oldVideo = internetSearchVideoDao.get(video.getId()); |
| | | Set<Integer> resourceIds = listResourceId(video); |
| | | int resourceId = Integer.parseInt(video.getResourceIds()); |
| | |
| | | msg.setId(video.getId()); |
| | | msg.setResourceId(resourceId); |
| | | CMQManager.getInstance().addInternetSearchVideoUpdateMsg(msg); |
| | | |
| | | return video; |
| | | } |
| | | |
| | | private Set<Integer> listResourceId(InternetSearchVideo video) { |
| | |
| | | } |
| | | mogoTVVideoDao.save(video); |
| | | } |
| | | internetSearchVideoService.save(InternetSearchVideoFactory.create(detail)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void addToInternetSearch(MogoTVClipInfo clipDetail) throws Exception { |
| | | save(clipDetail); |
| | | InternetSearchVideo video = InternetSearchVideoFactory.create(clipDetail); |
| | | internetSearchVideoService.save(video); |
| | | if (internetSearchVideoService.save(video) == null) { |
| | | return; |
| | | } |
| | | MogoTVSearchVideoMap map = new MogoTVSearchVideoMap(); |
| | | map.setClipId(clipDetail.getClipId()); |
| | | map.setVideoId(video.getId()); |
| | |
| | | |
| | | tencentCoverVideoDao.save(video); |
| | | } |
| | | |
| | | internetSearchVideoService.save(InternetSearchVideoFactory.create(detail)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void addToInternetSearch(TencentCoverInfo showDetail) throws Exception { |
| | | save(showDetail); |
| | | InternetSearchVideo video = InternetSearchVideoFactory.create(showDetail); |
| | | internetSearchVideoService.save(video); |
| | | if (internetSearchVideoService.save(video) == null) { |
| | | return; |
| | | } |
| | | TencentSearchVideoMap map = new TencentSearchVideoMap(); |
| | | map.setCoverId(showDetail.getId()); |
| | | map.setVideoId(video.getId()); |
| | |
| | | } |
| | | youKuVideoDao.save(video); |
| | | } |
| | | |
| | | internetSearchVideoService.save(InternetSearchVideoFactory.create(detail)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void addToInternetSearch(YouKuShowDetail showDetail) throws Exception { |
| | | save(showDetail); |
| | | InternetSearchVideo video = InternetSearchVideoFactory.create(showDetail); |
| | | internetSearchVideoService.save(video); |
| | | if (internetSearchVideoService.save(video) == null) { |
| | | return; |
| | | } |
| | | YouKuSearchVideoMap map = new YouKuSearchVideoMap(); |
| | | map.setShowId(showDetail.getId()); |
| | | map.setVideoId(video.getId()); |
| | |
| | | |
| | | public interface InternetSearchVideoService { |
| | | |
| | | public void save(@Valid InternetSearchVideo video) throws ParamsException, Exception; |
| | | public InternetSearchVideo save(@Valid InternetSearchVideo video) throws ParamsException, Exception; |
| | | |
| | | public Set<Integer> listResourceId(String id); |
| | | |
| | |
| | | doAddPPTVVideo(); |
| | | doDeleteVideoResource(); |
| | | doUpdateVideoExtraInfo(); |
| | | doInternetSearchVideoUpdateJob(); |
| | | } |
| | | doInternetSearchVideoUpdateJob(); |
| | | } |
| | | |
| | | private void doSolrJob() { |
| | |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.mogotv.entity.MogoTVClipInfo; |
| | | import com.yeshi.buwan.tencent.entity.TencentCoverInfo; |
| | | import com.yeshi.buwan.tencent.entity.TencentCoverVideo; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.youku.entity.YouKuShowDetail; |
| | |
| | | |
| | | public static InternetSearchVideo create(TencentCoverInfo info) { |
| | | |
| | | int videoCount = 0; |
| | | for (TencentCoverInfo.VipIdsBean idsBean : info.getVip_ids()) { |
| | | if (idsBean.getF() == 2 || idsBean.getF() == 7) |
| | | videoCount++; |
| | | } |
| | | |
| | | InternetSearchVideo video = new InternetSearchVideo(); |
| | | video.setActors(StringUtil.concat(info.getLeading_actor(), ",")); |
| | | video.setArea(info.getArea_name()); |
| | |
| | | } else |
| | | video.setTag(info.getEpisode_updated()); |
| | | video.setUpdateTime(new Date()); |
| | | video.setVideoCount(info.getVideoList().size()); |
| | | video.setVideoCount(videoCount); |
| | | video.setYear(info.getYear()); |
| | | video.setId(InternetSearchVideo.createId(video.getName(), video.getRootType(), video.getYear())); |
| | | return video; |
| | |
| | | @Test |
| | | public void userActive() throws Exception { |
| | | Gson gson = new Gson(); |
| | | List<String> list = loadLog("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\active_2021_03_23.log"); |
| | | List<String> list = loadLog("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\active_2021_03_27.log"); |
| | | Map<String, List<UserActiveLogInfo>> map = new HashMap<>(); |
| | | for (String st : list) { |
| | | UserActiveLogInfo activeLogInfo = gson.fromJson(st, UserActiveLogInfo.class); |
| | |
| | | System.out.println("搜索之后播放总数:" + searchPlayCount + "比例为:" + getPercent(map.size(), searchPlayCount)); |
| | | System.out.println("搜索之后未播放总数:" + searchNoPlay + "比例为:" + getPercent(map.size(), searchNoPlay)); |
| | | System.out.println("未搜索也未播放总数:" + noSearchAndPlay + "比例为:" + getPercent(map.size(), noSearchAndPlay)); |
| | | System.out.println("搜索满意度:" +getPercent(searchCount, searchPlayCount)); |
| | | System.out.println("未能成功进入首页总数:" + noComeInCount + "比例为:" + getPercent(map.size(), noComeInCount)); |
| | | System.out.println("进入首页后无动作的总数:" + comeinAndNoAction + "比例为:" + getPercent(map.size(), comeinAndNoAction)); |
| | | } |
| | |
| | | |
| | | @Test |
| | | public void addInternet() { |
| | | InternetSearchVideo list = internetSearchVideoService.selectByPrimaryKey("8a2332ccbabb5eb7076f690365db692a"); //listAll(1, 10); |
| | | InternetSearchVideo list = internetSearchVideoService.selectByPrimaryKey("9693a5f3de443fe48a5272ce12c859f3"); //listAll(1, 10); |
| | | solrInternetSearchVideoDataManager.saveOrUpdate(list); |
| | | } |
| | | |
| | | @Test |
| | | public void deleteInternet() { |
| | | String st="161469b4aa35ca7ae1cc5d3ddaa23276,3b57b603b4eef496ce0de50f06ca40c0"; |
| | | |
| | | |
| | | for (String id : st.split(",")) |
| | | solrInternetSearchVideoDataManager.deleteById(id); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private AlbumVideoMapDao albumVideoMapDao; |
| | |
| | | @Test |
| | | public void test2() { |
| | | try { |
| | | mogoTVVideoUpdate.updateLatestVideo("综艺"); |
| | | mogoTVVideoUpdate.updateLatestVideo("电视剧"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | package com.hxh.spring.test.video; |
| | | |
| | | |
| | | import com.yeshi.buwan.job.video.MogoTVVideoUpdate; |
| | | import com.yeshi.buwan.job.video.TencentVideoUpdate; |
| | | import com.yeshi.buwan.mogotv.entity.MogoTVClipInfo; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.MogoTVService; |
| | | import com.yeshi.buwan.service.inter.juhe.TencentVideoService; |
| | | import com.yeshi.buwan.tencent.entity.TencentCoverInfo; |
| | | import org.junit.Test; |
| | |
| | | @Test |
| | | public void test1() { |
| | | try { |
| | | youKuVideoUpdate.updateLatestVideo("ceba4745ea10415eb791"); |
| | | youKuVideoUpdate.updateLatestVideo("bb8e820fe05d414a8232"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |