@Override protected IVideoPage doTheWork(String... params) throws Exception { String id = params[0]; String uri = params[1]; String requestUri = new Config(SearchVideoDetailsActivity.this).getVchSearchUri(); String request = requestUri + "?action=parse&isVideoPage=true&id=" + id + "&uri=" + URLEncoder.encode(uri, "UTF-8"); HttpGet get = new HttpGet(request); get.addHeader("X-Requested-With", "XMLHttpRequest"); HttpClient client = new DefaultHttpClient(); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = client.execute(get, responseHandler); Log.v(BrowseActivity.TAG, "Server response: " + responseBody); IVideoPage video = new VideoPage(); JSONObject json = new JSONObject(responseBody).getJSONObject("video"); if (json.has("title")) { video.setTitle(json.getString("title")); } if (json.has("desc")) { video.setDescription(json.getString("desc")); } if (json.has("duration")) { video.setDuration(json.getLong("duration")); } if (json.has("thumb")) { video.setThumbnail(new URI(json.getString("thumb"))); } if (json.has("vchuri")) { vchuri = json.getString("vchuri"); video.setVchUri(new URI(vchuri)); } return video; }
@Override protected void finished(IVideoPage video) { updateView( video.getTitle(), video.getDescription(), video.getDuration(), video.getThumbnail()); }