| | |
| | | |
| | | 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;// 嵌套网页播放 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 添加爱奇艺小视频 |
| | | * |
| | |
| | | } |
| | | |
| | | 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()) { |
| | |
| | | } 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()) { |