From 7b72fd2a7d3632f3de0c57d525664c4c26c9af19 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Fri, 24 Jan 2020 01:59:39 +0100 Subject: [PATCH] [YouTube] Add new decryption function --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 98df78f74..cb2a5f53a 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -679,6 +679,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { private final static String DECRYPTION_SIGNATURE_FUNCTION_REGEX = "([\\w$]+)\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(\"\"\\)\\s*;"; + private final static String DECRYPTION_SIGNATURE_FUNCTION_REGEX_2 = + "\\b([\\w$]{2})\\s*=\\s*function\\((\\w+)\\)\\{\\s*\\2=\\s*\\2\\.split\\(\"\"\\)\\s*;"; private final static String DECRYPTION_AKAMAIZED_STRING_REGEX = "yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(:encodeURIComponent\\s*\\()([a-zA-Z0-9$]+)\\("; private final static String DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX = @@ -697,7 +699,8 @@ public class YoutubeStreamExtractor extends StreamExtractor { final String playerUrl; // Check if the video is age restricted - if (!doc.select("meta[property=\"og:restrictions:age\"]").isEmpty()) { + Elements e = doc.select("meta[property=\"og:restrictions:age\"]"); + if (!e.isEmpty()) { final EmbeddedInfo info = getEmbeddedInfo(); final String videoInfoUrl = getVideoInfoUrl(getId(), info.sts); final String infoPageResponse = downloader.get(videoInfoUrl, getExtractorLocalization()).responseBody(); @@ -869,6 +872,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { private String getDecryptionFuncName(String playerCode) throws DecryptException { String[] decryptionFuncNameRegexes = { + DECRYPTION_SIGNATURE_FUNCTION_REGEX_2, DECRYPTION_SIGNATURE_FUNCTION_REGEX, DECRYPTION_AKAMAIZED_SHORT_STRING_REGEX, DECRYPTION_AKAMAIZED_STRING_REGEX