File tree Expand file tree Collapse file tree
extractor/src/main/java/org/schabi/newpipe/extractor
services/soundcloud/linkHandler Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .schabi .newpipe .extractor .services .soundcloud .linkHandler ;
22
3+ import java .util .regex .Pattern ;
4+
35import org .schabi .newpipe .extractor .exceptions .ParsingException ;
46import org .schabi .newpipe .extractor .linkhandler .LinkHandlerFactory ;
57import org .schabi .newpipe .extractor .services .soundcloud .SoundcloudParsingHelper ;
911public final class SoundcloudStreamLinkHandlerFactory extends LinkHandlerFactory {
1012 private static final SoundcloudStreamLinkHandlerFactory INSTANCE
1113 = new SoundcloudStreamLinkHandlerFactory ();
12- private static final String URL_PATTERN = "^https?://(www\\ .|m\\ .|on\\ .)?"
13- + "soundcloud.com/[0-9a-z_-]+"
14- + "/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$" ;
15- private static final String API_URL_PATTERN = "^https?://api-v2\\ .soundcloud.com"
16- + "/(tracks|albums|sets|reposts|followers|following)/([0-9a-z_-]+)/" ;
14+
15+ private static final Pattern URL_PATTERN = Pattern .compile (
16+ "^https?://(?:www\\ .|m\\ .|on\\ .)?"
17+ + "soundcloud.com/[0-9a-z_-]+"
18+ + "/(?!(?:tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?(?:[#?].*)?$"
19+ );
20+
21+ private static final Pattern API_URL_PATTERN = Pattern .compile (
22+ "^https?://api-v2\\ .soundcloud.com"
23+ + "/(tracks|albums|sets|reposts|followers|following)/([0-9a-z_-]+)/"
24+ );
25+
1726 private SoundcloudStreamLinkHandlerFactory () {
1827 }
1928
Original file line number Diff line number Diff line change @@ -110,12 +110,22 @@ public static long mixedNumberWordToLong(final String numberWord)
110110 * @param url the url to be tested
111111 */
112112 public static void checkUrl (final String pattern , final String url ) throws ParsingException {
113+ checkUrl (Pattern .compile (pattern ), url );
114+ }
115+
116+ /**
117+ * Check if the url matches the pattern.
118+ *
119+ * @param pattern the pattern that will be used to check the url
120+ * @param url the url to be tested
121+ */
122+ public static void checkUrl (final Pattern pattern , final String url ) throws ParsingException {
113123 if (isNullOrEmpty (url )) {
114124 throw new IllegalArgumentException ("Url can't be null or empty" );
115125 }
116126
117127 if (!Parser .isMatch (pattern , url .toLowerCase ())) {
118- throw new ParsingException ("Url don 't match the pattern" );
128+ throw new ParsingException ("Url doesn 't match the pattern" );
119129 }
120130 }
121131
You can’t perform that action at this time.
0 commit comments