|
4 | 4 | import com.grack.nanojson.JsonObject; |
5 | 5 | import com.grack.nanojson.JsonParser; |
6 | 6 | import com.grack.nanojson.JsonParserException; |
7 | | - |
8 | 7 | import org.jsoup.Jsoup; |
9 | 8 | import org.jsoup.nodes.Document; |
10 | 9 | import org.jsoup.nodes.Element; |
|
18 | 17 | import org.schabi.newpipe.extractor.StreamingService; |
19 | 18 | import org.schabi.newpipe.extractor.downloader.Downloader; |
20 | 19 | import org.schabi.newpipe.extractor.downloader.Response; |
21 | | -import org.schabi.newpipe.extractor.exceptions.AgeRestrictedContentException; |
22 | | -import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; |
23 | | -import org.schabi.newpipe.extractor.exceptions.ExtractionException; |
24 | | -import org.schabi.newpipe.extractor.exceptions.GeographicRestrictionException; |
25 | | -import org.schabi.newpipe.extractor.exceptions.PaidContentException; |
26 | | -import org.schabi.newpipe.extractor.exceptions.ParsingException; |
27 | | -import org.schabi.newpipe.extractor.exceptions.PrivateContentException; |
28 | | -import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; |
29 | | -import org.schabi.newpipe.extractor.exceptions.YoutubeMusicPremiumContentException; |
| 20 | +import org.schabi.newpipe.extractor.exceptions.*; |
30 | 21 | import org.schabi.newpipe.extractor.linkhandler.LinkHandler; |
31 | 22 | import org.schabi.newpipe.extractor.localization.DateWrapper; |
32 | 23 | import org.schabi.newpipe.extractor.localization.Localization; |
33 | 24 | import org.schabi.newpipe.extractor.localization.TimeAgoParser; |
34 | 25 | import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager; |
35 | 26 | import org.schabi.newpipe.extractor.services.youtube.ItagItem; |
36 | 27 | import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper; |
37 | | -import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecoder; |
| 28 | +import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecrypter; |
38 | 29 | import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory; |
39 | | -import org.schabi.newpipe.extractor.stream.AudioStream; |
40 | | -import org.schabi.newpipe.extractor.stream.Description; |
41 | | -import org.schabi.newpipe.extractor.stream.Frameset; |
42 | | -import org.schabi.newpipe.extractor.stream.Stream; |
43 | | -import org.schabi.newpipe.extractor.stream.StreamExtractor; |
44 | | -import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor; |
45 | | -import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector; |
46 | | -import org.schabi.newpipe.extractor.stream.StreamSegment; |
47 | | -import org.schabi.newpipe.extractor.stream.StreamType; |
48 | | -import org.schabi.newpipe.extractor.stream.SubtitlesStream; |
49 | | -import org.schabi.newpipe.extractor.stream.VideoStream; |
| 30 | +import org.schabi.newpipe.extractor.stream.*; |
50 | 31 | import org.schabi.newpipe.extractor.utils.JsonUtils; |
51 | 32 | import org.schabi.newpipe.extractor.utils.Parser; |
52 | 33 | import org.schabi.newpipe.extractor.utils.Utils; |
53 | 34 |
|
| 35 | +import javax.annotation.Nonnull; |
| 36 | +import javax.annotation.Nullable; |
54 | 37 | import java.io.IOException; |
55 | 38 | import java.io.UnsupportedEncodingException; |
56 | 39 | import java.time.LocalDate; |
57 | 40 | import java.time.OffsetDateTime; |
58 | 41 | import java.time.format.DateTimeFormatter; |
59 | | -import java.util.ArrayList; |
60 | | -import java.util.Collections; |
61 | | -import java.util.HashMap; |
62 | | -import java.util.LinkedHashMap; |
63 | | -import java.util.List; |
64 | | -import java.util.Locale; |
65 | | -import java.util.Map; |
66 | | -import java.util.Objects; |
| 42 | +import java.util.*; |
67 | 43 |
|
68 | | -import javax.annotation.Nonnull; |
69 | | -import javax.annotation.Nullable; |
70 | | - |
71 | | -import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl; |
72 | | -import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse; |
73 | | -import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; |
74 | | -import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint; |
| 44 | +import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.*; |
75 | 45 | import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING; |
76 | 46 | import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; |
77 | 47 |
|
@@ -553,18 +523,15 @@ public List<AudioStream> getAudioStreams() throws ExtractionException { |
553 | 523 | public List<VideoStream> getVideoStreams() throws ExtractionException { |
554 | 524 | assertPageFetched(); |
555 | 525 | final List<VideoStream> videoStreams = new ArrayList<>(); |
556 | | - YoutubeThrottlingDecoder throttlingDecoder = new YoutubeThrottlingDecoder(getId(), getExtractorLocalization()); |
| 526 | + YoutubeThrottlingDecrypter throttlingDecrypter = new YoutubeThrottlingDecrypter(getId()); |
557 | 527 |
|
558 | 528 | try { |
559 | 529 | for (final Map.Entry<String, ItagItem> entry : getItags(FORMATS, ItagItem.ItagType.VIDEO).entrySet()) { |
560 | 530 | final ItagItem itag = entry.getValue(); |
561 | | - final String url = entry.getKey(); |
562 | | - |
563 | | - String oldNParam = throttlingDecoder.parseNParam(url); |
564 | | - String newNParam = throttlingDecoder.decodeNParam(oldNParam); |
565 | | - String newUrl = throttlingDecoder.replaceNParam(url, oldNParam, newNParam); |
| 531 | + String url = entry.getKey(); |
| 532 | + url = throttlingDecrypter.apply(url); |
566 | 533 |
|
567 | | - final VideoStream videoStream = new VideoStream(newUrl, false, itag); |
| 534 | + final VideoStream videoStream = new VideoStream(url, false, itag); |
568 | 535 | if (!Stream.containSimilarStream(videoStream, videoStreams)) { |
569 | 536 | videoStreams.add(videoStream); |
570 | 537 | } |
|
0 commit comments