Skip to content

Commit e5e8c66

Browse files
committed
Readd signature decryption in YtStreamExtractor
1 parent d9570d8 commit e5e8c66

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,10 +929,22 @@ private Map<String, ItagItem> getItags(String streamingDataKey, ItagItem.ItagTyp
929929
int itag = formatData.getInt("itag");
930930

931931
if (ItagItem.isSupported(itag)) {
932-
ItagItem itagItem = ItagItem.getItag(itag);
933-
if (itagItem.itagType == itagTypeWanted) {
934-
String streamUrl = formatData.getString("url");
935-
urlAndItags.put(streamUrl, itagItem);
932+
try {
933+
ItagItem itagItem = ItagItem.getItag(itag);
934+
if (itagItem.itagType == itagTypeWanted) {
935+
String streamUrl;
936+
if (formatData.has("url")) {
937+
streamUrl = formatData.getString("url");
938+
} else {
939+
// this url has an encrypted signature
940+
Map<String, String> cipher = Parser.compatParseMap(formatData.getString("cipher"));
941+
streamUrl = cipher.get("url") + "&" + cipher.get("sp") + "=" + decryptSignature(cipher.get("s"), decryptionCode);
942+
}
943+
944+
urlAndItags.put(streamUrl, itagItem);
945+
}
946+
} catch (UnsupportedEncodingException ignored) {
947+
936948
}
937949
}
938950
}

0 commit comments

Comments
 (0)