1 文件已重命名
19个文件已修改
2个文件已添加
| | |
| | | |
| | | /** |
| | | * 根据视频ID和来源ID查询 |
| | | * |
| | | * @param videoId |
| | | * @param resourceId |
| | | * @return |
| | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public long countByVideoIdAndResourceId(String videoId, String resourceId) { |
| | | return getCount("from ResourceVideo rv where rv.video.id=? and rv.resource.id=?", new Serializable[]{videoId, resourceId}); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.dao; |
| | | |
| | | import com.yeshi.buwan.dao.base.BaseDao; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Session; |
| | | import org.springframework.orm.hibernate4.HibernateCallback; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | |
| | | return list(hql, videos); |
| | | } |
| | | |
| | | /** |
| | | * 统计视频附加信息(包含地区,分类,来源) |
| | | * |
| | | * @param videoId -视频ID |
| | | */ |
| | | public void statisticVideoExtraInfo(final String videoId) { |
| | | excute(new HibernateCallback() { |
| | | @Override |
| | | public Object doInHibernate(Session session) throws HibernateException { |
| | | session.getTransaction().begin(); |
| | | session.createSQLQuery(String.format("call copyvideotemp(%s)", videoId)).executeUpdate(); |
| | | session.getTransaction().commit(); |
| | | return null; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.yeshi.buwan.dao.juhe.funtv; |
| | | |
| | | import com.yeshi.buwan.dao.base.MongodbBaseDao; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import com.yeshi.buwan.funtv.entity.FunTVAlbum; |
| | | |
| | | @Repository |
| | | public class FunTVAlbumDao extends MongodbBaseDao<FunTVAlbum> { |
| | | |
| | | } |
| | |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | @Repository |
| | | public class VideoFunTV2Dao extends MongodbBaseDao<VideoFunTV2> { |
| | |
| | | return findOne(query); |
| | | } |
| | | |
| | | /** |
| | | * 查询所有 |
| | | * |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | public List<VideoFunTV2> listAll(int start, int count) { |
| | | Query query = new Query(); |
| | | query.skip(start); |
| | | query.limit(count); |
| | | return findList(query); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Repository |
| | | public class VideoIqiyi2Dao extends MongodbBaseDao<VideoIqiyi2> { |
| | | |
| | |
| | | return findOne(query); |
| | | } |
| | | |
| | | public List<VideoIqiyi2> listAll(int start, int count) { |
| | | Query query = new Query(); |
| | | query.skip(start); |
| | | query.limit(count); |
| | | return findList(query); |
| | | } |
| | | |
| | | } |
File was renamed from src/main/java/com/yeshi/buwan/dto/mq/CMQConsumeMsg.java |
| | |
| | | package com.yeshi.buwan.dto.mq; |
| | | |
| | | //消息消费 |
| | | public class CMQConsumeMsg { |
| | | public class CMQResult { |
| | | private String handler; |
| | | private Object data; |
| | | |
| | | |
| | | public CMQResult() { |
| | | } |
| | | |
| | | public CMQResult(String handler, Object data) { |
| | | this.handler = handler; |
| | | this.data = data; |
| | | } |
| | | |
| | | public String getHandler() { |
| | | return handler; |
| | | } |
New file |
| | |
| | | package com.yeshi.buwan.dto.mq; |
| | | |
| | | public class VideoExtraInfoChangeMQMsg { |
| | | //添加 |
| | | public final static String ACTION_ADD = "add"; |
| | | //删除 |
| | | public final static String ACTION_DELETE = "del"; |
| | | |
| | | //来源 |
| | | public final static String TYPE_RESOURCE = "resource"; |
| | | //分类 |
| | | public final static String TYPE_CATEGORY = "category"; |
| | | |
| | | |
| | | private String type; |
| | | private String videoId; |
| | | private String action; |
| | | |
| | | public VideoExtraInfoChangeMQMsg(String type, String videoId, String action) { |
| | | this.type = type; |
| | | this.videoId = videoId; |
| | | this.action = action; |
| | | } |
| | | |
| | | public VideoExtraInfoChangeMQMsg() { |
| | | } |
| | | |
| | | public String getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(String type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getVideoId() { |
| | | return videoId; |
| | | } |
| | | |
| | | public void setVideoId(String videoId) { |
| | | this.videoId = videoId; |
| | | } |
| | | |
| | | public String getAction() { |
| | | return action; |
| | | } |
| | | |
| | | public void setAction(String action) { |
| | | this.action = action; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public void update(int channelId,Date startTime,Date endTime){ |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | switch (channelId) { |
| | | case IqiYiNewAPI.TYPE_DIANYING: |
| | | updateAlbum(channelId, false, startTime, endTime); |
| | | updateAlbum(channelId, true, startTime, endTime); |
| | | break; |
| | | case IqiYiNewAPI.TYPE_DIANSHIJU: |
| | | case IqiYiNewAPI.TYPE_DONGMAN: |
| | |
| | | private FunTV2Service funTV2Service; |
| | | |
| | | |
| | | /** |
| | | * 更新最近几天的视频 |
| | | * @param param 天数 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @XxlJob("video-update-funtv2-updateLatestVideo") |
| | | public ReturnT<String> updateLatestVideo(String param) throws Exception { |
| | | int d = 1; |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据专辑ID更新 |
| | | * @param param |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @XxlJob("video-update-funtv2-updateAlbumById") |
| | | public ReturnT<String> updateAlbumById(String param) throws Exception { |
| | | FunTVAlbum2 album2 = FunTVNewApi.getAlbumsDetail(param); |
| | |
| | | } |
| | | |
| | | |
| | | @XxlJob("video-update-iqiyi-updateVideoByChannelId") |
| | | public ReturnT<String> updateVideoByChannelId(String param) throws Exception { |
| | | String[] params = param.split(","); |
| | | for (String p : params) { |
| | | int channelId = Integer.parseInt(p); |
| | | iqiyiUtil2.updateTodayAlbumAndVideo(channelId); |
| | | logger.info("更新当天专辑:" + channelId); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.dao.CategoryVideoDao; |
| | | import com.yeshi.buwan.dao.ResourceVideoDao; |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.dto.mq.VideoExtraInfoChangeMQMsg; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Query; |
| | | import org.hibernate.Session; |
| | |
| | | cv.setVideo(new VideoInfo(videoId)); |
| | | cv.setVideoType(new VideoType(categoryId)); |
| | | categoryVideoDao.save(cv); |
| | | CMQManager.getInstance().addVideoExtraInfoChanged(new VideoExtraInfoChangeMQMsg(VideoExtraInfoChangeMQMsg.TYPE_CATEGORY, videoId, VideoExtraInfoChangeMQMsg.ACTION_ADD)); |
| | | } |
| | | } |
| | | |
| | |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.buwan.domain.VideoResource; |
| | | import com.yeshi.buwan.dto.mq.VideoExtraInfoChangeMQMsg; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Query; |
| | |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class ResourceVideoService { |
| | |
| | | return getResourceList(videoInfoList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据视频ID与ResourceId查询 |
| | | * |
| | | * @param videoId |
| | | * @param sourceId |
| | | * @return |
| | | */ |
| | | |
| | | public long countByVideoIdAndResourceId(String videoId, long sourceId) { |
| | | return resourceVideoDao.countByVideoIdAndResourceId(videoId, sourceId + ""); |
| | | } |
| | | |
| | | public void save(ResourceVideo resourceVideo) { |
| | | resourceVideoDao.save(resourceVideo); |
| | | } |
| | |
| | | public void addVideoResource(String videoId, String resourceId) { |
| | | ResourceVideo rv = resourceVideoDao.selectByVideoIdAndResourceId(videoId, resourceId); |
| | | if (rv == null) { |
| | | System.out.println(videoId + ":" + resourceId); |
| | | rv = new ResourceVideo(); |
| | | rv.setResource(new VideoResource(resourceId + "")); |
| | | rv.setVideo(new VideoInfo(videoId + "")); |
| | | resourceVideoDao.save(rv); |
| | | CMQManager.getInstance().addVideoExtraInfoChanged(new VideoExtraInfoChangeMQMsg(VideoExtraInfoChangeMQMsg.TYPE_RESOURCE, videoId, VideoExtraInfoChangeMQMsg.ACTION_ADD)); |
| | | } |
| | | } |
| | | |
| | | |
| | | public void delete(ResourceVideo rv) { |
| | | resourceVideoDao.delete(rv); |
| | | } |
| | | |
| | | @Transactional |
| | |
| | | if (resourceVideo != null) |
| | | resourceVideoDao.delete(resourceVideo); |
| | | CMQManager.getInstance().addVideoResourceDeleteMsg(videoId); |
| | | CMQManager.getInstance().addVideoExtraInfoChanged(new VideoExtraInfoChangeMQMsg(VideoExtraInfoChangeMQMsg.TYPE_RESOURCE, videoId, VideoExtraInfoChangeMQMsg.ACTION_DELETE)); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | public List<VideoInfo> listByVideoIds(List<String> videoIds) { |
| | | |
| | | return videoInfoDao.listByVideoIds(videoIds); |
| | | |
| | | } |
| | | |
| | | public void hiddenVideo(String id) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | //从新统计 |
| | | public void statisticVideoExtraInfo(String videoId) { |
| | | videoInfoDao.statisticVideoExtraInfo(videoId); |
| | | } |
| | | |
| | | } |
| | |
| | | VideoFunTV2 videoFunTV2 = videoFunTV2Dao.selectByMediaId(mediaId); |
| | | if (videoFunTV2 == null) |
| | | return; |
| | | |
| | | List<ResourceVideo> resourceVideoList = resourceVideoService.getResourceList(videoFunTV2.getVideoId() + ""); |
| | | for (int i = 0; i < resourceVideoList.size(); i++) { |
| | | ResourceVideo rv = resourceVideoList.get(i); |
| | | if (rv.getResource() != null && Integer.parseInt(rv.getResource().getId()) == FunTVUtil2.RESOURCE_ID) { |
| | | //删除资源映射 |
| | | resourceVideoService.delete(rv); |
| | | resourceVideoList.remove(i); |
| | | i--; |
| | | } |
| | | } |
| | | |
| | | if (resourceVideoList.size() == 0) { |
| | | //隐藏视频 |
| | | videoInfoService.hiddenVideo(videoFunTV2.getVideoId() + ""); |
| | | //更新搜索引擎 |
| | | CMQManager.getInstance().addSolrMsg(videoFunTV2.getVideoId() + ""); |
| | | } |
| | | |
| | | videoFunTV2Dao.delete(videoFunTV2.getVideoId()); |
| | | resourceVideoService.delete(videoFunTV2.getVideoId()+"",FunTVUtil2.RESOURCE_ID+""); |
| | | //删除媒体与媒体对应的视频 |
| | | funTVAlbum2Dao.delete(mediaId); |
| | | List<FunTVVideo2> video2List = listAllEpisodeList(mediaId); |
| | |
| | | |
| | | @Resource |
| | | private FunTVAlbumDao funTVAlbumDao; |
| | | |
| | | @Resource |
| | | private FunTVAlbumVideoMapDao funTVAlbumVideoMapDao; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private VideoManager videoManager; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | static Logger logger = Logger.getLogger(FunTVService.class); |
| | | |
| | |
| | | if (vft != null && vft.getAid() != null) {// 按节目查找视频 |
| | | String aid = vft.getAid(); |
| | | FunTVAlbum album = funTVAlbumDao.get(aid); |
| | | |
| | | if (album == null) { |
| | | resourceVideoService.delete(videoid, FunTVUtil.RESOURCE_ID + ""); |
| | | } |
| | | final String type = album.getVideoType(); |
| | | Sort.Direction sort = Sort.Direction.ASC; |
| | | if (type != null) |
New file |
| | |
| | | package com.yeshi.buwan.util; |
| | | |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.select.Elements; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class HtmlToolUtil { |
| | | |
| | | //解析SQLYog工具导出的html内容 |
| | | public static List<String[]> parseSQLYogExportHtmData(String path, int columns) { |
| | | List<String[]> contentList = new ArrayList<>(); |
| | | try { |
| | | Document doc = Jsoup.parse(new File(path), "UTF-8"); |
| | | Elements els = doc.getElementsByTag("tr"); |
| | | for (int i = 1; i < els.size(); i++) { |
| | | Elements tds = els.get(i).getElementsByTag("td"); |
| | | String[] contents = new String[columns]; |
| | | for (int j = 0; j < columns; j++) { |
| | | String content = tds.get(j).html().trim(); |
| | | contents[j] = content; |
| | | } |
| | | contentList.add(contents); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return contentList; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import com.yeshi.buwan.dto.mq.CMQConsumeMsg; |
| | | import com.yeshi.buwan.dto.mq.CMQResult; |
| | | import com.yeshi.buwan.dto.mq.FunTVAlbum2MQMsg; |
| | | import com.yeshi.buwan.dto.mq.IqiyiAlbum2MQMsg; |
| | | import com.yeshi.buwan.dto.mq.SolrVideoMQMsg; |
| | | import com.yeshi.buwan.funtv.entity.FunTVAlbum2; |
| | | import com.yeshi.buwan.funtv.entity.FunTVVideo2; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.service.imp.JobThreadExecutorServiceImpl; |
| | | import com.yeshi.buwan.service.imp.ResourceVideoService; |
| | |
| | | @Component |
| | | public class SpringContext implements ApplicationListener<ContextRefreshedEvent> { |
| | | |
| | | |
| | | @Resource |
| | | private VideoInfoService videoInfoService; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | |
| | | private static boolean isInited = false; |
| | | |
| | |
| | | @Override |
| | | public void run() { |
| | | while (true) { |
| | | List<CMQConsumeMsg> cmqMsgList = CMQManager.getInstance().consumeVideoResourceDeleteMsg(16); |
| | | List<CMQResult> cmqMsgList = CMQManager.getInstance().consumeVideoResourceDeleteMsg(16); |
| | | if (cmqMsgList != null) |
| | | for (CMQConsumeMsg msg : cmqMsgList) { |
| | | for (CMQResult msg : cmqMsgList) { |
| | | try { |
| | | String videoId = msg.getData() + ""; |
| | | //查询资源列表 |
| | |
| | | package com.yeshi.buwan.util.mq; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.qcloud.cmq.Message; |
| | | import com.yeshi.buwan.dto.mq.CMQConsumeMsg; |
| | | import com.yeshi.buwan.dto.mq.FunTVAlbum2MQMsg; |
| | | import com.yeshi.buwan.dto.mq.IqiyiAlbum2MQMsg; |
| | | import com.yeshi.buwan.dto.mq.SolrVideoMQMsg; |
| | | import com.yeshi.buwan.dto.mq.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | //删除视频资源 |
| | | public static String QUEUENAME_VIDEO_RESOURCE_DELETE = "buwan-video-resource-delete"; |
| | | |
| | | //更新视频附加信息 |
| | | public static String QUEUENAME_UPDATE_VIDEO_EXTRAINFO = "buwan-video-video-update-extrainfo"; |
| | | |
| | | |
| | | private static String TOPIC_VIDEO_EXTRAINFO = "buwan_topic_video_extrainfo_change"; |
| | | |
| | | |
| | | static { |
| | | cmqUtil = CMQUtil.getInstance(secretId, secretKey); |
| | |
| | | cmqUtil.createQueue(QUEUENAME_VIDEO_UPDATE_IQIYI_2, 1024 * 1024); |
| | | cmqUtil.createQueue(QUEUENAME_VIDEO_UPDATE_FUNTV_2, 1024 * 1024); |
| | | cmqUtil.createQueue(QUEUENAME_VIDEO_RESOURCE_DELETE, 1024 * 1024); |
| | | cmqUtil.createQueue(QUEUENAME_UPDATE_VIDEO_EXTRAINFO, 1024 * 1024); |
| | | |
| | | //创建主题 |
| | | cmqUtil.createTopic(TOPIC_VIDEO_EXTRAINFO); |
| | | //订阅主题 |
| | | try { |
| | | List<String> filters = new ArrayList<>(); |
| | | filters.add("resource"); |
| | | filters.add("category"); |
| | | cmqUtil.subscribeTopic(TOPIC_VIDEO_EXTRAINFO, TOPIC_VIDEO_EXTRAINFO + "#" + QUEUENAME_UPDATE_VIDEO_EXTRAINFO, QUEUENAME_UPDATE_VIDEO_EXTRAINFO, filters); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | |
| | | public static CMQManager getInstance() { |
| | |
| | | cmqUtil.sendMsg(QUEUENAME_VIDEO_RESOURCE_DELETE, videoId); |
| | | } |
| | | |
| | | public List<CMQConsumeMsg> consumeVideoResourceDeleteMsg(int count) { |
| | | List<CMQConsumeMsg> list = new ArrayList<>(); |
| | | public List<CMQResult> consumeVideoResourceDeleteMsg(int count) { |
| | | List<CMQResult> list = new ArrayList<>(); |
| | | List<Message> msgList = cmqUtil.recieveMsg(count, QUEUENAME_VIDEO_RESOURCE_DELETE); |
| | | if (msgList != null) |
| | | for (Message msg : msgList) { |
| | | CMQConsumeMsg mm = new CMQConsumeMsg(); |
| | | CMQResult mm = new CMQResult(); |
| | | mm.setHandler(msg.receiptHandle); |
| | | mm.setData(msg.msgBody); |
| | | list.add(mm); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 视频附加信息改变 |
| | | */ |
| | | public void addVideoExtraInfoChanged(VideoExtraInfoChangeMQMsg msg) { |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(msg.getType()); |
| | | cmqUtil.publishTopicMessage(TOPIC_VIDEO_EXTRAINFO, new Gson().toJson(msg), list); |
| | | } |
| | | |
| | | |
| | | public List<CMQResult> consumeUpdateVideoExtraInfoMsg(int count) { |
| | | List<CMQResult> list = new ArrayList<>(); |
| | | List<Message> msgList = cmqUtil.recieveMsg(count, QUEUENAME_UPDATE_VIDEO_EXTRAINFO); |
| | | if (msgList != null) |
| | | for (Message msg : msgList) { |
| | | CMQResult mm = new CMQResult(); |
| | | mm.setHandler(msg.receiptHandle); |
| | | mm.setData(new Gson().fromJson(msg.msgBody, VideoExtraInfoChangeMQMsg.class)); |
| | | list.add(mm); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public void deleteUpdateVideoExtraInfoMsg(String handler) { |
| | | cmqUtil.deleteMsg(QUEUENAME_UPDATE_VIDEO_EXTRAINFO, handler); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | * 指定参数创建队列 |
| | | * |
| | | * @param queueName |
| | | * @param pollingWaitSeconds |
| | | * -长轮训等待时间 |
| | | * @param visibilityTimeout |
| | | * -消息消费后再次可见的时间 |
| | | * @param pollingWaitSeconds -长轮训等待时间 |
| | | * @param visibilityTimeout -消息消费后再次可见的时间 |
| | | * @return |
| | | */ |
| | | public boolean createQueue(String queueName, int pollingWaitSeconds, int visibilityTimeout) { |
| | |
| | | meta.maxMsgSize = 65536; |
| | | meta.msgRetentionSeconds = 345600; |
| | | try { |
| | | // if (account.getQueue(queueName) != null) |
| | | account.createQueue(queueName, meta); |
| | | return true; |
| | | } catch (Exception e) { |
| | |
| | | /** |
| | | * 消费消息 |
| | | * |
| | | * @param count |
| | | * 1-16 |
| | | * @param queueName |
| | | * 队列名字 |
| | | * @param count 1-16 |
| | | * @param queueName 队列名字 |
| | | * @return |
| | | */ |
| | | public List<Message> recieveMsg(int count, String queueName) { |
| | |
| | | */ |
| | | public boolean createTopic(String topicName, int maxMsgSize, int filterType) { |
| | | try { |
| | | // if (topicAccount.getTopic(topicName) == null) |
| | | topicAccount.createTopic(topicName, maxMsgSize, filterType); |
| | | return true; |
| | | } catch (Exception e) { |
| | |
| | | */ |
| | | public boolean createTopic(String topicName) { |
| | | try { |
| | | if (topicAccount.getTopic(topicName) == null) |
| | | topicAccount.createTopic(topicName, 65536); |
| | | return true; |
| | | } catch (Exception e) { |
| | |
| | | public boolean subscribeTopic(String topicName, String subscriptionName, String queueName) { |
| | | try { |
| | | topicAccount.createSubscribe(topicName, subscriptionName, queueName, "queue"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 订阅 |
| | | * |
| | | * @param topicName |
| | | * @param subscriptionName |
| | | * @param queueName |
| | | * @param filterTag |
| | | * @return |
| | | */ |
| | | public boolean subscribeTopic(final String topicName, final String subscriptionName, String queueName, |
| | | final List<String> filterTag) { |
| | | try { |
| | | topicAccount.createSubscribe(topicName, subscriptionName, queueName, "queue", |
| | | filterTag, null, null, null); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发布订阅消息 |
| | | * @param topicName |
| | | * @param message |
| | | * @param tags |
| | | * @return |
| | | */ |
| | | public boolean publishTopicMessage(String topicName, String message, List<String> tags) { |
| | | try { |
| | | Topic topic = topicAccount.getTopic(topicName); |
| | | if (topic == null) |
| | | return false; |
| | | topic.publishMessage(message, tags, null); |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 批量发布消息 |
| | | * |
| | |
| | | package com.hxh.spring.test; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.dao.juhe.funtv.FunTVAlbum2Dao; |
| | | import com.yeshi.buwan.dao.juhe.funtv.FunTVVideo2Dao; |
| | | import com.yeshi.buwan.dao.juhe.funtv.VideoFunTV2Dao; |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.funtv.FunTVNewApi; |
| | | import com.yeshi.buwan.funtv.FunTVUtil2; |
| | | import com.yeshi.buwan.funtv.entity.FunTVAlbum2; |
| | | import com.yeshi.buwan.funtv.entity.FunTVShortVideo2; |
| | | import com.yeshi.buwan.funtv.entity.FunTVVideo2; |
| | | import com.yeshi.buwan.funtv.entity.VideoFunTV2; |
| | | import com.yeshi.buwan.job.video.FunTV2VideoUpdate; |
| | | import com.yeshi.buwan.service.imp.ResourceVideoService; |
| | | import com.yeshi.buwan.service.imp.VideoInfoService; |
| | | import com.yeshi.buwan.service.inter.juhe.FunTV2Service; |
| | | import com.yeshi.buwan.vo.video.funtv.Funtv2ResultVO; |
| | | import org.junit.Test; |
| | |
| | | @Resource |
| | | private FunTV2VideoUpdate funTV2VideoUpdate; |
| | | |
| | | @Resource |
| | | private VideoInfoService videoInfoService; |
| | | |
| | | @Resource |
| | | private VideoFunTV2Dao videoFunTV2Dao; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | @Test |
| | | public void test1() { |
| | | long now = System.currentTimeMillis(); |
| | |
| | | |
| | | @Test |
| | | public void syncAlbum() { |
| | | Funtv2ResultVO vo = FunTVNewApi.getAlbums(1, 20, null, null, 5, 1); |
| | | //1-电影 2-电视剧 3-动漫 4-综艺 5-少儿 |
| | | int channelId = 5; |
| | | Funtv2ResultVO vo = FunTVNewApi.getAlbums(1, 20, null, null, channelId, 1); |
| | | int totalCount = vo.getCount(); |
| | | int pageSize = 20; |
| | | int totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1; |
| | | for (int p = 0; p < totalPage; p++) { |
| | | Funtv2ResultVO result = FunTVNewApi.getAlbums(p + 1, pageSize, null, null, 5, 1); |
| | | Funtv2ResultVO result = FunTVNewApi.getAlbums(p + 1, pageSize, null, null, channelId, 1); |
| | | if (result != null) |
| | | for (Serializable a : result.getList()) { |
| | | FunTVAlbum2 album2 = (FunTVAlbum2) a; |
| | |
| | | |
| | | @Test |
| | | public void addToVideoInfo() { |
| | | List<FunTVAlbum2> album2List = funTVAlbum2Dao.listByChannelId(1, 300, 500); |
| | | List<FunTVAlbum2> album2List = funTVAlbum2Dao.listByChannelId(3, 2000, 1000); |
| | | for (FunTVAlbum2 album2 : album2List) { |
| | | System.out.println(album2.getName()); |
| | | List<FunTVVideo2> list = funTVVideo2Dao.listByMediaId(album2.getId(), 0, 2000); |
| | | album2.setEpisodes(list); |
| | | funTV2Service.addToVideoInfo(album2); |
| | | try { |
| | | funTV2Service.processAlbum(album2); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void addToVideoInfo1() { |
| | | videoInfoService.statisticVideoExtraInfo(179210 + ""); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | |
| | | @Test |
| | | public void test() { |
| | | FunTVVideo2 video = funTVVideo2Dao.get(34027 + ""); |
| | | System.out.println(video); |
| | | public void addResource() { |
| | | List<String> videoIds = new ArrayList<>(); |
| | | List<VideoFunTV2> list = videoFunTV2Dao.listAll(0, 5000); |
| | | for (VideoFunTV2 funTV2 : list) { |
| | | long count = resourceVideoService.countByVideoIdAndResourceId(funTV2.getVideoId() + "", FunTVUtil2.RESOURCE_ID); |
| | | if (count==0L) { |
| | | videoIds.add(funTV2.getVideoId() + ""); |
| | | } |
| | | } |
| | | //["7993072","7993075","7993076","7993077","7993078","7993079","7993081","7993082","7993083","7993084","7993085","7993086","7993088","7993089","7993090","7993094","7993095","7993096","7595177","8066187","8066194","8066195","8066196","8076894","7582863","7582643","7582653","7582876","7583418","7582690","7595550","7595195","7582913","7582989","982912","5625845","7582991","7334865","7761779","8077307","8077347","8077354","8077355","8077397","8077399","7728744","7674559","7728747","7726042","359250","7053989","7351834"] |
| | | System.out.println(new Gson().toJson(videoIds)); |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void offLine() { |
| | | funTV2Service.offLineAlbum("565"); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.IqiyiAlbum2Dao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyi2Dao; |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.funtv.FunTVUtil2; |
| | | import com.yeshi.buwan.funtv.entity.VideoFunTV2; |
| | | import com.yeshi.buwan.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; |
| | | import com.yeshi.buwan.iqiyi.entity.VideoIqiyi2; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil2; |
| | | import com.yeshi.buwan.iqiyi.vo.IqiyiAlbumListResult; |
| | | import com.yeshi.buwan.job.SMSJob; |
| | | import com.yeshi.buwan.job.video.Iqiyi2VideoUpdate; |
| | | import com.yeshi.buwan.query.Iqiyi2AlbumQuery; |
| | | import com.yeshi.buwan.service.imp.CategoryVideoService; |
| | | import com.yeshi.buwan.service.imp.ResourceVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.Iqiyi2Service; |
| | | import com.yeshi.buwan.util.FileUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import net.sf.json.JSONArray; |
| | | import org.junit.Test; |
| | | import org.junit.runner.RunWith; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | |
| | | import org.springframework.test.context.web.WebAppConfiguration; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Scanner; |
| | | |
| | | // |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | |
| | | @Resource |
| | | private Iqiyi2VideoUpdate iqiyi2VideoUpdate; |
| | | |
| | | @Resource |
| | | private CategoryVideoService categoryVideoService; |
| | | |
| | | @Resource |
| | | private VideoIqiyi2Dao videoIqiyi2Dao; |
| | | |
| | | @Resource |
| | | private ResourceVideoService resourceVideoService; |
| | | |
| | | |
| | | @Test |
| | | public void syncAll() { |
| | | iqiyiUtil2.syncAllDianShiJu(); |
| | | iqiyiUtil2.updateTodayAlbumAndVideo(IqiYiNewAPI.TYPE_DIANYING); |
| | | } |
| | | |
| | | @Test |
| | |
| | | @Test |
| | | public void test6() { |
| | | for(int i=0;i<10;i++) { |
| | | List<Long> ids = iqiyiAlbum2Dao.listInvalid(1000*(i), 1000); |
| | | saveToFile(ids); |
| | | List<Long> ids = iqiyiAlbum2Dao.listInvalid(0, 1000); |
| | | for (long id : ids) |
| | | iqiyiAlbum2Dao.delete(id); |
| | | //saveToFile(ids); |
| | | } |
| | | } |
| | | |
| | |
| | | public void count() { |
| | | // long count = iqiyiAlbum2Dao.countVideoByAid(253120001L); |
| | | // System.out.println(count); |
| | | IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(6603128446259700L); |
| | | IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(730266600L); |
| | | iqiyi2Service.addToVideoInfo(album2); |
| | | } |
| | | |
| | |
| | | System.out.println(result); |
| | | } |
| | | |
| | | @Test |
| | | public void deleteAlbum() { |
| | | try { |
| | | Scanner scanner = new Scanner(new FileInputStream(new File("E:\\iqiyialbum_invalid.txt"))); |
| | | while (scanner.hasNextLine()) { |
| | | String text = scanner.nextLine(); |
| | | if (!StringUtil.isNullOrEmpty(text)) { |
| | | JSONArray array = JSONArray.fromObject(text); |
| | | for (int i = 0; i < array.size(); i++) { |
| | | iqiyi2Service.deleteByAid(array.optLong(i)); |
| | | } |
| | | } |
| | | } |
| | | scanner.close(); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Test |
| | | public void addToMQ() { |
| | | Iqiyi2AlbumQuery query = new Iqiyi2AlbumQuery(); |
| | | query.setContentType(1); |
| | | query.setFeatureAlbumId(0L); |
| | | query.setChannelId(2); |
| | | |
| | | long count = iqiyiAlbum2Dao.countByAid(query); |
| | | int page = (int) (count % 100 == 0 ? count / 100 : count / 100 + 1); |
| | | |
| | | for (int i = 0; i < page; i++) { |
| | | List<IqiyiAlbum2> album2List = iqiyiAlbum2Dao.listByAid(query, IqiyiAlbum2.SORT_ID, i * 100, 100); |
| | | for (IqiyiAlbum2 album2 : album2List) { |
| | | System.out.println(album2.getName()); |
| | | if (IqiyiUtil2.albumIsValid(album2)) { |
| | | CMQManager.getInstance().addIqiyiAlbumUpdateMsg(album2.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void addCategory() { |
| | | List<String[]> list = HtmlToolUtil.parseSQLYogExportHtmData("C:\\Users\\Administrator\\Desktop\\爱奇艺分类缺失.htm", 2); |
| | | for (String[] sts : list) { |
| | | String videoId = sts[0]; |
| | | String videoType = sts[1]; |
| | | categoryVideoService.addCategoryVideo(videoId, Long.parseLong(videoType)); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void addResources() { |
| | | List<String> videoIds = new ArrayList<>(); |
| | | List<VideoIqiyi2> list = videoIqiyi2Dao.listAll(0, 5000); |
| | | for (VideoIqiyi2 video : list) { |
| | | long count = resourceVideoService.countByVideoIdAndResourceId(video.getVideoId() + "", IqiyiUtil2.RESOURCE_ID); |
| | | if (count == 0L) { |
| | | videoIds.add(video.getVideoId() + ""); |
| | | } |
| | | } |
| | | //["588808","466573","475946","328312","475934","359261","276279","322163","276768"] |
| | | System.out.println(new Gson().toJson(videoIds)); |
| | | } |
| | | |
| | | |
| | | } |