public class YoutubeThrottlingDecrypter extends Object
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.
https://r5---sn-4g5ednsz.googlevideo.com/videoplayback?n=VVF2xyZLVRZZxHXZ&other=otherbecomes
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 clearCache()
Constructor and Description |
---|
YoutubeThrottlingDecrypter()
Deprecated.
Use static function instead
|
YoutubeThrottlingDecrypter(String videoId)
Deprecated.
Use static function instead
|
Modifier and Type | Method and Description |
---|---|
String |
apply(String url)
Deprecated.
|
static String |
apply(String url,
String videoId)
The videoId is only used to fetch the decryption function.
|
static void |
clearCache()
Clears all stored "n" query parameters.
|
static int |
getCacheSize() |
public YoutubeThrottlingDecrypter(String videoId) throws ParsingException
Use this if you care about the off chance that YouTube tracks with which videoId the cipher is requested.
Otherwise use the no-arg constructor which uses a constant value.ParsingException
public YoutubeThrottlingDecrypter() throws ParsingException
ParsingException
public static String apply(String url, String videoId) throws ParsingException
The videoId is only used to fetch the decryption function. It can be a constant value of any existing video. A constant value is discouraged, because it could allow tracking.
ParsingException
@Deprecated public String apply(String url) throws ParsingException
ParsingException
public static int getCacheSize()
public static void clearCache()