Skip to content

Commit 3e8e2a1

Browse files
committed
Add support for y2u.be links
1 parent b425394 commit 3e8e2a1

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ public static boolean isInvidioURL(@Nonnull final URL url) {
162162
|| host.equalsIgnoreCase("y.com.cm");
163163
}
164164

165+
public static boolean isY2ubeURL(@Nonnull final URL url) {
166+
return url.getHost().equalsIgnoreCase("y2u.be");
167+
}
168+
165169
/**
166170
* Parses the duration string of the video expecting ":" or "." as separators
167171
*

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public String getId(String urlString) throws ParsingException, IllegalArgumentEx
110110

111111
if (!Utils.isHTTP(url) || !(YoutubeParsingHelper.isYoutubeURL(url) ||
112112
YoutubeParsingHelper.isYoutubeServiceURL(url) || YoutubeParsingHelper.isHooktubeURL(url) ||
113-
YoutubeParsingHelper.isInvidioURL(url))) {
113+
YoutubeParsingHelper.isInvidioURL(url) || YoutubeParsingHelper.isY2ubeURL(url))) {
114114
if (host.equalsIgnoreCase("googleads.g.doubleclick.net")) {
115115
throw new FoundAdException("Error found ad: " + urlString);
116116
}
@@ -160,6 +160,7 @@ public String getId(String urlString) throws ParsingException, IllegalArgumentEx
160160
return assertIsId(viewQueryValue);
161161
}
162162

163+
case "Y2U.BE":
163164
case "YOUTU.BE": {
164165
String viewQueryValue = Utils.getQueryValue(url, "v");
165166
if (viewQueryValue != null) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,10 @@ public void getIdFromInvidious() throws ParsingException {
6161
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://invidio.us/VM_6n762j6M&t=20").getId());
6262
}
6363

64+
@Test
65+
public void getIdFromY2ube() throws ParsingException {
66+
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://y2u.be/VM_6n762j6M").getId());
67+
assertEquals("VM_6n762j6M", linkHandler.fromUrl("https://Y2U.Be/VM_6n762j6M").getId());
68+
}
69+
6470
}

0 commit comments

Comments
 (0)