Merge pull request #137 from connectety/invidious-support
Invidious support
This commit is contained in:
commit
4c633c2166
|
@ -46,7 +46,8 @@ public class YoutubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
URL urlObj = Utils.stringToURL(url);
|
URL urlObj = Utils.stringToURL(url);
|
||||||
String path = urlObj.getPath();
|
String path = urlObj.getPath();
|
||||||
|
|
||||||
if (!(YoutubeParsingHelper.isYoutubeURL(urlObj) || urlObj.getHost().equalsIgnoreCase("hooktube.com"))) {
|
if (!Utils.isHTTP(urlObj) || !(YoutubeParsingHelper.isYoutubeURL(urlObj) ||
|
||||||
|
YoutubeParsingHelper.isInvidioURL(urlObj) || YoutubeParsingHelper.isHooktubeURL(urlObj))) {
|
||||||
throw new ParsingException("the URL given is not a Youtube-URL");
|
throw new ParsingException("the URL given is not a Youtube-URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,40 +30,25 @@ public class YoutubeParsingHelper {
|
||||||
private YoutubeParsingHelper() {
|
private YoutubeParsingHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isHTTP(URL url) {
|
|
||||||
// make sure its http or https
|
|
||||||
String protocol = url.getProtocol();
|
|
||||||
if (!protocol.equals("http") && !protocol.equals("https")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean usesDefaultPort = url.getPort() == url.getDefaultPort();
|
|
||||||
boolean setsNoPort = url.getPort() == -1;
|
|
||||||
|
|
||||||
return setsNoPort || usesDefaultPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isYoutubeURL(URL url) {
|
public static boolean isYoutubeURL(URL url) {
|
||||||
// make sure its http or https
|
|
||||||
if (!isHTTP(url))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// make sure its a known youtube url
|
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
return host.equalsIgnoreCase("youtube.com") || host.equalsIgnoreCase("www.youtube.com")
|
return host.equalsIgnoreCase("youtube.com") || host.equalsIgnoreCase("www.youtube.com")
|
||||||
|| host.equalsIgnoreCase("m.youtube.com");
|
|| host.equalsIgnoreCase("m.youtube.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isYoutubeALikeURL(URL url) {
|
public static boolean isYoutubeServiceURL(URL url) {
|
||||||
// make sure its http or https
|
|
||||||
if (!isHTTP(url))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// make sure its a known youtube url
|
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
return host.equalsIgnoreCase("youtube.com") || host.equalsIgnoreCase("www.youtube.com")
|
return host.equalsIgnoreCase("www.youtube-nocookie.com") || host.equalsIgnoreCase("youtu.be");
|
||||||
|| host.equalsIgnoreCase("m.youtube.com") || host.equalsIgnoreCase("www.youtube-nocookie.com")
|
}
|
||||||
|| host.equalsIgnoreCase("youtu.be") || host.equalsIgnoreCase("hooktube.com");
|
|
||||||
|
public static boolean isHooktubeURL(URL url) {
|
||||||
|
String host = url.getHost();
|
||||||
|
return host.equalsIgnoreCase("hooktube.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isInvidioURL(URL url) {
|
||||||
|
String host = url.getHost();
|
||||||
|
return host.equalsIgnoreCase("invidio.us") || host.equalsIgnoreCase("www.invidio.us");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long parseDurationString(String input)
|
public static long parseDurationString(String input)
|
||||||
|
|
|
@ -25,10 +25,16 @@ public class YoutubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
try {
|
try {
|
||||||
URL urlObj = Utils.stringToURL(url);
|
URL urlObj = Utils.stringToURL(url);
|
||||||
|
|
||||||
if (!YoutubeParsingHelper.isYoutubeURL(urlObj)) {
|
if (!Utils.isHTTP(urlObj) || !(YoutubeParsingHelper.isYoutubeURL(urlObj)
|
||||||
|
|| YoutubeParsingHelper.isInvidioURL(urlObj))) {
|
||||||
throw new ParsingException("the url given is not a Youtube-URL");
|
throw new ParsingException("the url given is not a Youtube-URL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String path = urlObj.getPath();
|
||||||
|
if (!path.equals("/watch" ) && !path.equals("/playlist")) {
|
||||||
|
throw new ParsingException("the url given is neither a video nor a playlist URL");
|
||||||
|
}
|
||||||
|
|
||||||
String listID = Utils.getQueryValue(urlObj, "list");
|
String listID = Utils.getQueryValue(urlObj, "list");
|
||||||
|
|
||||||
if (listID == null) {
|
if (listID == null) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
URI uri = new URI(urlString);
|
URI uri = new URI(urlString);
|
||||||
String scheme = uri.getScheme();
|
String scheme = uri.getScheme();
|
||||||
|
|
||||||
if (scheme != null && scheme.equals("vnd.youtube")) {
|
if (scheme != null && (scheme.equals("vnd.youtube") || scheme.equals("vnd.youtube.launch"))) {
|
||||||
String schemeSpecificPart = uri.getSchemeSpecificPart();
|
String schemeSpecificPart = uri.getSchemeSpecificPart();
|
||||||
if (schemeSpecificPart.startsWith("//")) {
|
if (schemeSpecificPart.startsWith("//")) {
|
||||||
urlString = "https:" + schemeSpecificPart;
|
urlString = "https:" + schemeSpecificPart;
|
||||||
|
@ -85,7 +85,9 @@ public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
path = path.substring(1);
|
path = path.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!YoutubeParsingHelper.isYoutubeALikeURL(url)) {
|
if (!Utils.isHTTP(url) || !(YoutubeParsingHelper.isYoutubeURL(url) ||
|
||||||
|
YoutubeParsingHelper.isYoutubeServiceURL(url) || YoutubeParsingHelper.isHooktubeURL(url) ||
|
||||||
|
YoutubeParsingHelper.isInvidioURL(url))) {
|
||||||
if (host.equalsIgnoreCase("googleads.g.doubleclick.net")) {
|
if (host.equalsIgnoreCase("googleads.g.doubleclick.net")) {
|
||||||
throw new FoundAdException("Error found ad: " + urlString);
|
throw new FoundAdException("Error found ad: " + urlString);
|
||||||
}
|
}
|
||||||
|
@ -147,6 +149,21 @@ public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
case "HOOKTUBE.COM": {
|
case "HOOKTUBE.COM": {
|
||||||
|
if (path.startsWith("v/")) {
|
||||||
|
String id = path.substring("v/".length());
|
||||||
|
|
||||||
|
return assertIsID(id);
|
||||||
|
}
|
||||||
|
if (path.startsWith("watch/")) {
|
||||||
|
String id = path.substring("watch/".length());
|
||||||
|
|
||||||
|
return assertIsID(id);
|
||||||
|
}
|
||||||
|
// there is no break-statement here on purpose so the next code-block gets also run for hooktube
|
||||||
|
}
|
||||||
|
|
||||||
|
case "WWW.INVIDIO.US":
|
||||||
|
case "INVIDIO.US": { // code-block for hooktube.com and invidio.us
|
||||||
if (path.equals("watch")) {
|
if (path.equals("watch")) {
|
||||||
String viewQueryValue = Utils.getQueryValue(url, "v");
|
String viewQueryValue = Utils.getQueryValue(url, "v");
|
||||||
if (viewQueryValue != null) {
|
if (viewQueryValue != null) {
|
||||||
|
@ -158,20 +175,10 @@ public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
|
|
||||||
return assertIsID(id);
|
return assertIsID(id);
|
||||||
}
|
}
|
||||||
if (path.startsWith("v/")) {
|
|
||||||
String id = path.substring("v/".length());
|
|
||||||
|
|
||||||
return assertIsID(id);
|
|
||||||
}
|
|
||||||
if (path.startsWith("watch/")) {
|
|
||||||
String id = path.substring("watch/".length());
|
|
||||||
|
|
||||||
return assertIsID(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw new ParsingException("Error no suitable url: " + urlString);
|
throw new ParsingException("Error no suitable url: " + urlString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,6 @@ public class YoutubeTrendingLinkHandlerFactory extends ListLinkHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
String urlPath = urlObj.getPath();
|
String urlPath = urlObj.getPath();
|
||||||
return YoutubeParsingHelper.isYoutubeURL(urlObj) && urlPath.equals("/feed/trending");
|
return Utils.isHTTP(urlObj) && (YoutubeParsingHelper.isYoutubeURL(urlObj) || YoutubeParsingHelper.isInvidioURL(urlObj)) && urlPath.equals("/feed/trending");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,6 +121,19 @@ public class Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isHTTP(URL url) {
|
||||||
|
// make sure its http or https
|
||||||
|
String protocol = url.getProtocol();
|
||||||
|
if (!protocol.equals("http") && !protocol.equals("https")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean usesDefaultPort = url.getPort() == url.getDefaultPort();
|
||||||
|
boolean setsNoPort = url.getPort() == -1;
|
||||||
|
|
||||||
|
return setsNoPort || usesDefaultPort;
|
||||||
|
}
|
||||||
|
|
||||||
public static String removeUTF8BOM(String s) {
|
public static String removeUTF8BOM(String s) {
|
||||||
if (s.startsWith("\uFEFF")) {
|
if (s.startsWith("\uFEFF")) {
|
||||||
s = s.substring(1);
|
s = s.substring(1);
|
||||||
|
|
|
@ -37,6 +37,12 @@ public class YoutubeChannelLinkHandlerFactoryTest {
|
||||||
|
|
||||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
assertTrue(linkHandler.acceptUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||||
|
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/user/Gronkh"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/user/Netzkino/videos"));
|
||||||
|
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -53,5 +59,11 @@ public class YoutubeChannelLinkHandlerFactoryTest {
|
||||||
|
|
||||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
||||||
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://hooktube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
||||||
|
|
||||||
|
assertEquals("user/Gronkh", linkHandler.fromUrl("https://invidio.us/user/Gronkh").getId());
|
||||||
|
assertEquals("user/Netzkino", linkHandler.fromUrl("https://invidio.us/user/Netzkino/videos").getId());
|
||||||
|
|
||||||
|
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA").getId());
|
||||||
|
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.schabi.newpipe.Downloader;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
|
||||||
|
import org.schabi.newpipe.extractor.utils.Localization;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for {@link YoutubePlaylistLinkHandlerFactory}
|
||||||
|
*/
|
||||||
|
public class YoutubePlaylistLinkHandlerFactoryTest {
|
||||||
|
private static YoutubePlaylistLinkHandlerFactory linkHandler;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUp() {
|
||||||
|
linkHandler = YoutubePlaylistLinkHandlerFactory.getInstance();
|
||||||
|
NewPipe.init(Downloader.getInstance(), new Localization("GB", "en"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void getIdWithNullAsUrl() throws ParsingException {
|
||||||
|
linkHandler.fromId(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getIdfromYt() throws Exception {
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV", linkHandler.fromUrl("https://www.youtube.com/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC&t=100").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://WWW.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC&t=100").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("HTTPS://www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC&t=100").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://www.youtube.com/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("http://www.youtube.com/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://m.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV", linkHandler.fromUrl("www.youtube.com/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV").getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAcceptYtUrl() throws ParsingException {
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://WWW.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dCI"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("HTTPS://www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("http://www.youtube.com/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://m.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("www.youtube.com/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeniesInvalidYtUrl() throws ParsingException {
|
||||||
|
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/feed/subscriptions?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("ftp://www.youtube.com/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("www.youtube.com:22/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("youtube . com/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAcceptInvidioUrl() throws ParsingException {
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://www.invidio.us/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://WWW.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dCI"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("HTTPS://www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://www.invidio.us/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("http://www.invidio.us/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("www.invidio.us/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeniesInvalidInvidioUrl() throws ParsingException {
|
||||||
|
assertFalse(linkHandler.acceptUrl("https://invidio.us/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("https://invidio.us/feed/subscriptions?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("ftp:/invidio.us/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("invidio.us:22/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("invidio . us/feed/trending?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
assertFalse(linkHandler.acceptUrl("?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetInvidioIdfromUrl() throws ParsingException {
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV", linkHandler.fromUrl("https://www.invidio.us/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC&t=100").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://WWW.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC&t=100").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("HTTPS://www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC&t=100").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://www.invidio.us/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("http://www.invidio.us/watch?v=0JFM3PRZH-k&index=8&list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("https://invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC", linkHandler.fromUrl("www.invidio.us/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC").getId());
|
||||||
|
assertEquals("PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV", linkHandler.fromUrl("www.invidio.us/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV").getId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -99,12 +99,13 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
||||||
assertTrue(linkHandler.acceptUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI"));
|
assertTrue(linkHandler.acceptUrl("vnd.youtube://www.youtube.com/watch?v=jZViOEv90dI"));
|
||||||
assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
||||||
|
|
||||||
assertTrue(linkHandler.acceptUrl("vnd.youtube:jZViOEv90dI"));
|
assertTrue(linkHandler.acceptUrl("vnd.youtube.launch:jZViOEv90dI"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAcceptHookUrl() throws ParsingException {
|
public void testAcceptHookUrl() throws ParsingException {
|
||||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=TglNG-yjabU"));
|
assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=TglNG-yjabU"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("http://hooktube.com/watch?v=TglNG-yjabU"));
|
||||||
assertTrue(linkHandler.acceptUrl("hooktube.com/watch?v=3msbfr6pBNE"));
|
assertTrue(linkHandler.acceptUrl("hooktube.com/watch?v=3msbfr6pBNE"));
|
||||||
assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2"));
|
assertTrue(linkHandler.acceptUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2"));
|
||||||
assertTrue(linkHandler.acceptUrl("hooktube.com/watch/3msbfr6pBNE"));
|
assertTrue(linkHandler.acceptUrl("hooktube.com/watch/3msbfr6pBNE"));
|
||||||
|
@ -115,10 +116,31 @@ public class YoutubeStreamLinkHandlerFactoryTest {
|
||||||
@Test
|
@Test
|
||||||
public void testGetHookIdfromUrl() throws ParsingException {
|
public void testGetHookIdfromUrl() throws ParsingException {
|
||||||
assertEquals("TglNG-yjabU", linkHandler.fromUrl("https://hooktube.com/watch?v=TglNG-yjabU").getId());
|
assertEquals("TglNG-yjabU", linkHandler.fromUrl("https://hooktube.com/watch?v=TglNG-yjabU").getId());
|
||||||
|
assertEquals("TglNG-yjabU", linkHandler.fromUrl("http://hooktube.com/watch?v=TglNG-yjabU").getId());
|
||||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch?v=3msbfr6pBNE").getId());
|
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch?v=3msbfr6pBNE").getId());
|
||||||
assertEquals("ocH3oSnZG3c", linkHandler.fromUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId());
|
assertEquals("ocH3oSnZG3c", linkHandler.fromUrl("https://hooktube.com/watch?v=ocH3oSnZG3c&list=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId());
|
||||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch/3msbfr6pBNE").getId());
|
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/watch/3msbfr6pBNE").getId());
|
||||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/v/3msbfr6pBNE").getId());
|
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/v/3msbfr6pBNE").getId());
|
||||||
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/embed/3msbfr6pBNE").getId());
|
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("hooktube.com/embed/3msbfr6pBNE").getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAcceptInvidioUrl() throws ParsingException {
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/watch?v=TglNG-yjabU"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("http://www.invidio.us/watch?v=TglNG-yjabU"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("http://invidio.us/watch?v=TglNG-yjabU"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("invidio.us/watch?v=3msbfr6pBNE"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("https://invidio.us/watch?v=ocH3oSnZG3c&test=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2"));
|
||||||
|
assertTrue(linkHandler.acceptUrl("invidio.us/embed/3msbfr6pBNE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetInvidioIdfromUrl() throws ParsingException {
|
||||||
|
assertEquals("TglNG-yjabU", linkHandler.fromUrl("https://invidio.us/watch?v=TglNG-yjabU").getId());
|
||||||
|
assertEquals("TglNG-yjabU", linkHandler.fromUrl("http://www.invidio.us/watch?v=TglNG-yjabU").getId());
|
||||||
|
assertEquals("TglNG-yjabU", linkHandler.fromUrl("http://invidio.us/watch?v=TglNG-yjabU").getId());
|
||||||
|
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("invidio.us/watch?v=3msbfr6pBNE").getId());
|
||||||
|
assertEquals("ocH3oSnZG3c", linkHandler.fromUrl("https://invidio.us/watch?v=ocH3oSnZG3c&test=PLS2VU1j4vzuZwooPjV26XM9UEBY2CPNn2").getId());
|
||||||
|
assertEquals("3msbfr6pBNE", linkHandler.fromUrl("invidio.us/embed/3msbfr6pBNE").getId());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -69,6 +69,10 @@ public class YoutubeTrendingLinkHandlerFactoryTest {
|
||||||
assertTrue(LinkHandlerFactory.acceptUrl("https://youtube.com/feed/trending"));
|
assertTrue(LinkHandlerFactory.acceptUrl("https://youtube.com/feed/trending"));
|
||||||
assertTrue(LinkHandlerFactory.acceptUrl("m.youtube.com/feed/trending"));
|
assertTrue(LinkHandlerFactory.acceptUrl("m.youtube.com/feed/trending"));
|
||||||
|
|
||||||
|
assertTrue(LinkHandlerFactory.acceptUrl("https://www.invidio.us/feed/trending"));
|
||||||
|
assertTrue(LinkHandlerFactory.acceptUrl("https://invidio.us/feed/trending"));
|
||||||
|
assertTrue(LinkHandlerFactory.acceptUrl("invidio.us/feed/trending"));
|
||||||
|
|
||||||
assertFalse(LinkHandlerFactory.acceptUrl("https://youtu.be/feed/trending"));
|
assertFalse(LinkHandlerFactory.acceptUrl("https://youtu.be/feed/trending"));
|
||||||
assertFalse(LinkHandlerFactory.acceptUrl("kdskjfiiejfia"));
|
assertFalse(LinkHandlerFactory.acceptUrl("kdskjfiiejfia"));
|
||||||
assertFalse(LinkHandlerFactory.acceptUrl("https://www.youtube.com/bullshit/feed/trending"));
|
assertFalse(LinkHandlerFactory.acceptUrl("https://www.youtube.com/bullshit/feed/trending"));
|
||||||
|
|
Loading…
Reference in New Issue