Handle youtube stream urls in "vnd.youtube:videoId" format.
The official YouTube app accept intents in this format, which causes other developers to use it.
This commit is contained in:
parent
6446abc6d1
commit
cc8fb486ee
|
@ -1,7 +1,10 @@
|
|||
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
|
||||
|
||||
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.BASE_YOUTUBE_INTENT_URL;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -14,6 +17,15 @@ public class YoutubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
|
|||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListLinkHandler fromUrl(String url) throws ParsingException {
|
||||
if (url.startsWith(BASE_YOUTUBE_INTENT_URL)){
|
||||
return super.fromUrl(url, BASE_YOUTUBE_INTENT_URL);
|
||||
} else {
|
||||
return super.fromUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String id) {
|
||||
return "https://m.youtube.com/watch?v=" + id;
|
||||
|
|
|
@ -53,10 +53,15 @@ public class YoutubeParsingHelper {
|
|||
private YoutubeParsingHelper() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The official youtube app supports intents in this format, where after the ':' is the videoId.
|
||||
* Accordingly there are other apps sharing streams in this format.
|
||||
*/
|
||||
public final static String BASE_YOUTUBE_INTENT_URL = "vnd.youtube";
|
||||
|
||||
private static final String HARDCODED_CLIENT_VERSION = "2.20200214.04.00";
|
||||
private static String clientVersion;
|
||||
|
||||
|
||||
private static final String FEED_BASE_CHANNEL_ID = "https://www.youtube.com/feeds/videos.xml?channel_id=";
|
||||
private static final String FEED_BASE_USER = "https://www.youtube.com/feeds/videos.xml?user=";
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.schabi.newpipe.extractor.services.youtube.linkHandler;
|
||||
|
||||
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.BASE_YOUTUBE_INTENT_URL;
|
||||
|
||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
|
@ -49,6 +52,15 @@ public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory {
|
|||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkHandler fromUrl(String url) throws ParsingException {
|
||||
if (url.startsWith(BASE_YOUTUBE_INTENT_URL)){
|
||||
return super.fromUrl(url, BASE_YOUTUBE_INTENT_URL);
|
||||
} else {
|
||||
return super.fromUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String id) {
|
||||
return "https://www.youtube.com/watch?v=" + id;
|
||||
|
|
Loading…
Reference in New Issue