Skip to content

Commit 7b72fd2

Browse files
committed
[YouTube] Add new decryption function
1 parent bce87f3 commit 7b72fd2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ public String getErrorMessage() {
679679

680680
private final static String DECRYPTION_SIGNATURE_FUNCTION_REGEX =
681681
"([\\w$]+)\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(\"\"\\)\\s*;";
682+
private final static String DECRYPTION_SIGNATURE_FUNCTION_REGEX_2 =
683+
"\\b([\\w$]{2})\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(\"\"\\)\\s*;";
682684
private final static String DECRYPTION_AKAMAIZED_STRING_REGEX =
683685
"yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\(";
684686
private final static String DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX =
@@ -697,7 +699,8 @@ public void onFetchPage(@Nonnull Downloader downloader) throws IOException, Extr
697699

698700
final String playerUrl;
699701
// Check if the video is age restricted
700-
if (!doc.select("meta[property=\"og:restrictions:age\"]").isEmpty()) {
702+
Elements e = doc.select("meta[property=\"og:restrictions:age\"]");
703+
if (!e.isEmpty()) {
701704
final EmbeddedInfo info = getEmbeddedInfo();
702705
final String videoInfoUrl = getVideoInfoUrl(getId(), info.sts);
703706
final String infoPageResponse = downloader.get(videoInfoUrl, getExtractorLocalization()).responseBody();
@@ -869,6 +872,7 @@ private String decryptSignature(String encryptedSig, String decryptionCode) thro
869872

870873
private String getDecryptionFuncName(String playerCode) throws DecryptException {
871874
String[] decryptionFuncNameRegexes = {
875+
DECRYPTION_SIGNATURE_FUNCTION_REGEX_2,
872876
DECRYPTION_SIGNATURE_FUNCTION_REGEX,
873877
DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX,
874878
DECRYPTION_AKAMAIZED_STRING_REGEX

0 commit comments

Comments
 (0)