diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java index 48ddab82e..4f10e8c58 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java @@ -11,9 +11,10 @@ import java.util.regex.Pattern; /** *
- * YouTube's media is protected with a cipher, which modifies the "n" query parameter of it's video playback urls. - * This class handles extracting that "n" query parameter, applying the cipher on it and returning the resulting url - * which is not throttled. + * YouTube's media is protected with a cipher, + * which modifies the "n" query parameter of it's video playback urls. + * This class handles extracting that "n" query parameter, + * applying the cipher on it and returning the resulting url which is not throttled. *
* *@@ -23,6 +24,12 @@ import java.util.regex.Pattern; *
* https://r5---sn-4g5ednsz.googlevideo.com/videoplayback?n=iHywZkMipkszqA&other=other *
+ *+ * Decoding the "n" parameter is time intensive. For this reason, the results are cached. + * The cache can be cleared using {@link #clearCache()} + *
+ * */ public class YoutubeThrottlingDecrypter { @@ -102,4 +109,18 @@ public class YoutubeThrottlingDecrypter { final String newValue) { return url.replace(oldValue, newValue); } + + /** + * @return the number of the cached "n" query parameters. + */ + public static int getCacheSize() { + return nParams.size(); + } + + /** + * Clears all stored "n" query parameters. + */ + public static void clearCache() { + nParams.clear(); + } }