From 44c54d403a6ff38d7ac86f647a34ba64ca4a8765 Mon Sep 17 00:00:00 2001 From: bopol Date: Fri, 5 Feb 2021 18:57:58 +0100 Subject: [PATCH] fix Invidious channels being accepted by YoutubeStreamLinkHandlerFactory (#527) fixes https://github.com/TeamNewPipe/NewPipeExtractor/issues/524, see it for more details --- .../youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java | 2 +- .../services/youtube/YoutubeStreamLinkHandlerFactoryTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java index dd2d44831..6ff6175bd 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeStreamLinkHandlerFactory.java @@ -36,7 +36,7 @@ import java.util.regex.Pattern; public class YoutubeStreamLinkHandlerFactory extends LinkHandlerFactory { - private static final Pattern YOUTUBE_VIDEO_ID_REGEX_PATTERN = Pattern.compile("([a-zA-Z0-9_-]{11})"); + private static final Pattern YOUTUBE_VIDEO_ID_REGEX_PATTERN = Pattern.compile("^([a-zA-Z0-9_-]{11})"); private static final YoutubeStreamLinkHandlerFactory instance = new YoutubeStreamLinkHandlerFactory(); private YoutubeStreamLinkHandlerFactory() { diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java index ab61f5d34..b156e70ce 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamLinkHandlerFactoryTest.java @@ -42,6 +42,8 @@ public class YoutubeStreamLinkHandlerFactoryTest { invalidUrls.add("https://www.youtube.com/watch?v=jZViOEv90d"); invalidUrls.add("https://www.youtube.com/watchjZViOEv90d"); invalidUrls.add("https://www.youtube.com/"); + invalidUrls.add("https://www.youtube.com/channel/UCBR8-60-B28hp2BmDPdntcQ"); + invalidUrls.add("https://invidio.us/channel/UCBR8-60-B28hp2BmDPdntcQ"); for (String invalidUrl : invalidUrls) { Throwable exception = null; try {