Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
final class YoutubeThrottlingParameterUtils {

// NOTE: When changing this you should also change the quick exit/shortcut
// in getThrottlingParameterFromStreamingUrl
private static final Pattern THROTTLING_PARAM_PATTERN = Pattern.compile("[&?]n=([^&]+)");

private static final String SINGLE_CHAR_VARIABLE_REGEX = "[a-zA-Z0-9$_]";
Expand Down Expand Up @@ -196,6 +198,11 @@ static String getDeobfuscationFunction(@Nonnull final String javaScriptPlayerCod
*/
@Nullable
static String getThrottlingParameterFromStreamingUrl(@Nonnull final String streamingUrl) {
// Do a quick check if the n parameter is even present, if not abort
// This improves performance by 60-900x
if (!streamingUrl.contains("&n=") && !streamingUrl.contains("?n=")) {
return null;
}
try {
return Parser.matchGroup1(THROTTLING_PARAM_PATTERN, streamingUrl);
} catch (final Parser.RegexException e) {
Expand Down
Loading