Skip to content

Commit 4ff8438

Browse files
committed
Proper regex for on.soundcloud URLs
Follow-up fix to 02e14b8
1 parent 39b9482 commit 4ff8438

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/linkHandler/SoundcloudStreamLinkHandlerFactory.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ public final class SoundcloudStreamLinkHandlerFactory extends LinkHandlerFactory
1212
private static final SoundcloudStreamLinkHandlerFactory INSTANCE
1313
= new SoundcloudStreamLinkHandlerFactory();
1414

15+
private static final String ON_URL_PATTERN = "^https?://on\\.soundcloud\\.com/[0-9a-zA-Z]+$";
1516
private static final Pattern URL_PATTERN = Pattern.compile(
16-
"^https?://(?:www\\.|m\\.|on\\.)?"
17+
"^https?://(?:www\\.|m\\.)?"
1718
+ "soundcloud.com/[0-9a-z_-]+"
1819
+ "/(?!(?:tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?(?:[#?].*)?$"
20+
+ "|" + ON_URL_PATTERN
1921
);
2022

2123
private static final Pattern API_URL_PATTERN = Pattern.compile(

extractor/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamLinkHandlerFactoryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ void getIdForInvalidUrls(final String invalidUrl) {
5454
"294487684,https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9",
5555
"294487428,https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s",
5656
"294487157,https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s",
57-
"44556776,https://soundcloud.com/kechuspider-sets-1/last-days"
57+
"44556776,https://soundcloud.com/kechuspider-sets-1/last-days",
58+
"1171484959,https://on.soundcloud.com/Z8uNsRy7lABhSBiGgq"
5859
})
5960
void getId(final String expectedId, final String url) throws ParsingException {
6061
assertEquals(expectedId, linkHandler.fromUrl(url).getId());
@@ -72,7 +73,8 @@ void getId(final String expectedId, final String url) throws ParsingException {
7273
"https://soundcloud.com/liluzivert/threesome-produced-by-zaytoven#t=1:09",
7374
"https://soundcloud.com/liluzivert/blonde-brigitte-produced-manny-fresh#t=1:9",
7475
"https://soundcloud.com/liluzivert/today-produced-by-c-note#t=1m9s",
75-
"https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s"
76+
"https://soundcloud.com/liluzivert/changed-my-phone-produced-by-c-note#t=1m09s",
77+
"https://on.soundcloud.com/Z8uNsRy7lABhSBiGgq"
7678
})
7779
void testAcceptUrl(final String url) throws ParsingException {
7880
assertTrue(linkHandler.acceptUrl(url));

0 commit comments

Comments
 (0)