示例#1
0
 /**
  * 获取 迅雷 云播的 地址
  *
  * @param url
  * @param headers
  * @param pairs
  * @return
  */
 public static ArrayList<VideoPlayUrl> getPlayUrl(
     String url, Header[] headers, NameValuePair[] pairs) {
   try {
     ArrayList<VideoPlayUrl> urls = new ArrayList<VideoPlayUrl>();
     String json = HttpUtils.getContent(url, headers, pairs);
     if (TextUtils.equals(json, null)) {
       return null;
     }
     JSONTokener jsonParser = new JSONTokener(json);
     JSONObject object = (JSONObject) jsonParser.nextValue();
     JSONObject resp = object.getJSONObject("resp");
     JSONArray array = resp.getJSONArray("vodinfo_list");
     for (int i = 0; i < array.length(); i++) {
       VideoPlayUrl playurl = new VideoPlayUrl();
       JSONObject urlobject = array.getJSONObject(i);
       playurl.playurl = urlobject.getString("vod_url");
       playurl.sharp = SharpnessEnum.getSharp(i);
       urls.add(playurl);
     }
     return urls;
   } catch (JSONException e) {
     e.printStackTrace();
   }
   return null;
 }
示例#2
0
  public static ArrayList<VideoPlayUrl> getLXPlayUrl_1(Context context, XLLXFileInfo info) {
    ArrayList<VideoPlayUrl> urls = new ArrayList<VideoPlayUrl>();
    try {
      if (info.isDir) { // 文件夹 没有解析播放地址
        return urls;
      }
      String CookieUID =
          "userid=" + XLLXBiz.getUID(context) + "; sessionid=" + XLLXBiz.getSessionid(context);
      String list_json =
          HttpUtils.getContent(
              GET_PLAY_URL_1,
              new Header[] {new BasicHeader(XLLXBiz.COOKIE, CookieUID)},
              new NameValuePair[] {
                new BasicNameValuePair("userid", info.userid),
                new BasicNameValuePair("gcid", info.gcid),
                new BasicNameValuePair("filename", URLEncoder.encode(info.src_url))
              });
      JSONTokener jsonParser = new JSONTokener(list_json);
      JSONObject object = (JSONObject) jsonParser.nextValue();
      JSONObject full_HD_Object = object.getJSONObject("Full_HD");
      Log.d(TAG, full_HD_Object + "");
      if (full_HD_Object.has("url") && !full_HD_Object.isNull("url")) {
        VideoPlayUrl playurl = new VideoPlayUrl();
        playurl.playurl = full_HD_Object.getString("url");
        playurl.sharp = SharpnessEnum.getSharp(3);
        urls.add(playurl);
      }

      JSONObject HD_Object = object.getJSONObject("HD");
      if (HD_Object.has("url") && !HD_Object.isNull("url")) {
        VideoPlayUrl playurl = new VideoPlayUrl();
        playurl.playurl = HD_Object.getString("url");
        playurl.sharp = SharpnessEnum.getSharp(2);
        urls.add(playurl);
      }
      JSONObject SD_Object = object.getJSONObject("SD");
      if (SD_Object.has("url") && !SD_Object.isNull("url")) {
        VideoPlayUrl playurl = new VideoPlayUrl();
        playurl.playurl = SD_Object.getString("url");
        playurl.sharp = SharpnessEnum.getSharp(0);
        urls.add(playurl);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return urls;
  }
示例#3
0
  public static ArrayList<VideoPlayUrl> getLXPlayUrl_2(Context context, XLLXFileInfo info) {
    ArrayList<VideoPlayUrl> urls = new ArrayList<VideoPlayUrl>();
    try {
      // BT文件夹转码没有完成或失败
      if (info.isDir || info.file_name == null || info.src_url == null) {
        return urls;
      }
      String CookieUID =
          "userid=" + XLLXBiz.getUID(context) + "; sessionid=" + XLLXBiz.getSessionid(context);
      for (int i = 2; i > 0; i--) {
        String json =
            HttpUtils.getContent(
                GET_PLAY_URL_2,
                new Header[] {
                  new BasicHeader(XLLXBiz.COOKIE, CookieUID), new BasicHeader("Referer", REFERER)
                },
                new NameValuePair[] {
                  new BasicNameValuePair("url", URLEncoder.encode(info.src_url)),
                  new BasicNameValuePair("video_name", URLEncoder.encode(info.file_name)),
                  new BasicNameValuePair("platform", i + ""),
                  new BasicNameValuePair("userid", XLLXBiz.getUID(context)),
                  new BasicNameValuePair("vip", "1"),
                  new BasicNameValuePair("sessionid", XLLXBiz.getSessionid(context)),
                  new BasicNameValuePair("cache", System.currentTimeMillis() + ""),
                  new BasicNameValuePair("from", "vlist")
                });

        Log.d(TAG, "play url 2 : json =" + json);
        JSONTokener jsonParser = new JSONTokener(json);
        JSONObject object = (JSONObject) jsonParser.nextValue();
        JSONObject resp = object.getJSONObject("resp");
        if (resp.has("src_info")) {

          JSONArray array = resp.getJSONArray("vodinfo_list");
          Log.d("", "" + array.length());
          for (int j = 0; j < array.length(); j++) {
            VideoPlayUrl playurl = new VideoPlayUrl();
            JSONObject urlobject = array.getJSONObject(j);
            playurl.playurl = urlobject.getString("vod_url");
            playurl.sharp = SharpnessEnum.getSharp(j);
            urls.add(playurl);
          }
        }
        if (urls.size() > 0) {
          return urls;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return urls;
  }