admin
2021-04-02 d551bef5e2b09bd98681cf97807988c9863e66fc
src/main/java/com/yeshi/buwan/pptv/PPTVUtil.java
@@ -4,13 +4,14 @@
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.AESUtil;
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 RESOURCE_ID = 25;
    public final static int PLAY_NONE = 0;// 不能播放
    public final static int PLAY_HTML = 1;// 跳转移动端网页播放
@@ -37,7 +38,11 @@
            case "动漫":
                videoType = VideoConstant.VIDEO_CATEGORY_DONGMAN;
                break;
            case "少儿":
                videoType = 312;
                break;
            default:
                return null;
        }
        return (long) videoType;
@@ -60,14 +65,18 @@
        String score = series.getScore();
        String tag = "";
        VideoType videoType = new VideoType(getVideoType(series));
        Long videoTypeId = getVideoType(series);
        if (videoTypeId == null)
            return null;
        VideoType videoType = new VideoType(videoTypeId);
        //电影
        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())) {
            if (series.getCurrentNum() != null && series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) {
                tag = series.getSeriesCount() + "集全";
            } else {
                tag = "更新至" + series.getCurrentNum() + "集";
@@ -78,6 +87,20 @@
                tag = series.getCurrentNum().replace("期", "");
            } else {
                tag = series.getPublishTime().split(" ")[0];
            }
        } else {
            if ("1".equalsIgnoreCase(series.getSeriesCount())) {
                tag = "评分:" + score;
            } else {
                if (series.getCurrentNum() != null && series.getSeriesCount().trim().equalsIgnoreCase(series.getCurrentNum().trim())) {
                    tag = series.getSeriesCount() + "集全";
                } else {
                    if (series.getCurrentNum() != null)
                        tag = "更新至" + series.getCurrentNum() + "集";
                    else {
                        tag = "更新至" + series.getSeriesCount() + "集";
                    }
                }
            }
        }
@@ -128,4 +151,73 @@
        }
    }
    /**
     * 获取pptv的用户ID
     *
     * @param uid
     * @return
     */
    public static String getPPTVUid(String uid) {
        return "buwan_" + uid;
    }
    /**
     * 获取pptvcode
     *
     * @param pptvUid
     * @return
     */
    public static String getPPTVCode(String pptvUid) {
        if (StringUtil.isNullOrEmpty(pptvUid))
            return null;
        return AESUtil.encrypt(pptvUid + "#" + System.currentTimeMillis()).replace("/", "_").replace("=", "-");
    }
    public static String getUidFromPPTVUid(String pptvUid) {
        return pptvUid.split("_")[1];
    }
    /**
     * 解密PPTVCode
     *
     * @param code
     * @return
     */
    public static PPTVCodeInfo decryptPPTVCode(String code) {
        code = code.replace("_", "/").replace("-", "=");
        String info = AESUtil.decrypt(code);
        if (StringUtil.isNullOrEmpty(info)) {
            return null;
        } else {
            String[] sts = info.split("#");
            if (sts.length != 2)
                return null;
            PPTVCodeInfo codeInfo = new PPTVCodeInfo();
            codeInfo.pptvUid = sts[0];
            codeInfo.time = Long.parseLong(sts[1]);
            return codeInfo;
        }
    }
    /**
     * 获取播放链接
     *
     * @param series
     * @param program
     * @return
     */
    public static String getPlayUrl(PPTVSeries series, PPTVProgram program) {
        //programtype 电影-3  其他-2
        return String.format("https://acmd.api.pptv.com/2021/bwysdqmovie_thrid_h5.html?cid=%s&vid=%s&programtype=%s", series.getSeriesCode(), program.getProgramCode(), series.getProgramType().contains("电影") ? 3 : 2);
//        return String.format(" http://vip.pptv.com/activity/2021/pg_bwysdqmovie?cid=%s&vid=%s&programtype=%s", series.getSeriesCode(), program.getProgramCode(), series.getProgramType().contains("电影") ? 3 : 2);
    }
    public static class PPTVCodeInfo {
        public String pptvUid;
        public long time;
    }
}