Make sure playlists aren't accepted by PeertubeStreamLinkHandlerFactory
This commit is contained in:
parent
38ad1eaac5
commit
396aecef19
3 changed files with 15 additions and 3 deletions
|
@ -9,7 +9,8 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
|||
public class PeertubeStreamLinkHandlerFactory extends LinkHandlerFactory {
|
||||
|
||||
private static final PeertubeStreamLinkHandlerFactory instance = new PeertubeStreamLinkHandlerFactory();
|
||||
private static final String ID_PATTERN = "(/w/|(/videos/(watch/|embed/)?))([^/?&#]*)";
|
||||
private static final String ID_PATTERN = "(/w/|(/videos/(watch/|embed/)?))(?!p/)([^/?&#]*)";
|
||||
// we exclude p/ because /w/p/ is playlist, not video
|
||||
public static final String VIDEO_API_ENDPOINT = "/api/v1/videos/";
|
||||
|
||||
// From PeerTube 3.3.0, the default path is /w/.
|
||||
|
|
|
@ -45,4 +45,11 @@ public class PeertubePlaylistLinkHandlerFactoryTest {
|
|||
assertEquals("96b0ee2b-a5a7-4794-8769-58d8ccb79ab7", linkHandler.getId("https://framatube.org/videos/watch/playlist/96b0ee2b-a5a7-4794-8769-58d8ccb79ab7"));
|
||||
assertEquals("96b0ee2b-a5a7-4794-8769-58d8ccb79ab7", linkHandler.getId("https://framatube.org/w/p/96b0ee2b-a5a7-4794-8769-58d8ccb79ab7"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUrl() throws ParsingException {
|
||||
System.out.println(linkHandler.fromUrl("https://framatube.org/videos/watch/playlist/d8ca79f9-e4c7-4269-8183-d78ed269c909").getUrl());;
|
||||
System.out.println(linkHandler.fromUrl("https://framatube.org/w/p/d8ca79f9-e4c7-4269-8183-d78ed269c909").getUrl());;
|
||||
System.out.println(linkHandler.fromUrl("https://framatube.org/w/p/sLFbqXsw7sPR3AfvqQSBZB").getUrl());;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import org.schabi.newpipe.extractor.NewPipe;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStreamLinkHandlerFactory;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.PeerTube;
|
||||
|
||||
/**
|
||||
* Test for {@link PeertubeStreamLinkHandlerFactory}
|
||||
*/
|
||||
public class PeertubeStreamLinkHandlerFactoryTest {
|
||||
|
||||
private static PeertubeStreamLinkHandlerFactory linkHandler;
|
||||
|
||||
@BeforeClass
|
||||
|
@ -67,5 +67,9 @@ public class PeertubeStreamLinkHandlerFactoryTest {
|
|||
assertTrue(linkHandler.acceptUrl("https://framatube.org/videos/embed/9c9de5e8-0a1e-484a-b099-e80766180a6d"));
|
||||
assertTrue(linkHandler.acceptUrl("https://framatube.org/videos/watch/9c9de5e8-0a1e-484a-b099-e80766180a6d"));
|
||||
assertTrue(linkHandler.acceptUrl("https://framatube.org/w/9c9de5e8-0a1e-484a-b099-e80766180a6d"));
|
||||
|
||||
// make sure playlists aren't accepted
|
||||
assertFalse(linkHandler.acceptUrl("https://framatube.org/w/p/dacdc4ef-5160-4846-9b70-a655880da667"));
|
||||
assertFalse(linkHandler.acceptUrl("https://framatube.org/videos/watch/playlist/dacdc4ef-5160-4846-9b70-a655880da667"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue