@Test public void testAreHardcodedYoutubeMusicKeysValid() throws IOException, ExtractionException { assertTrue("Hardcoded YouTube Music keys are not valid anymore", YoutubeParsingHelper.areHardcodedYoutubeMusicKeysValid()); }
public static boolean areHardcodedYoutubeMusicKeysValid() throws IOException, ReCaptchaException { final String url = "https: byte[] json = JsonWriter.string() .object() .object("context") .object("client") .value("clientName", "WEB_REMIX") .value("clientVersion", HARDCODED_YOUTUBE_MUSIC_KEYS[2]) .value("hl", "en") .value("gl", "GB") .array("experimentIds").end() .value("experimentsToken", "") .value("utcOffsetMinutes", 0) .object("locationInfo").end() .object("musicAppInfo").end() .end() .object("capabilities").end() .object("request") .array("internalExperimentFlags").end() .object("sessionIndex").end() .end() .object("activePlayers").end() .object("user") .value("enableSafetyMode", false) .end() .end() .value("query", "test") .value("params", "Eg-KAQwIARAAGAAgACgAMABqChAEEAUQAxAKEAk%3D") .end().done().getBytes("UTF-8"); Map<String, List<String>> headers = new HashMap<>(); headers.put("X-YouTube-Client-Name", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[1])); headers.put("X-YouTube-Client-Version", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[2])); headers.put("Origin", Collections.singletonList("https: headers.put("Referer", Collections.singletonList("music.youtube.com")); headers.put("Content-Type", Collections.singletonList("application/json")); String response = getDownloader().post(url, headers, json).responseBody(); return response.length() > 50; }
YoutubeParsingHelper { public static boolean areHardcodedYoutubeMusicKeysValid() throws IOException, ReCaptchaException { final String url = "https: byte[] json = JsonWriter.string() .object() .object("context") .object("client") .value("clientName", "WEB_REMIX") .value("clientVersion", HARDCODED_YOUTUBE_MUSIC_KEYS[2]) .value("hl", "en") .value("gl", "GB") .array("experimentIds").end() .value("experimentsToken", "") .value("utcOffsetMinutes", 0) .object("locationInfo").end() .object("musicAppInfo").end() .end() .object("capabilities").end() .object("request") .array("internalExperimentFlags").end() .object("sessionIndex").end() .end() .object("activePlayers").end() .object("user") .value("enableSafetyMode", false) .end() .end() .value("query", "test") .value("params", "Eg-KAQwIARAAGAAgACgAMABqChAEEAUQAxAKEAk%3D") .end().done().getBytes("UTF-8"); Map<String, List<String>> headers = new HashMap<>(); headers.put("X-YouTube-Client-Name", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[1])); headers.put("X-YouTube-Client-Version", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[2])); headers.put("Origin", Collections.singletonList("https: headers.put("Referer", Collections.singletonList("music.youtube.com")); headers.put("Content-Type", Collections.singletonList("application/json")); String response = getDownloader().post(url, headers, json).responseBody(); return response.length() > 50; } }
YoutubeParsingHelper { public static boolean areHardcodedYoutubeMusicKeysValid() throws IOException, ReCaptchaException { final String url = "https: byte[] json = JsonWriter.string() .object() .object("context") .object("client") .value("clientName", "WEB_REMIX") .value("clientVersion", HARDCODED_YOUTUBE_MUSIC_KEYS[2]) .value("hl", "en") .value("gl", "GB") .array("experimentIds").end() .value("experimentsToken", "") .value("utcOffsetMinutes", 0) .object("locationInfo").end() .object("musicAppInfo").end() .end() .object("capabilities").end() .object("request") .array("internalExperimentFlags").end() .object("sessionIndex").end() .end() .object("activePlayers").end() .object("user") .value("enableSafetyMode", false) .end() .end() .value("query", "test") .value("params", "Eg-KAQwIARAAGAAgACgAMABqChAEEAUQAxAKEAk%3D") .end().done().getBytes("UTF-8"); Map<String, List<String>> headers = new HashMap<>(); headers.put("X-YouTube-Client-Name", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[1])); headers.put("X-YouTube-Client-Version", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[2])); headers.put("Origin", Collections.singletonList("https: headers.put("Referer", Collections.singletonList("music.youtube.com")); headers.put("Content-Type", Collections.singletonList("application/json")); String response = getDownloader().post(url, headers, json).responseBody(); return response.length() > 50; } private  YoutubeParsingHelper(); }
YoutubeParsingHelper { public static boolean areHardcodedYoutubeMusicKeysValid() throws IOException, ReCaptchaException { final String url = "https: byte[] json = JsonWriter.string() .object() .object("context") .object("client") .value("clientName", "WEB_REMIX") .value("clientVersion", HARDCODED_YOUTUBE_MUSIC_KEYS[2]) .value("hl", "en") .value("gl", "GB") .array("experimentIds").end() .value("experimentsToken", "") .value("utcOffsetMinutes", 0) .object("locationInfo").end() .object("musicAppInfo").end() .end() .object("capabilities").end() .object("request") .array("internalExperimentFlags").end() .object("sessionIndex").end() .end() .object("activePlayers").end() .object("user") .value("enableSafetyMode", false) .end() .end() .value("query", "test") .value("params", "Eg-KAQwIARAAGAAgACgAMABqChAEEAUQAxAKEAk%3D") .end().done().getBytes("UTF-8"); Map<String, List<String>> headers = new HashMap<>(); headers.put("X-YouTube-Client-Name", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[1])); headers.put("X-YouTube-Client-Version", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[2])); headers.put("Origin", Collections.singletonList("https: headers.put("Referer", Collections.singletonList("music.youtube.com")); headers.put("Content-Type", Collections.singletonList("application/json")); String response = getDownloader().post(url, headers, json).responseBody(); return response.length() > 50; } private  YoutubeParsingHelper(); static Document parseAndCheckPage(final String url, final Response response); static boolean isYoutubeURL(URL url); static boolean isYoutubeServiceURL(URL url); static boolean isHooktubeURL(URL url); static boolean isInvidioURL(URL url); static int parseDurationString(final String input); static String getFeedUrlFrom(final String channelIdOrUser); static Calendar parseDateFrom(String textualUploadDate); static JsonObject getInitialData(String html); static boolean isHardcodedClientVersionValid(); static String getClientVersion(); static String getKey(); static boolean areHardcodedYoutubeMusicKeysValid(); static String[] getYoutubeMusicKeys(); static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint); static String getTextFromObject(JsonObject textObject, boolean html); static String getTextFromObject(JsonObject textObject); static String fixThumbnailUrl(String thumbnailUrl); static String getValidJsonResponseBody(final Response response); static JsonArray getJsonResponse(final String url, final Localization localization); static void defaultAlertsCheck(final JsonObject initialData); }
YoutubeParsingHelper { public static boolean areHardcodedYoutubeMusicKeysValid() throws IOException, ReCaptchaException { final String url = "https: byte[] json = JsonWriter.string() .object() .object("context") .object("client") .value("clientName", "WEB_REMIX") .value("clientVersion", HARDCODED_YOUTUBE_MUSIC_KEYS[2]) .value("hl", "en") .value("gl", "GB") .array("experimentIds").end() .value("experimentsToken", "") .value("utcOffsetMinutes", 0) .object("locationInfo").end() .object("musicAppInfo").end() .end() .object("capabilities").end() .object("request") .array("internalExperimentFlags").end() .object("sessionIndex").end() .end() .object("activePlayers").end() .object("user") .value("enableSafetyMode", false) .end() .end() .value("query", "test") .value("params", "Eg-KAQwIARAAGAAgACgAMABqChAEEAUQAxAKEAk%3D") .end().done().getBytes("UTF-8"); Map<String, List<String>> headers = new HashMap<>(); headers.put("X-YouTube-Client-Name", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[1])); headers.put("X-YouTube-Client-Version", Collections.singletonList(HARDCODED_YOUTUBE_MUSIC_KEYS[2])); headers.put("Origin", Collections.singletonList("https: headers.put("Referer", Collections.singletonList("music.youtube.com")); headers.put("Content-Type", Collections.singletonList("application/json")); String response = getDownloader().post(url, headers, json).responseBody(); return response.length() > 50; } private  YoutubeParsingHelper(); static Document parseAndCheckPage(final String url, final Response response); static boolean isYoutubeURL(URL url); static boolean isYoutubeServiceURL(URL url); static boolean isHooktubeURL(URL url); static boolean isInvidioURL(URL url); static int parseDurationString(final String input); static String getFeedUrlFrom(final String channelIdOrUser); static Calendar parseDateFrom(String textualUploadDate); static JsonObject getInitialData(String html); static boolean isHardcodedClientVersionValid(); static String getClientVersion(); static String getKey(); static boolean areHardcodedYoutubeMusicKeysValid(); static String[] getYoutubeMusicKeys(); static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint); static String getTextFromObject(JsonObject textObject, boolean html); static String getTextFromObject(JsonObject textObject); static String fixThumbnailUrl(String thumbnailUrl); static String getValidJsonResponseBody(final Response response); static JsonArray getJsonResponse(final String url, final Localization localization); static void defaultAlertsCheck(final JsonObject initialData); final static String BASE_YOUTUBE_INTENT_URL; }