admin
2021-01-25 cbc9ffb792e29beddf15dbfa70437bfc40de5baa
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
package com.yeshi.buwan.pptv;
 
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoType;
import com.yeshi.buwan.pptv.entity.PPTVProgram;
import com.yeshi.buwan.pptv.entity.PPTVSeries;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.video.VideoConstant;
import com.yeshi.buwan.vo.AcceptData;
 
public class PPTVUtil {
 
    public final static int RESOURCE_ID=25;
 
    public final static int PLAY_NONE = 0;// 不能播放
    public final static int PLAY_HTML = 1;// 跳转移动端网页播放
    public final static int PLAY_SDK = 2;// 内嵌SDK播放
 
 
    private static Long getVideoType(PPTVSeries series) {
        String type = series.getProgramType();
        if (type.contains("VIP")) {
            type = series.getProgramType2();
        }
 
        int videoType = 0;
        switch (type) {
            case "电影":
                videoType = VideoConstant.VIDEO_CATEGORY_DIANYING;
                break;
            case "电视剧":
                videoType = VideoConstant.VIDEO_CATEGORY_DIANSHIJU;
                break;
            case "综艺":
                videoType = VideoConstant.VIDEO_CATEGORY_ZONGYI;
                break;
            case "动漫":
                videoType = VideoConstant.VIDEO_CATEGORY_DONGMAN;
                break;
            default:
        }
 
        return (long) videoType;
    }
 
 
    /**
     * 视频转换
     *
     * @param series
     * @return
     */
    public static VideoInfo convertToVideoInfo(PPTVSeries series) {
        int year = Integer.parseInt(series.getReleaseYear());
        int month = 1;
        int day = 1;
        String director = series.getDirector();
        String mainActor = series.getActor();
 
        String score = series.getScore();
 
        String tag = "";
        VideoType videoType = new VideoType(getVideoType(series));
 
        //电影
        if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_DIANYING) {
            tag = "评分:" + score;
        } else if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_DIANSHIJU || videoType.getId() == VideoConstant.VIDEO_CATEGORY_DONGMAN) {
            //电视剧,动漫
            if (series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) {
                tag = series.getSeriesCount() + "集全";
            } else {
                tag = "更新至" + series.getCurrentNum() + "集";
            }
        } else if (videoType.getId() == VideoConstant.VIDEO_CATEGORY_ZONGYI) {
            //综艺
            if (!StringUtil.isNullOrEmpty(series.getCurrentNum())) {
                tag = series.getCurrentNum().replace("期", "");
            } else {
                tag = series.getPublishTime().split(" ")[0];
            }
        }
 
 
        String latestHpicture = series.getSeries().get(series.getSeries().size() - 1).getSubHorCover();
 
        long updateTime = System.currentTimeMillis();
 
        VideoInfo vi = new VideoInfo();
        vi.setVideoType(videoType);
        vi.setArea(series.getCountry());
        vi.setBaseurl("");
        vi.setCanSave(false);
        vi.setCommentCount(0);
        vi.setContentType(1);
        vi.setCreatetime(System.currentTimeMillis());
        vi.setDay(day + "");
        vi.setDirector(director);
        vi.setFocus("");
        vi.setHpicture(series.getHorCover());
        vi.setIntroduction(series.getDescription());
        vi.setLatestHpicture(latestHpicture);
        vi.setLatestVpicture("");
        vi.setMainActor(mainActor);
        vi.setMonth(month + "");
        vi.setName(series.getName());
        vi.setNowNumber(0 + "");
        vi.setOrderby("0");
        vi.setPicture(series.getCover());
        vi.setScore(score);
        vi.setShare("0");
        vi.setShow(1 + "");
        vi.setTag(tag);
        vi.setVpicture(series.getCover());
        vi.setWatchCount(0 + "");
        vi.setYear(year + "");
        vi.setUpdatetime(updateTime + "");
        vi.setVideocount(series.getSeries().size());
        return vi;
    }
 
 
    public static int getPlayType(AcceptData acceptData, PPTVProgram pptvProgram) {
        if (!pptvProgram.getStatus().equalsIgnoreCase("del")) {
            return PLAY_SDK;
        } else {
            return PLAY_NONE;
        }
    }
 
}