admin
2020-09-12 2778cf2a16823f9b1153a0549b47f7b503176a17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package com.yeshi.buwan.job;
 
import java.util.List;
 
import javax.annotation.Resource;
 
import com.yeshi.buwan.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.log.LogHelper;
import com.yeshi.buwan.pptv.PPTVUtil;
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 VideoUpdateJob {
    @Resource
    private IqiyiUtil iqiyiUtil;
    @Resource
    private SoHuUtil soHuUtil;
 
    @Resource
    private PPTVUtil pptvUtil;
 
    @Resource
    private FunTVUtil funTVUtil;
 
    @Resource
    private AcFunUtil acFunUtil;
 
    @Resource
    private IqiyiQueueService iqiyiQueueService;
 
    @Resource
    private AcfunVideoNewService acfunVideoNewService;
 
    private static int c = 1;
 
    public VideoUpdateJob() {
        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);
                }
            }
        }
    }
 
}