@Override public void parse(JSONObject jsonObject) { super.parse(jsonObject); this.setKey(CTVVideo.parseKey(jsonObject)); this.frontendServerKey = jsonObject.optString("frontend_server_key", null); this.privacyDescription = jsonObject.optString("video_privacy_description", null); this.privacyKey = jsonObject.optString("video_privacy_key", null); // videoUrl will be set when running the task to get the video details that finds the correct // quality at which to stream. // this.videoUrl = "http://" + // MainActivity.frontendServerHashMap.get(this.frontendServerKey).videoHost + // "/480p/ios-original-" + jsonObject.optString("video_key", "videonotfound") + ".mp4"; this.isFeatureFilm = jsonObject.optBoolean("is_feature_film"); this.isBiography = jsonObject.optBoolean("is_biography"); this.isAdvertisement = jsonObject.optBoolean("is_advertisement"); this.isShowReel = jsonObject.optBoolean("is_show_reel"); this.isInterview = jsonObject.optBoolean("is_interview"); this.isSeries = jsonObject.optBoolean("is_series"); this.isBehindTheScenes = jsonObject.optBoolean("is_behind_the_scenes"); this.isShortFilm = jsonObject.optBoolean("is_short_film"); this.isTutorial = jsonObject.optBoolean("is_tutorial"); this.isVideoBlog = jsonObject.optBoolean("is_video_blog"); this.isNews = jsonObject.optBoolean("is_news"); this.isReview = jsonObject.optBoolean("is_review"); this.isEvent = jsonObject.optBoolean("is_event"); this.isAdultVideo = jsonObject.optBoolean("is_adult_video"); this.isShortFilm = jsonObject.optBoolean("is_short_film"); this.isPreview = jsonObject.optBoolean("is_preview"); this.isWinner = jsonObject.optBoolean("is_winner"); this.restrictAdult = jsonObject.optBoolean("video_restrict_adult"); this.restrictNation = jsonObject.optBoolean("video_restrict_nation"); this.width = jsonObject.optInt("video_width"); this.height = jsonObject.optInt("video_height"); this.videoState = jsonObject.optInt("video_state"); this.videoQuality = jsonObject.optInt("video_quality"); this.online = jsonObject.optInt("video_online"); this.deleted = jsonObject.optInt("video_deleted"); this.views = jsonObject.optInt("video_views"); this.competitionEnterOnStateChange = jsonObject.optInt("competition_enter_on_state_change"); this.updateDate = jsonObject.optLong("video_update_date"); this.uploadDate = jsonObject.optLong("video_upload_date"); this.releaseDate = jsonObject.optLong("video_release_date"); this.rating = jsonObject.optDouble("video_rating", 0.0); this.duration = jsonObject.optDouble("video_duration", 0.0); this.ratingNum = jsonObject.optDouble("video_rating_num", 0.0); JSONObject jsoUploader = jsonObject.optJSONObject("uploader"); this.uploaderKey = CTVUser.parseKey(jsoUploader); // this.uploader = new CTVUser(CTVUser.parseKey(uploader)); // this.uploader.parse(uploader); // TODO - Populate video competition JSONObject jsoVideoDescription = jsonObject.optJSONObject("video_description"); this.descriptionText = jsoVideoDescription.optString("text"); this.descriptionLanguageKey = jsoVideoDescription.optString("language"); // loadUploader(jsonObject, this); JSONObject jsoVideoTitle = jsonObject.optJSONObject("video_title"); this.titleText = jsoVideoTitle.optString("text"); this.titleLanguageKey = jsoVideoTitle.optString("language"); this.previewImage = new CTVResource(jsonObject.optJSONObject("image_preview")); this.halfImage = new CTVResource(jsonObject.optJSONObject("image_half")); this.firstImage = new CTVResource(jsonObject.optJSONObject("image_first")); JSONArray jsaCategories = jsonObject.optJSONArray("category"); parseCategories(jsaCategories); // JSONObject jsoWallReference = jsonObject.optJSONObject("wall"); // this.wallReference = new CTVWallReference(); // this.wallReference.entryCount = jsoWallReference.getInt("wall_entry_count"); // this.wallReference.key = jsoWallReference.getString("key"); if (jsonObject.has("video_source_list")) { JSONArray jsonVideoSourceList = jsonObject.optJSONArray("video_source_list"); CTVVideoSource[] videoSourceList = new CTVVideoSource[jsonVideoSourceList.length()]; for (int i = 0; i < jsonVideoSourceList.length(); ++i) { try { JSONObject rawVideoSource = jsonVideoSourceList.getJSONObject(i); CTVVideoSource videoSource = new CTVVideoSource(rawVideoSource); videoSourceList[i] = videoSource; } catch (JSONException e) { e.printStackTrace(); } } this.videoSourceList = videoSourceList; } }