admin
2020-10-13 fc7a6634496066fe45dca8ea9832bdd2f7341db4
src/main/java/com/yeshi/buwan/iqiyi/util/IqiyiUtil.java
@@ -62,6 +62,10 @@
    static Logger logger = Logger.getLogger(IqiyiUtil.class);
    public final static int RESOURCE_ID = 13;
    public final static String RESOURCE_NAME = "爱奇艺";
    public final int PLAY_NONE = 0;// 不能播放
    public final int PLAY_HTML = 1;// 跳转移动端网页播放
    public final int PLAY_SWF = 2;// 嵌套网页播放
@@ -1691,51 +1695,6 @@
        }
    }
    public static String getAlbumIdFromPlayUrl(String url) {
        try {
            Document doc = Jsoup.connect(url)
                    .userAgent(
                            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36")
                    .timeout(6000).get();
            try {
                Elements els = doc.getElementsByTag("script");
                String albumId = null;
                for (int i = 0; i < els.size(); i++) {
                    System.out.println(els.get(i).toString());
                    if (els.get(i).toString().contains("Q.PageInfo.playPageInfo")
                            && els.get(i).toString().contains("albumId")) {
                        String content = els.get(i).html();
                        content = content.substring(content.indexOf("albumId"), content.length());
                        albumId = content.split(",")[0].replace("albumId", "").replace("\"", "").replace(":", "")
                                .replace(";", "").trim();
                        if (!StringUtil.isNullOrEmpty(albumId) && Long.parseLong(albumId) > 0)
                            return albumId;
                    }
                }
                if (StringUtil.isNullOrEmpty(albumId) || Long.parseLong(albumId) <= 0) {
                    for (int i = 0; i < els.size(); i++) {
                        if (els.get(i).toString().contains("window.QiyiPlayerLoader")
                                && els.get(i).toString().contains("param['albumid']")) {
                            String content = els.get(i).html();
                            content = content.substring(content.indexOf("param['albumid'] ="), content.length());
                            albumId = content.split(";")[0].replace("param['albumid'] =", "").replace("\"", "").trim();
                            return albumId;
                        }
                    }
                }
            } catch (Exception e) {
            }
            String json = doc.getElementById("iqiyi-main").getElementsByTag("div").get(0).attr(":page-info");
            return JSONObject.fromObject(json).optString("albumId");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 添加爱奇艺小视频
     *
@@ -1756,7 +1715,7 @@
    }
    public static String getHPicture(String url) {
        String regex = "_m[0-9]\\.jpg";
        String regex = "_m[0-9]+\\.jpg";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(url);
        if (m.find()) {
@@ -1764,12 +1723,10 @@
        } else {
            return url;
        }
    }
    public static String getVPicture(String url) {
        String regex = "_m[0-9]\\.jpg";
        String regex = "_m[0-9]+\\.jpg";
        Pattern p = Pattern.compile(regex);
        Matcher m = p.matcher(url);
        if (m.find()) {