From e5e8c66686589de0c452fa75c68143152a3e1c4f Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 11 Sep 2019 19:56:16 +0200 Subject: [PATCH] Readd signature decryption in YtStreamExtractor --- .../extractors/YoutubeStreamExtractor.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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 b4c8058e..82836ce8 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 @@ -929,10 +929,22 @@ public class YoutubeStreamExtractor extends StreamExtractor { int itag = formatData.getInt("itag"); if (ItagItem.isSupported(itag)) { - ItagItem itagItem = ItagItem.getItag(itag); - if (itagItem.itagType == itagTypeWanted) { - String streamUrl = formatData.getString("url"); - urlAndItags.put(streamUrl, itagItem); + try { + ItagItem itagItem = ItagItem.getItag(itag); + if (itagItem.itagType == itagTypeWanted) { + String streamUrl; + if (formatData.has("url")) { + streamUrl = formatData.getString("url"); + } else { + // this url has an encrypted signature + Map cipher = Parser.compatParseMap(formatData.getString("cipher")); + streamUrl = cipher.get("url") + "&" + cipher.get("sp") + "=" + decryptSignature(cipher.get("s"), decryptionCode); + } + + urlAndItags.put(streamUrl, itagItem); + } + } catch (UnsupportedEncodingException ignored) { + } } }