private JsonObject getPlayerArgs(JsonObject playerConfig) throws ParsingException { JsonObject playerArgs; //attempt to load the youtube js player JSON arguments try { playerArgs = playerConfig.getObject("args"); } catch (Exception e) { throw new ParsingException("Could not parse yt player config", e); } return playerArgs; }
@Override public String getUploaderName() { return itemObject.getObject("user").getString("username"); }
public static String getUploaderName(JsonObject object) { return object.getObject("user").getString("username", ""); } }
@Nonnull static String getUploaderUrl(JsonObject object) { String url = object.getObject("user").getString("permalink_url", ""); return replaceHttpWithHttps(url); }
@Override public String getUploaderName() throws ParsingException { try { return itemObject.getObject(USER_KEY).getString("username"); } catch (Exception e) { throw new ParsingException("Failed to extract playlist uploader", e); } }
private String getPlayerUrl(JsonObject playerConfig) throws ParsingException { try { // The Youtube service needs to be initialized by downloading the // js-Youtube-player. This is done in order to get the algorithm // for decrypting cryptic signatures inside certain stream urls. String playerUrl; JsonObject ytAssets = playerConfig.getObject("assets"); playerUrl = ytAssets.getString("js"); if (playerUrl.startsWith("//")) { playerUrl = HTTPS + playerUrl; } return playerUrl; } catch (Exception e) { throw new ParsingException("Could not load decryption code for the Youtube service.", e); } }
@Override public String getUploaderUrl() { return replaceHttpWithHttps(itemObject.getObject("user").getString("permalink_url")); }
@Nonnull static String getAvatarUrl(JsonObject object) { String url = object.getObject("user", new JsonObject()).getString("avatar_url", ""); return replaceHttpWithHttps(url); }
final JsonObject creator = trackObject.getObject(USER_KEY, new JsonObject()); final String creatorAvatar = creator.getString(AVATAR_URL_KEY, ""); if (!creatorAvatar.isEmpty()) return creatorAvatar; return itemObject.getObject(USER_KEY).getString(AVATAR_URL_KEY, ""); } catch (Exception e) { throw new ParsingException("Failed to extract playlist thumbnail url", e);
@Override public String getBannerUrl() { return user.getObject("visuals", new JsonObject()) .getArray("visuals", new JsonArray()) .getObject(0, new JsonObject()) .getString("visual_url"); }
throw new SubtitlesException("Unable to download player configs", e); final String playerResponse = playerConfig.getObject("args", new JsonObject()) .getString("player_response"); captions = JsonParser.object().from(playerResponse).getObject("captions"); } catch (JsonParserException e) { throw new SubtitlesException("Unable to parse subtitles listing", e); final JsonObject renderer = captions.getObject("playerCaptionsTracklistRenderer", new JsonObject()); final JsonArray captionsArray = renderer.getArray("captionTracks", new JsonArray());
@Nonnull @Override public String getHlsUrl() throws ParsingException { assertPageFetched(); try { String hlsvp = ""; if (playerArgs != null) { if( playerArgs.isString("hlsvp") ) { hlsvp = playerArgs.getString("hlsvp", ""); }else { hlsvp = JsonParser.object() .from(playerArgs.getString("player_response", "{}")) .getObject("streamingData", new JsonObject()) .getString("hlsManifestUrl", ""); } } return hlsvp; } catch (Exception e) { throw new ParsingException("Could not get hls manifest url", e); } }
/** * Fetch the streams from the given api and commit each of them to the collector. * * @return the next streams url, empty if don't have */ public static String getStreamsFromApi(StreamInfoItemsCollector collector, String apiUrl, boolean charts) throws IOException, ReCaptchaException, ParsingException { String response = NewPipe.getDownloader().download(apiUrl); JsonObject responseObject; try { responseObject = JsonParser.object().from(response); } catch (JsonParserException e) { throw new ParsingException("Could not parse json response", e); } JsonArray responseCollection = responseObject.getArray("collection"); for (Object o : responseCollection) { if (o instanceof JsonObject) { JsonObject object = (JsonObject) o; collector.commit(new SoundcloudStreamInfoItemExtractor(charts ? object.getObject("track") : object)); } } String nextPageUrl; try { nextPageUrl = responseObject.getString("next_href"); if (!nextPageUrl.contains("client_id=")) nextPageUrl += "&client_id=" + SoundcloudParsingHelper.clientId(); } catch (Exception ignored) { nextPageUrl = ""; } return nextPageUrl; }