admin
2020-10-10 81db7b3b070c003e6f5f0d1c757ab30b6f42c944
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
package com.yeshi.buwan.pptv;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Component;
 
import com.yeshi.buwan.dao.juhe.pptv.PPTVMovieVideoDao;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.pptv.entity.PPTVCartoonDetail;
import com.yeshi.buwan.pptv.entity.PPTVCartoonVideo;
import com.yeshi.buwan.pptv.entity.PPTVMovieVideo;
import com.yeshi.buwan.pptv.entity.PPTVShortVideo;
import com.yeshi.buwan.pptv.entity.PPTVShowDetail;
import com.yeshi.buwan.pptv.entity.PPTVShowVideo;
import com.yeshi.buwan.pptv.entity.PPTVTVDetail;
import com.yeshi.buwan.pptv.entity.PPTVTVVideo;
import com.yeshi.buwan.service.imp.juhe.PPTVService;
import com.yeshi.buwan.util.HttpUtil;
import com.yeshi.buwan.util.NumberUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
 
@Component
public class PPTVUtil {
 
    public final static int RESOURCE_ID = 16;
    public final static String RESOURCE_NAME = "PPTV";
 
    @Resource
    private PPTVService pptvService;
    @Resource
    private PPTVMovieVideoDao pptvMovieVideoDao;
 
 
 
    // 解析电影
    public void startParseMovie() {
        List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_MOVIE);
        for (String url : urlList) {
            List<PPTVMovieVideo> list = PPTVDataParseUtil.parseMovieListVideo(HttpUtil.get(url));
            for (PPTVMovieVideo pv : list) {
                if (pv.getOp().equalsIgnoreCase("del")) {// 删除
                    pptvService.deletePPTVMovie(pv);
                } else {// 增加或者更新
                    Serializable id = pptvService.saveOrUpdatePPTVMovie(pv);
                    if (id != null)
                        pptvService.addPPTVMovieToVideoInfo(pv, false);
                }
            }
        }
    }
 
    // 解析电视剧
    public void startParseTV() {
        List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_TV);
        for (int p = 0; p < urlList.size(); p++) {
            String url = urlList.get(p);
            List<PPTVTVVideo> list = PPTVDataParseUtil.parseTVListVideo(HttpUtil.get(url));
            System.out.println(list.size());
            for (int n = 0; n < list.size(); n++) {
                PPTVTVVideo pv = list.get(n);
                if (pv.getOp().equalsIgnoreCase("del")) {// 删除
                    pptvService.deletePPTVTV(pv);
                } else {// 增加或者更新
                    String videoid = pptvService.saveOrUpdatePPTVTV(pv) + "";
                    boolean isUpdate = pptvService.hasTVUpdate(pv.getDetailList());
                    for (PPTVTVDetail pd : pv.getDetailList()) {
 
                        pd.setVideoId(pv.getAid());
                        if (pd.getOp().equalsIgnoreCase("del")) {
                            pptvService.deletePPTVTVDetail(pd);
                        } else {
                            pptvService.saveOrUpdatePPTVTVDetail(pd);
                        }
                    }
                    if (!StringUtil.isNullOrEmpty(videoid))
                        pptvService.addPPTVTVToVideoInfo(pv, isUpdate);
                }
            }
        }
    }
 
    // 解析综艺
    public void startParseShow() {
        List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_SHOW);
        for (String url : urlList) {
            List<PPTVShowVideo> list = PPTVDataParseUtil.parseShowListVideo(HttpUtil.get(url));
            for (PPTVShowVideo pv : list) {
                if (pv.getOp().equalsIgnoreCase("del")) {// 删除
                    pptvService.deletePPTVShow(pv);
                } else {// 增加或者更新
                    String videoid = pptvService.saveOrUpdatePPTVShow(pv) + "";
                    boolean isUpdate = pptvService.hasShowUpdate(pv.getDetailList());
                    for (PPTVShowDetail pd : pv.getDetailList()) {
                        pd.setVideoId(pv.getAid());
                        if (pd.getOp().equalsIgnoreCase("del")) {
                            pptvService.deletePPTVShowDetail(pd);
                        } else {
                            pptvService.saveOrUpdatePPTVShowDetail(pd);
                        }
                    }
                    if (!StringUtil.isNullOrEmpty(videoid))
                        pptvService.addPPTVShowToVideoInfo(pv, isUpdate);
                }
            }
        }
    }
 
    // 解析卡通
    public void startParseCartoon() {
        List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_CARTON);
        for (String url : urlList) {
            List<PPTVCartoonVideo> list = PPTVDataParseUtil.parseCartoonListVideo(HttpUtil.get(url));
            for (PPTVCartoonVideo pv : list) {
                if (pv.getOp().equalsIgnoreCase("del")) {// 删除
                    pptvService.deletePPTVCartoon(pv);
                } else {// 增加或者更新
                    String videoid = pptvService.saveOrUpdatePPTVCartoon(pv) + "";
                    boolean isUpdate = pptvService.hasCartoonUpdate(pv.getDetailList());
                    for (PPTVCartoonDetail pd : pv.getDetailList()) {
                        pd.setVideoId(pv.getAid());
                        if (pd.getOp().equalsIgnoreCase("del")) {
                            pptvService.deletePPTVCartoonDetail(pd);
                        } else {
                            pptvService.saveOrUpdatePPTVCartoonDetail(pd);
                        }
                    }
                    if (!StringUtil.isNullOrEmpty(videoid))
                        pptvService.addPPTVCartoonToVideoInfo(pv, isUpdate);
                }
            }
        }
    }
 
    // 解析小视频
    public void startParseShortVideo() {
        List<String> urlList = PPTVApi.getPageUrl(PPTVApi.PPTV_UPDATE_SHORTVIDEO);
        for (String url : urlList) {
            List<PPTVShortVideo> list = PPTVDataParseUtil.parseShortListVideo(HttpUtil.get(url));
            for (PPTVShortVideo pv : list) {
                if (pv.getOp().equalsIgnoreCase("del")) {// 删除
                    pptvService.deletePPTVShort(pv);
                } else {// 增加或者更新
                    Serializable id = pptvService.saveOrUpdatePPTVShort(pv);
                    if (id != null)
                        pptvService.addPPTVShortToVideoInfo(pv, false);
                }
            }
        }
    }
 
    // 获取分类
    public static List<Integer> getTypeList(String rc, String sc) {
        List<Integer> list = new ArrayList<Integer>();
        if (rc.equalsIgnoreCase("电影")) {
            if ("预告".equalsIgnoreCase(sc)) {
                list.add(281);
            } else if ("用户上传".equalsIgnoreCase(sc)) {
                list.add(281);
            } else {
                list.add(151);
            }
 
        } else if (rc.equalsIgnoreCase("电视剧")) {
            if ("预告".equalsIgnoreCase(sc)) {
                list.add(282);
            } else if ("剧八卦".equalsIgnoreCase(sc)) {
                list.add(282);
            } else
                list.add(150);
 
        } else if (rc.equalsIgnoreCase("卡通")) {// 现场 预告 MV 原创 音乐 自制 用户上传
            if ("现场".equalsIgnoreCase(sc)) {
                list.add(283);
            } else if ("预告".equalsIgnoreCase(sc)) {
                list.add(283);
            } else if ("MV".equalsIgnoreCase(sc)) {
                list.add(283);
            } else if ("原创".equalsIgnoreCase(sc)) {
                list.add(283);
            } else if ("音乐".equalsIgnoreCase(sc)) {
                list.add(283);
            } else if ("自制".equalsIgnoreCase(sc)) {
                list.add(283);
            } else if ("用户上传".equalsIgnoreCase(sc)) {
                list.add(283);
            } else
                list.add(153);
 
        } else if (rc.equalsIgnoreCase("综艺")) {
            list.add(152);
        } else if (rc.equalsIgnoreCase("生活")) {// 美味食刻 萌宠萌宝 新辣生活 健康休闲 生活窍门 用户上传
                                                // 猎奇趣闻
            if ("美味食刻".equalsIgnoreCase(sc)) {
                list.add(228);
            } else if ("萌宠萌宝".equalsIgnoreCase(sc)) {
            } else if ("新辣生活".equalsIgnoreCase(sc)) {
                list.add(230);
            } else if ("健康休闲".equalsIgnoreCase(sc)) {
                list.add(230);
            } else if ("生活窍门".equalsIgnoreCase(sc)) {
                list.add(230);
            } else if ("用户上传".equalsIgnoreCase(sc)) {
            } else if ("猎奇趣闻".equalsIgnoreCase(sc)) {
            }
 
        } else if (rc.equalsIgnoreCase("时尚")) {// 秀场传真 媒体专区 美丽课堂 视觉大赏 用户上传 风尚快报
                                                // 潮流关键词 时尚人物 品牌风向标
            if ("秀场传真".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("媒体专区".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("美丽课堂".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("视觉大赏".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("用户上传".equalsIgnoreCase(sc)) {
            } else if ("风尚快报".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("潮流关键词".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("时尚人物".equalsIgnoreCase(sc)) {
                list.add(232);
            } else if ("品牌风向标".equalsIgnoreCase(sc)) {
                list.add(232);
            }
 
        } else if (rc.equalsIgnoreCase("音乐")) {// 舞蹈 不要 音乐节 用户上传 颁奖礼 翻唱猎奇 自制音乐
                                                // 乐人无数 戏曲 新歌首发 音乐资讯 内地 港台 台湾音乐
                                                // 日本 韩国 欧美 现场 合作比赛 影视原声 其他
            if ("舞蹈".equalsIgnoreCase(sc)) {
                list.add(303);
            } else if ("不要".equalsIgnoreCase(sc)) {
            } else if ("音乐节".equalsIgnoreCase(sc)) {
            } else if ("用户上传".equalsIgnoreCase(sc)) {
            } else if ("颁奖礼".equalsIgnoreCase(sc)) {
            } else if ("翻唱猎奇".equalsIgnoreCase(sc)) {
                list.add(304);
            } else if ("自制音乐".equalsIgnoreCase(sc)) {
            } else if ("乐人无数".equalsIgnoreCase(sc)) {
            } else if ("戏曲".equalsIgnoreCase(sc)) {
            } else if ("新歌首发".equalsIgnoreCase(sc)) {
            } else if ("音乐资讯".equalsIgnoreCase(sc)) {
                list.add(280);
            } else if ("内地".equalsIgnoreCase(sc)) {
            } else if ("港台".equalsIgnoreCase(sc)) {
            } else if ("台湾音乐".equalsIgnoreCase(sc)) {
            } else if ("日本".equalsIgnoreCase(sc)) {
            } else if ("韩国".equalsIgnoreCase(sc)) {
            } else if ("欧美".equalsIgnoreCase(sc)) {
            } else if ("现场".equalsIgnoreCase(sc)) {
                list.add(303);
            } else if ("合作比赛".equalsIgnoreCase(sc)) {
            } else if ("影视原声".equalsIgnoreCase(sc)) {
                list.add(279);
            } else if ("其他".equalsIgnoreCase(sc)) {
                list.add(280);
            }
 
        } else if (rc.equalsIgnoreCase("旅游")) {// 酒店之选 极致旅游 旷世美景 舌尖美食 用户上传 走遍中国
                                                // 香艳之旅 环球畅游 出境游(港澳台) 热点推荐 户外猎奇
                                                // 沿途春色 人文风物 旅游焦点 网友攻略
            list.add(229);
            if ("酒店之选".equalsIgnoreCase(sc)) {
            } else if ("极致旅游".equalsIgnoreCase(sc)) {
            } else if ("旷世美景".equalsIgnoreCase(sc)) {
            } else if ("舌尖美食".equalsIgnoreCase(sc)) {
            } else if ("用户上传".equalsIgnoreCase(sc)) {
            } else if ("走遍中国".equalsIgnoreCase(sc)) {
            } else if ("香艳之旅".equalsIgnoreCase(sc)) {
            } else if ("环球畅游".equalsIgnoreCase(sc)) {
            } else if ("出境游(港澳台)".equalsIgnoreCase(sc)) {
            } else if ("热点推荐".equalsIgnoreCase(sc)) {
            } else if ("户外猎奇".equalsIgnoreCase(sc)) {
            } else if ("沿途春色".equalsIgnoreCase(sc)) {
            } else if ("人文风物".equalsIgnoreCase(sc)) {
            } else if ("旅游焦点".equalsIgnoreCase(sc)) {
            } else if ("网友攻略".equalsIgnoreCase(sc)) {
            }
 
        } else if (rc.equalsIgnoreCase("搞笑")) {// 郭德纲专场 爆笑秀场 周立波专场 囧人囧片 用户上传
                                                // 恶搞整蛊 搞笑自拍 相声小品 超萌系列 动物奇趣 开心广告
            if ("郭德纲专场".equalsIgnoreCase(sc)) {
                list.add(217);
            } else if ("爆笑秀场".equalsIgnoreCase(sc)) {
                list.add(216);
            } else if ("周立波专场".equalsIgnoreCase(sc)) {
                list.add(217);
            } else if ("囧人囧片".equalsIgnoreCase(sc)) {
                list.add(216);
            } else if ("用户上传".equalsIgnoreCase(sc)) {
            } else if ("恶搞整蛊".equalsIgnoreCase(sc)) {
                list.add(216);
            } else if ("搞笑自拍".equalsIgnoreCase(sc)) {
                list.add(216);
            } else if ("相声小品".equalsIgnoreCase(sc)) {
                list.add(217);
            } else if ("超萌系列".equalsIgnoreCase(sc)) {
                list.add(220);
            } else if ("动物奇趣".equalsIgnoreCase(sc)) {
                list.add(220);
            } else if ("开心广告".equalsIgnoreCase(sc)) {
                list.add(216);
            }
        }
        return list;
    }
 
    private static String getScore(String vid) {
        String result = HttpUtil
                .get("http://epg.api.pptv.com/detail.api?auth=d410fafad87e7bbf6c6dd62434345818&canal=17&userLevel=0&ppi=AgACAAAABwAABOUAAAAHAAAAAFf5GACAuIIVSMh5Qi0t_zR3NmUpIHR91aabBP6RHKxiYkX3RBkET2s_BTUB5ewNFjXCLeUkiUqMCreGl70MnKLhRpth&appid=com.pplive.androidphone&appver=6.1.5&appplt=aph&vid="
                        + vid
                        + "&series=1&virtual=1&ver=4&platform=android3&contentType=Preview&vr=3d%2Cvr360%2Cvr180");
        String score = PPTVDataParseUtil.parseScore(result);
        return score;
    }
 
    public static VideoInfo convertMovieToVideoInfo(PPTVMovieVideo pptv) {
        String score = getScore(pptv.getVid());
        String showTime = pptv.getShowTime();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd"));
        String year = calendar.get(Calendar.YEAR) + "";
        String month = calendar.get(Calendar.MONTH) + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
 
        VideoInfo video = new VideoInfo();
        String area = "";
        for (String st : pptv.getRegion().split("\\$\\$"))
            area += st + " ";
        video.setArea(area);
        video.setBaseurl("");
        video.setCanSave(false);
        video.setCommentCount(0);
        video.setContentType(1);
        video.setCreatetime(System.currentTimeMillis());
        video.setDay(day);
        String director = "";
        for (String st : pptv.getDirector().split("\\$\\$"))
            director += st + " ";
 
        video.setDirector(director);
        video.setHpicture(pptv.getHorizontalPoster());
        video.setIntroduction(pptv.getIntroduction());
        video.setLatestHpicture(pptv.getHorizontalPoster());
        video.setLatestVpicture(pptv.getNewPoster());
        video.setLatestWatchCount(0);
        String mainActor = "";
        for (String st : pptv.getStarring().split("\\$\\$"))
            mainActor += st + " ";
        video.setMainActor(mainActor);
        video.setMonth(month);
        video.setName(pptv.getWorkName());
        video.setNowNumber(0 + "");
        video.setOrderby(0 + "");
        video.setPicture(pptv.getNewPoster());
        video.setPlayPicture(pptv.getHorizontalPoster());
        video.setScore(score);
        video.setShare("0");
        video.setShow("1");
        video.setTag("评分:" + score);
        video.setThirdType("0");
        video.setTotalNumber("0");
        video.setUpdatetime(calendar.getTimeInMillis() + "");
        video.setVideocount(1);
        video.setVpicture(pptv.getNewPoster());
        video.setWatchCount(0 + "");
        video.setYear(year);
        return video;
    }
 
    public static VideoInfo convertTVToVideoInfo(PPTVTVVideo pptv) {
        Comparator<PPTVTVDetail> cm = new Comparator<PPTVTVDetail>() {
            public int compare(PPTVTVDetail o1, PPTVTVDetail o2) {
                return (int) (Long.parseLong(o1.getSeq()) - Long.parseLong(o2.getSeq()));
            }
        };
 
        Collections.sort(pptv.getDetailList(), cm);
 
        String score = getScore(pptv.getDetailList().get(0).getVid());
        String showTime = pptv.getDetailList().get(pptv.getDetailList().size() - 1).getResourceTime();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd HH:mm:ss"));
        String year = calendar.get(Calendar.YEAR) + "";
        String month = calendar.get(Calendar.MONTH) + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
 
        VideoInfo video = new VideoInfo();
        String area = "";
        for (String st : pptv.getRegion().split("\\$\\$"))
            area += st + " ";
        video.setArea(area);
        video.setBaseurl("");
        video.setCanSave(false);
        video.setCommentCount(0);
        video.setContentType(1);
        video.setCreatetime(System.currentTimeMillis());
        video.setDay(day);
        String director = "";
        for (String st : pptv.getDirector().split("\\$\\$"))
            director += st + " ";
 
        video.setDirector(director);
        video.setHpicture(pptv.getHorizontalPoster());
        video.setIntroduction(pptv.getIntroduction());
        video.setLatestHpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getSingleThumbnails());
        video.setLatestVpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getPoster());
        video.setLatestWatchCount(0);
        String mainActor = "";
        for (String st : pptv.getStarring().split("\\$\\$"))
            mainActor += st + " ";
        video.setMainActor(mainActor);
        video.setMonth(month);
        video.setName(pptv.getWorkName());
        video.setNowNumber(0 + "");
        video.setOrderby(0 + "");
        video.setPicture(pptv.getNewPoster());
        video.setPlayPicture(pptv.getHorizontalPoster());
        video.setScore(score);
        video.setShare("0");
        video.setShow("1");
        if (Integer.parseInt(pptv.getNewUpdate()) == pptv.getTotalnumber())
            video.setTag(pptv.getNewUpdate() + "集全");
        else
            video.setTag("更新至" + pptv.getNewUpdate() + "集");
        video.setThirdType("0");
        video.setTotalNumber(pptv.getTotalnumber() + "");
        video.setUpdatetime(calendar.getTimeInMillis() + "");
        video.setVideocount(pptv.getDetailList().size());
        video.setVpicture(pptv.getNewPoster());
        video.setWatchCount(0 + "");
        video.setYear(year);
        return video;
    }
 
    public static VideoInfo convertShowToVideoInfo(PPTVShowVideo pptv) {
        Comparator<PPTVShowDetail> cm = new Comparator<PPTVShowDetail>() {
            public int compare(PPTVShowDetail o1, PPTVShowDetail o2) {
                return (int) (Long.parseLong(o1.getSeq()) - Long.parseLong(o2.getSeq()));
            }
        };
 
        Collections.sort(pptv.getDetailList(), cm);
 
        String score = getScore(pptv.getDetailList().get(0).getVid());
        String showTime = pptv.getShowTime();
        Calendar calendar = Calendar.getInstance();
        long time = TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd");
        if (time < 0)
            time = TimeUtil.convertGernalTime(pptv.getDetailList().get(0).getDate(), "yyyyMMdd");
 
        calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd"));
        String year = calendar.get(Calendar.YEAR) + "";
        String month = calendar.get(Calendar.MONTH) + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
 
        VideoInfo video = new VideoInfo();
        String area = "";
        for (String st : pptv.getRegion().split("\\$\\$"))
            area += st + " ";
        video.setArea(area);
        video.setBaseurl("");
        video.setCanSave(false);
        video.setCommentCount(0);
        video.setContentType(1);
        video.setCreatetime(System.currentTimeMillis());
        video.setDay(day);
        String director = "";
        for (String st : pptv.getHost().split("\\$\\$"))
            director += st + " ";
 
        video.setDirector(director);
        video.setHpicture(pptv.getHorizontalPoster());
        video.setIntroduction(pptv.getIntroduction());
        video.setLatestHpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getSingleThumbnails());
        video.setLatestVpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getPoster());
        video.setLatestWatchCount(0);
        String mainActor = "";
 
        video.setMainActor(mainActor);
        video.setMonth(month);
        video.setName(pptv.getWorkName());
        video.setNowNumber(0 + "");
        video.setOrderby(0 + "");
        video.setPicture(pptv.getNewPoster());
        video.setPlayPicture(pptv.getHorizontalPoster());
        video.setScore(score);
        video.setShare("0");
        video.setShow("1");
        video.setTag("更新至"
                + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(pptv.getNewUpdate(), "yyyyMMdd"), "yyyy-MM-dd"));
        video.setThirdType("0");
        video.setTotalNumber(pptv.getTotalNumber() + "");
        video.setUpdatetime(TimeUtil.convertGernalTime(pptv.getNewUpdate(), "yyyyMMdd") + "");
        video.setVideocount(pptv.getDetailList().size());
        video.setVpicture(pptv.getNewPoster());
        video.setWatchCount(0 + "");
        video.setYear(year);
        return video;
    }
 
    public static VideoInfo convertCartoonToVideoInfo(PPTVCartoonVideo pptv) {
        Comparator<PPTVCartoonDetail> cm = new Comparator<PPTVCartoonDetail>() {
            public int compare(PPTVCartoonDetail o1, PPTVCartoonDetail o2) {
                return (int) (Long.parseLong(o1.getSeq()) - Long.parseLong(o2.getSeq()));
            }
        };
 
        Collections.sort(pptv.getDetailList(), cm);
 
        String score = getScore(pptv.getDetailList().get(0).getVid());
        String showTime = pptv.getShowTime();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy"));
        String year = calendar.get(Calendar.YEAR) + "";
        String month = calendar.get(Calendar.MONTH) + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
 
        VideoInfo video = new VideoInfo();
        String area = "";
        for (String st : pptv.getRegion().split("\\$\\$"))
            area += st + " ";
        video.setArea(area);
        video.setBaseurl("");
        video.setCanSave(false);
        video.setCommentCount(0);
        video.setContentType(1);
        video.setCreatetime(System.currentTimeMillis());
        video.setDay(day);
        String director = "";
 
        video.setDirector(director);
        video.setHpicture(pptv.getHorizontalPoster());
        video.setIntroduction(pptv.getIntroduction());
        video.setLatestHpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getSingleThumbnails());
        video.setLatestVpicture(pptv.getDetailList().get(pptv.getDetailList().size() - 1).getPoster());
        video.setLatestWatchCount(0);
        String mainActor = "";
 
        video.setMainActor(mainActor);
        video.setMonth(month);
        video.setName(pptv.getWorkName());
        video.setNowNumber(0 + "");
        video.setOrderby(0 + "");
        video.setPicture(pptv.getNewPoster());
        video.setPlayPicture(pptv.getHorizontalPoster());
        video.setScore(score);
        video.setShare("0");
        video.setShow("1");
        if (Integer.parseInt(pptv.getNewUpdate()) == pptv.getTotalNumber())
            video.setTag(pptv.getNewUpdate() + "集全");
        else
            video.setTag("更新至" + pptv.getNewUpdate() + "集");
        video.setThirdType("0");
        video.setTotalNumber(pptv.getTotalNumber() + "");
        video.setUpdatetime(calendar.getTimeInMillis() + "");
        video.setVideocount(pptv.getDetailList().size());
        video.setVpicture(pptv.getNewPoster());
        video.setWatchCount(0 + "");
        video.setYear(year);
        return video;
    }
 
    public static VideoInfo convertShortToVideoInfo(PPTVShortVideo pptv) {
        String showTime = pptv.getPublish();
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(TimeUtil.convertGernalTime(showTime, "yyyy-MM-dd HH:mm:ss"));
        String year = calendar.get(Calendar.YEAR) + "";
        String month = calendar.get(Calendar.MONTH) + "";
        String day = calendar.get(Calendar.DAY_OF_MONTH) + "";
 
        String[] sts = pptv.getDuration().split(":");
        int t = 0;
        if (sts.length == 3)
            t = Integer.parseInt(sts[0]) * 3600 + Integer.parseInt(sts[1]) * 60 + Integer.parseInt(sts[2]);
        else if (sts.length == 2)
            t = Integer.parseInt(sts[0]) * 60 + Integer.parseInt(sts[1]);
        else if (sts.length == 1)
            t = Integer.parseInt(sts[0]);
 
        String tag = NumberUtil.convertSecondToString(t);
        VideoInfo video = new VideoInfo();
        String area = "";
 
        video.setArea(area);
        video.setBaseurl("");
        video.setCanSave(false);
        video.setCommentCount(0);
        video.setContentType(1);
        video.setCreatetime(System.currentTimeMillis());
        video.setDay(day);
        String director = "";
        video.setDirector(t + "");
        video.setHpicture(pptv.getHorizontalPoster());
        video.setIntroduction(pptv.getIntroduction());
        video.setLatestHpicture("");
        video.setLatestVpicture("");
        video.setLatestWatchCount(0);
        String mainActor = "";
 
        video.setMainActor(mainActor);
        video.setMonth(month);
        video.setName(pptv.getSingleTitle());
        video.setNowNumber(0 + "");
        video.setOrderby(0 + "");
        video.setPicture(pptv.getHorizontalPoster());
        video.setPlayPicture(pptv.getHorizontalPoster());
        video.setScore("9.0");
        video.setShare("0");
        video.setShow("1");
        video.setTag(tag);
        video.setThirdType("0");
        video.setTotalNumber("1");
        video.setUpdatetime(calendar.getTimeInMillis() + "");
        video.setVideocount(1);
        video.setVpicture("");
        video.setWatchCount(0 + "");
        video.setYear(year);
        return video;
    }
 
    public static List<Integer> getVideoTypeList(String ft, String typeStr) {
        List<Integer> typeList = new ArrayList<Integer>();
        String[] types = (typeStr + "").split("\\$\\$");
        Set<Integer> set = new TreeSet<Integer>();
        for (String tp : types) {
            List<Integer> typeL = PPTVUtil.getTypeList(ft, tp);
            for (Integer i : typeL)
                set.add(i);
        }
        Iterator<Integer> its = set.iterator();
        while (its.hasNext()) {
            typeList.add(its.next());
        }
        if (typeList.size() == 0)
            typeList.add(299);
 
        return typeList;
    }
 
}