From c70d28597bc2fbe368575e0b4f56925c0211aa3e Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 14 May 2019 13:57:45 +0200 Subject: [PATCH] Add fallback for urls not conaining the "sp" tag If ever YouTube changes thing again (or uses old urls for some unknown reason), this prevents the extractor from crashing. As suggested here: https://github.com/TeamNewPipe/NewPipeExtractor/pull/163/files/133cc032d9987130927e4c00e78e9fdbca1331dd#r283529811 --- .../youtube/extractors/YoutubeStreamExtractor.java | 8 +++++++- 1 file changed, 7 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 cbee9e062..2ad2f9049 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 @@ -888,7 +888,13 @@ public class YoutubeStreamExtractor extends StreamExtractor { String streamUrl = tags.get("url"); // if video has a signature: decrypt it and add it to the url if (tags.get("s") != null) { - streamUrl = streamUrl + "&" + tags.get("sp") + "=" + decryptSignature(tags.get("s"), decryptionCode); + if (tags.get("sp") == null) { + // fallback for urls not conaining the "sp" tag + streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode); + } + else { + streamUrl = streamUrl + "&" + tags.get("sp") + "=" + decryptSignature(tags.get("s"), decryptionCode); + } } urlAndItags.put(streamUrl, itagItem); }