Skip to content

Commit 5a259fc

Browse files
authored
Merge pull request #238 from B0pol/c_links_support
add support to /c/shortened_url channel links
2 parents 57cf47b + 5e81ed1 commit 5a259fc

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public String getId(String url) throws ParsingException {
5151
throw new ParsingException("the URL given is not a Youtube-URL");
5252
}
5353

54-
if (!path.startsWith("/user/") && !path.startsWith("/channel/")) {
54+
if (!path.startsWith("/user/") && !path.startsWith("/channel/") && !path.startsWith("/c/")) {
5555
throw new ParsingException("the URL given is neither a channel nor an user");
5656
}
5757

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelLinkHandlerFactoryTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public void acceptUrlTest() throws ParsingException {
2828
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Gronkh"));
2929
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/user/Netzkino/videos"));
3030

31+
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/c/creatoracademy"));
32+
3133
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA"));
3234
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
3335

@@ -64,5 +66,8 @@ public void getIdFromUrl() throws ParsingException {
6466

6567
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA").getId());
6668
assertEquals("channel/UClq42foiSgl7sSpLupnugGA", linkHandler.fromUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1").getId());
69+
70+
assertEquals("c/creatoracademy", linkHandler.fromUrl("https://www.youtube.com/c/creatoracademy").getId());
71+
assertEquals("c/YouTubeCreators", linkHandler.fromUrl("https://www.youtube.com/c/YouTubeCreators").getId());
6772
}
6873
}

0 commit comments

Comments
 (0)