Skip to content

Commit 5a88263

Browse files
authored
Merge pull request #604 from TiA4f8R/youtubei-api
[YouTube] Use the new internal API in NewPipe Extractor
2 parents c97a19d + 79cc5c8 commit 5a88263

254 files changed

Lines changed: 48432 additions & 15818 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.schabi.newpipe.extractor.ListExtractor;
44
import org.schabi.newpipe.extractor.StreamingService;
5+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
56
import org.schabi.newpipe.extractor.exceptions.ParsingException;
67
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
78

@@ -17,7 +18,7 @@ public CommentsExtractor(final StreamingService service, final ListLinkHandler u
1718
* @apiNote Warning: This method is experimental and may get removed in a future release.
1819
* @return <code>true</code> if the comments are disabled otherwise <code>false</code> (default)
1920
*/
20-
public boolean isCommentsDisabled() {
21+
public boolean isCommentsDisabled() throws ExtractionException {
2122
return false;
2223
}
2324

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ public class ItagItem {
4646
/// VIDEO ONLY ////////////////////////////////////////////
4747
// ID Type Format Resolution FPS ///
4848
/////////////////////////////////////////////////////////
49-
// Don't add VideoOnly streams that have normal variants
5049
new ItagItem(160, VIDEO_ONLY, MPEG_4, "144p"),
5150
new ItagItem(133, VIDEO_ONLY, MPEG_4, "240p"),
52-
// new ItagItem(134, VIDEO_ONLY, MPEG_4, "360p"),
51+
new ItagItem(134, VIDEO_ONLY, MPEG_4, "360p"),
5352
new ItagItem(135, VIDEO_ONLY, MPEG_4, "480p"),
5453
new ItagItem(212, VIDEO_ONLY, MPEG_4, "480p"),
55-
// new ItagItem(136, VIDEO_ONLY, MPEG_4, "720p"),
54+
new ItagItem(136, VIDEO_ONLY, MPEG_4, "720p"),
5655
new ItagItem(298, VIDEO_ONLY, MPEG_4, "720p60", 60),
5756
new ItagItem(137, VIDEO_ONLY, MPEG_4, "1080p"),
5857
new ItagItem(299, VIDEO_ONLY, MPEG_4, "1080p60", 60),
@@ -75,6 +74,7 @@ public class ItagItem {
7574
new ItagItem(313, VIDEO_ONLY, WEBM, "2160p"),
7675
new ItagItem(315, VIDEO_ONLY, WEBM, "2160p60", 60)
7776
};
77+
7878
/*//////////////////////////////////////////////////////////////////////////
7979
// Utils
8080
//////////////////////////////////////////////////////////////////////////*/

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public static String extractJavaScriptCode() throws ParsingException {
6060
return extractJavaScriptCode("d4IGg5dqeO8");
6161
}
6262

63+
/**
64+
* Reset the JavaScript code. It will be fetched again the next time
65+
* {@link #extractJavaScriptCode()} or {@link #extractJavaScriptCode(String)} is called.
66+
*/
67+
public static void resetJavaScriptCode() {
68+
cachedJavaScriptCode = null;
69+
}
70+
6371
private static String extractJavaScriptUrl(final String videoId) throws ParsingException {
6472
try {
6573
final String embedUrl = "https://www.youtube.com/embed/" + videoId;

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

Lines changed: 373 additions & 119 deletions
Large diffs are not rendered by default.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ private String parseDecodeFunction(final String playerJsCode, final String funct
7979
}
8080
}
8181

82+
@Nonnull
8283
private String parseWithParenthesisMatching(final String playerJsCode, final String functionName) {
8384
final String functionBase = functionName + "=function";
8485
return functionBase + StringUtils.matchToClosingParenthesis(playerJsCode, functionBase) + ";";
8586
}
8687

88+
@Nonnull
8789
private String parseWithRegex(final String playerJsCode, final String functionName) throws Parser.RegexException {
8890
Pattern functionPattern = Pattern.compile(functionName + "=function(.*?}};)\n",
8991
Pattern.DOTALL);

0 commit comments

Comments
 (0)