Skip to content

Commit a6a2119

Browse files
committed
Do a quick check if the n parameter is even present before exec regex
1 parent ef1db0d commit a6a2119

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingParameterUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ static String getDeobfuscationFunction(@Nonnull final String javaScriptPlayerCod
196196
*/
197197
@Nullable
198198
static String getThrottlingParameterFromStreamingUrl(@Nonnull final String streamingUrl) {
199+
// Do a quick check if the n parameter is even present, if not abort
200+
// This improves performance by 60-900x
201+
if (!streamingUrl.contains("&n=") || !streamingUrl.contains("?n=")) {
202+
return null;
203+
}
199204
try {
200205
return Parser.matchGroup1(THROTTLING_PARAM_PATTERN, streamingUrl);
201206
} catch (final Parser.RegexException e) {

0 commit comments

Comments
 (0)