Skip to content

Commit 0a72252

Browse files
authored
Merge pull request #48 from RSoulwin/master
Fix: [YT] videos can not be played <NewPipeExtractor TeamNewPipe#1191>
2 parents 9f741d5 + d65ca10 commit 0a72252

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,18 @@
3737
public final class YoutubeThrottlingDecrypter {
3838

3939
private static final Pattern N_PARAM_PATTERN = Pattern.compile("[&?]n=([^&]+)");
40+
private static final String SINGLE_CHAR_VARIABLE_REGEX = "[a-zA-Z0-9$_]";
41+
42+
private static final String FUNCTION_NAME_REGEX = SINGLE_CHAR_VARIABLE_REGEX + "+";
43+
44+
private static final String ARRAY_ACCESS_REGEX = "\\[(\\d+)]";
4045
private static final Pattern DECRYPT_FUNCTION_NAME_PATTERN = Pattern.compile(
4146
// CHECKSTYLE:OFF
42-
"\\.get\\(\"n\"\\)\\)&&\\([a-zA-Z0-9$_]=([a-zA-Z0-9$_]+)(?:\\[(\\d+)])?\\([a-zA-Z0-9$_]\\)");
47+
"\\(" + SINGLE_CHAR_VARIABLE_REGEX + "=String\\.fromCharCode\\(110\\),"
48+
+ SINGLE_CHAR_VARIABLE_REGEX + "=" + SINGLE_CHAR_VARIABLE_REGEX + "\\.get\\("
49+
+ SINGLE_CHAR_VARIABLE_REGEX + "\\)\\)" + "&&\\(" + SINGLE_CHAR_VARIABLE_REGEX
50+
+ "=(" + FUNCTION_NAME_REGEX + ")" + "(?:" + ARRAY_ACCESS_REGEX + ")?\\("
51+
+ SINGLE_CHAR_VARIABLE_REGEX + "\\)");
4352
// CHECKSTYLE:ON
4453

4554
// Escape the curly end brace to allow compatibility with Android's regex engine

0 commit comments

Comments
 (0)