public static XLLXFileInfo[] getSubFile(Context context, XLLXFileInfo btdir) { String CookieUID = XLLXBiz.getUserUID(context); if (isNumeric(CookieUID) && CookieUID != "-") { CookieUID = "userid=" + CookieUID + ";"; } else { CookieUID = "userid=" + XLLXBiz.getUID(context) + "; sessionid=" + XLLXBiz.getSessionid(context); } Log.d(TAG, "CookieUID= " + CookieUID); Header cookie = new BasicHeader(XLLXBiz.COOKIE, CookieUID); try { String suburl = "http://i.vod.xunlei.com/req_subBT/info_hash/" + btdir.src_url.substring(5) + "/req_num/30/req_offset/0"; String btjson = HttpUtils.getContent(suburl, new Header[] {cookie}, null); btjson = URLDecoder.decode(btjson); JSONTokener btjsonParser = new JSONTokener(btjson); JSONObject btobject = (JSONObject) btjsonParser.nextValue(); JSONObject btresp = btobject.getJSONObject("resp"); JSONArray btsubfile_list = btresp.getJSONArray("subfile_list"); XLLXFileInfo[] btFiles = new XLLXFileInfo[btsubfile_list.length()]; for (int j = 0; j < btsubfile_list.length(); j++) { JSONObject btsubfile = btsubfile_list.getJSONObject(j); Log.d(TAG, "btsubfile = " + btsubfile); btFiles[j] = new XLLXFileInfo(); btFiles[j].file_name = btsubfile.getString("name"); btFiles[j].src_url = btdir.src_url + "/" + btsubfile.getString("index"); btFiles[j].createTime = btdir.createTime; btFiles[j].duration = btsubfile.getString("duration"); btFiles[j].filesize = btsubfile.getString("file_size"); btFiles[j].gcid = btsubfile.getString("gcid"); btFiles[j].userid = btdir.userid; } btdir.btFiles = btFiles; return btFiles; } catch (Exception e) { e.printStackTrace(); } return null; }
/** * 获取 XL 云播的 视频列表 * * @param context * @param per 一页的个数 >=1 * @param page 页码 从第一页开始 * @return */ public static ArrayList<XLLXFileInfo> getVideoList(Context context, int per, int page) { try { String CookieUID = XLLXBiz.getUserUID(context); if (isNumeric(CookieUID) && CookieUID != "-") { CookieUID = "userid=" + CookieUID + ";"; } else { CookieUID = "userid=" + XLLXBiz.getUID(context) + "; sessionid=" + XLLXBiz.getSessionid(context); } Log.d(TAG, "CookieUID= " + CookieUID); Header cookie = new BasicHeader(XLLXBiz.COOKIE, CookieUID); String url = "http://i.vod.xunlei.com/req_history_play_list/req_num/" + per + "/req_offset/" + per * (page - 1); String json = HttpUtils.getContent( url, new Header[] {cookie}, new NameValuePair[] { new BasicNameValuePair("type", "all"), new BasicNameValuePair("order", "create"), new BasicNameValuePair("t", String.valueOf(System.currentTimeMillis())) }); if (json == null) { return null; } json = URLDecoder.decode(json); Log.d(TAG, "getVideoList json= " + json); JSONTokener jsonParser = new JSONTokener(json); JSONObject object = (JSONObject) jsonParser.nextValue(); JSONObject resp = object.getJSONObject("resp"); int recodenum = resp.getInt("record_num"); Log.d(TAG, "getVideoList record_num= " + recodenum); JSONArray history_play_list = resp.getJSONArray("history_play_list"); ArrayList<XLLXFileInfo> list = new ArrayList<XLLXFileInfo>(); for (int i = 0; i < history_play_list.length(); i++) { XLLXFileInfo info = new XLLXFileInfo(); JSONObject historyPlay = history_play_list.getJSONObject(i); info.file_name = (historyPlay.getString("file_name")); info.src_url = (historyPlay.getString("src_url")); info.createTime = historyPlay.getString("createtime"); info.duration = historyPlay.getString("duration"); info.filesize = historyPlay.getString("file_size"); info.userid = historyPlay.getString("userid"); info.urlhash = historyPlay.getString("url_hash"); info.gcid = historyPlay.getString("gcid"); info.cid = historyPlay.getString("cid"); info.recodenum = recodenum; if (info.src_url.contains("bt://")) { info.isDir = true; } list.add(info); } return list; } catch (Exception e) { e.printStackTrace(); } return null; }