From 133cc032d9987130927e4c00e78e9fdbca1331dd Mon Sep 17 00:00:00 2001 From: Stypox Date: Mon, 13 May 2019 21:25:35 +0200 Subject: [PATCH 1/2] Fix invalid yt url: signature tag name is not always "signature" Thanks to @omarroth for the suggestion: see TeamNewPipe/NewPipeExtractor#155 --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 2 +- 1 file changed, 1 insertion(+), 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 b5940ad11f..cbee9e062d 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,7 @@ private Map getItags(String encodedUrlMapKey, ItagItem.ItagTyp 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 + "&signature=" + decryptSignature(tags.get("s"), decryptionCode); + streamUrl = streamUrl + "&" + tags.get("sp") + "=" + decryptSignature(tags.get("s"), decryptionCode); } urlAndItags.put(streamUrl, itagItem); } From c70d28597bc2fbe368575e0b4f56925c0211aa3e Mon Sep 17 00:00:00 2001 From: Stypox Date: Tue, 14 May 2019 13:57:45 +0200 Subject: [PATCH 2/2] 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 cbee9e062d..2ad2f90494 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 @@ private Map getItags(String encodedUrlMapKey, ItagItem.ItagTyp 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); }