Skip to content

Commit 1c954fb

Browse files
authored
Merge pull request #277 from XiangRongLin/vnd
Handle youtube stream urls in "vnd.youtube:videoId" format.
2 parents 9edd0f2 + cc8fb48 commit 1c954fb

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeCommentsLinkHandlerFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.BASE_YOUTUBE_INTENT_URL;
4+
35
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
46
import org.schabi.newpipe.extractor.exceptions.ParsingException;
7+
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
58
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
69

710
import java.util.List;
@@ -14,6 +17,15 @@ public static YoutubeCommentsLinkHandlerFactory getInstance() {
1417
return instance;
1518
}
1619

20+
@Override
21+
public ListLinkHandler fromUrl(String url) throws ParsingException {
22+
if (url.startsWith(BASE_YOUTUBE_INTENT_URL)){
23+
return super.fromUrl(url, BASE_YOUTUBE_INTENT_URL);
24+
} else {
25+
return super.fromUrl(url);
26+
}
27+
}
28+
1729
@Override
1830
public String getUrl(String id) {
1931
return "https://m.youtube.com/watch?v=" + id;

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ public class YoutubeParsingHelper {
5353
private YoutubeParsingHelper() {
5454
}
5555

56+
/**
57+
* The official youtube app supports intents in this format, where after the ':' is the videoId.
58+
* Accordingly there are other apps sharing streams in this format.
59+
*/
60+
public final static String BASE_YOUTUBE_INTENT_URL = "vnd.youtube";
61+
5662
private static final String HARDCODED_CLIENT_VERSION = "2.20200214.04.00";
5763
private static String clientVersion;
5864

59-
6065
private static final String FEED_BASE_CHANNEL_ID = "https://www.youtube.com/feeds/videos.xml?channel_id=";
6166
private static final String FEED_BASE_USER = "https://www.youtube.com/feeds/videos.xml?user=";
6267

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
22

3+
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.BASE_YOUTUBE_INTENT_URL;
4+
35
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
46
import org.schabi.newpipe.extractor.exceptions.ParsingException;
7+
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
58
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
69
import org.schabi.newpipe.extractor.utils.Utils;
710

@@ -49,6 +52,15 @@ private static String assertIsID(String id) throws ParsingException {
4952
return id;
5053
}
5154

55+
@Override
56+
public LinkHandler fromUrl(String url) throws ParsingException {
57+
if (url.startsWith(BASE_YOUTUBE_INTENT_URL)){
58+
return super.fromUrl(url, BASE_YOUTUBE_INTENT_URL);
59+
} else {
60+
return super.fromUrl(url);
61+
}
62+
}
63+
5264
@Override
5365
public String getUrl(String id) {
5466
return "https://www.youtube.com/watch?v=" + id;

0 commit comments

Comments
 (0)