| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.buwan.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.videos.iqiyi.IqiYiNewAPI; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.yeshi.buwan.acFun.AcFunUtil; |
| | | import com.yeshi.buwan.acFun.AcfunVideoNew; |
| | | import com.yeshi.buwan.acFun.AcfunVideoResult; |
| | | import com.yeshi.buwan.funtv.FunTVUtil; |
| | | import com.yeshi.buwan.iqiyi.entity.IqiyiUpdateQueue; |
| | | import com.yeshi.buwan.iqiyi.util.IqiyiUtil; |
| | | import com.yeshi.buwan.videos.iqiyi.entity.IqiyiUpdateQueue; |
| | | import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil; |
| | | import com.yeshi.buwan.log.LogHelper; |
| | | import com.yeshi.buwan.service.imp.juhe.AcfunVideoNewService; |
| | | import com.yeshi.buwan.service.imp.juhe.IqiyiQueueService; |
| | | import com.yeshi.buwan.sohu.SoHuUtil; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.video.AcfunApiUtil; |
| | | |
| | | /** |
| | | * |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | @Component |
| | | public class JuHeVideoUpdateJob { |
| | | @Resource |
| | | private IqiyiUtil iqiyiUtil; |
| | | @Resource |
| | | private SoHuUtil soHuUtil; |
| | | @Resource |
| | | private IqiyiUtil iqiyiUtil; |
| | | |
| | | @Resource |
| | | private FunTVUtil funTVUtil; |
| | | @Resource |
| | | private IqiyiQueueService iqiyiQueueService; |
| | | |
| | | @Resource |
| | | private AcFunUtil acFunUtil; |
| | | private static int c = 1; |
| | | |
| | | @Resource |
| | | private IqiyiQueueService iqiyiQueueService; |
| | | public JuHeVideoUpdateJob() { |
| | | System.out.println("============================================实例化次数:" + c); |
| | | ++c; |
| | | } |
| | | |
| | | @Resource |
| | | private AcfunVideoNewService acfunVideoNewService; |
| | | // @Scheduled(cron = "0 25 17 * * ?") |
| | | // 暂时注释掉 |
| | | @Scheduled(cron = "0 0 0,9,14,20 * * ?") |
| | | public void doJob() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | System.out.println("VideoUpdateJob-doJob"); |
| | | new Thread(new Runnable() { |
| | | public void run() { |
| | | LogHelper.iqiyi("更新iaiyi。。。。。。"); |
| | | iqiyiUtil.updateAll(""); |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | private static int c = 1; |
| | | |
| | | public JuHeVideoUpdateJob() { |
| | | System.out.println("============================================实例化次数:" + c); |
| | | ++c; |
| | | } |
| | | |
| | | // @Scheduled(cron = "0 25 17 * * ?") |
| | | // 暂时注释掉 |
| | | @Scheduled(cron = "0 0 0,9,14,20 * * ?") |
| | | public void doJob() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | System.out.println("VideoUpdateJob-doJob"); |
| | | new Thread(new Runnable() { |
| | | public void run() { |
| | | LogHelper.iqiyi("更新iaiyi。。。。。。"); |
| | | iqiyiUtil.updateAll(""); |
| | | } |
| | | }).start(); |
| | | |
| | | // new Thread(new Runnable() { |
| | | // |
| | | // public void run() { |
| | | // soHuUtil.parseAll(); |
| | | // } |
| | | // }).start(); |
| | | |
| | | // new Thread(new Runnable() { |
| | | // |
| | | // public void run() { |
| | | // YouKuDJUtil.startParseUpdate(); |
| | | // } |
| | | // }).start(); |
| | | // |
| | | // new Thread(new Runnable() { |
| | | // |
| | | // public void run() { |
| | | // YouKuDJUtil.startParseDelete(); |
| | | // } |
| | | // }).start(); |
| | | |
| | | // new Thread(new Runnable() { |
| | | // |
| | | // public void run() { |
| | | // pptvUtil.startParseTV(); |
| | | // } |
| | | // }).start(); |
| | | // |
| | | // new Thread(new Runnable() { |
| | | // |
| | | // public void run() { |
| | | // pptvUtil.startParseMovie(); |
| | | // pptvUtil.startParseShow(); |
| | | // pptvUtil.startParseCartoon(); |
| | | // pptvUtil.startParseShortVideo(); |
| | | // } |
| | | // }).start(); |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 2 * * ?") |
| | | public void updateAcFun() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | |
| | | AcfunVideoResult result = AcfunApiUtil.videoList(""); |
| | | while (result != null && result.pcursor != null && !result.pcursor.equalsIgnoreCase("no_more")) { |
| | | if (result.videoList != null) { |
| | | acfunVideoNewService.save(result.videoList); |
| | | for (AcfunVideoNew video : result.videoList) |
| | | try { |
| | | acFunUtil.addVideo(video); |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | result = AcfunApiUtil.videoList(result.pcursor); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 3,4 * * ? ") |
| | | // @Scheduled(cron = "0 52 * * * ? ") |
| | | public void updateFuntvAll() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | synchronized (funTVUtil) { |
| | | funTVUtil.startUpdate(); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 0/1 * * ? ") |
| | | public void updateFuntv() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | synchronized (funTVUtil) { |
| | | funTVUtil.startUpdate(); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 5 0,12,20 * * ? ") |
| | | public void updateIqiyiQueue() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | synchronized (iqiyiQueueService) { |
| | | List<IqiyiUpdateQueue> queueList = iqiyiQueueService.listUpdateQueue(); |
| | | for (IqiyiUpdateQueue queue : queueList) { |
| | | String aid = null; |
| | | int count = 0; |
| | | while (StringUtil.isNullOrEmpty(aid) && count < 3) { |
| | | if (StringUtil.isNullOrEmpty(queue.getAid())) { |
| | | aid = IqiYiNewAPI.getAidByUrl(queue.getUrl()); |
| | | count++; |
| | | try { |
| | | Thread.sleep(1000 * 2); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else |
| | | aid = queue.getAid(); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(aid)) { |
| | | queue.setAid(aid); |
| | | iqiyiQueueService.updateUpdateQueue(queue); |
| | | iqiyiUtil.updateAlbum(aid); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @Scheduled(cron = "0 5 0,12,20 * * ? ") |
| | | public void updateIqiyiQueue() { |
| | | if (!Constant.JobTasker) |
| | | return; |
| | | synchronized (iqiyiQueueService) { |
| | | List<IqiyiUpdateQueue> queueList = iqiyiQueueService.listUpdateQueue(); |
| | | for (IqiyiUpdateQueue queue : queueList) { |
| | | String aid = null; |
| | | int count = 0; |
| | | while (StringUtil.isNullOrEmpty(aid) && count < 3) { |
| | | if (StringUtil.isNullOrEmpty(queue.getAid())) { |
| | | aid = IqiYiNewAPI.getAidByUrl(queue.getUrl()); |
| | | count++; |
| | | try { |
| | | Thread.sleep(1000 * 2); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } else |
| | | aid = queue.getAid(); |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(aid)) { |
| | | queue.setAid(aid); |
| | | iqiyiQueueService.updateUpdateQueue(queue); |
| | | iqiyiUtil.updateAlbum(aid); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |