Skip to content

Commit 390e572

Browse files
committed
Reduce bandwidth consume by StreamExtractor
- Don't download the not needed info page - The difference is very small (~20-30 KB)
1 parent f308755 commit 390e572

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public int getAgeLimit() throws ParsingException {
175175
@Override
176176
public long getLength() throws ParsingException {
177177
try {
178-
long returnValue = playerArgs.getNumber("length_seconds", -1).longValue();
178+
long returnValue = Long.parseLong(playerArgs.get("length_seconds") + "");
179179
if (returnValue >= 0) return returnValue;
180180
} catch (Exception ignored) {
181181
// Try other method...
@@ -504,14 +504,12 @@ public void fetchPage() throws IOException, ExtractionException {
504504

505505
String pageContent = dl.download(getCleanUrl());
506506
doc = Jsoup.parse(pageContent, getCleanUrl());
507-
String infoPageResponse = dl.download(String.format(GET_VIDEO_INFO_URL, getId()));
508-
videoInfoPage = Parser.compatParseMap(infoPageResponse);
509-
510507

511508
String playerUrl;
512-
513509
// Check if the video is age restricted
514510
if (pageContent.contains("<meta property=\"og:restrictions:age")) {
511+
String infoPageResponse = dl.download(String.format(GET_VIDEO_INFO_URL, getId()));
512+
videoInfoPage = Parser.compatParseMap(infoPageResponse);
515513
playerUrl = getPlayerUrlFromRestrictedVideo();
516514
isAgeRestricted = true;
517515
} else {

0 commit comments

Comments
 (0)