File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .schabi .newpipe .extractor ;
2+
3+ import org .schabi .newpipe .extractor .exceptions .ParsingException ;
4+
5+ public abstract class ListUrlIdHandler extends UrlIdHandler {
6+
7+ public abstract String getUrl (String id , String [] contentFilter , String sortFilter ) throws ParsingException ;
8+
9+ @ Override
10+ public String getUrl (String id ) throws ParsingException {
11+ return getUrl (id , new String [0 ], null );
12+ }
13+
14+ /**
15+ * Will returns content filter the corresponding extractor can handle like "channels", "videos", "music", etc.
16+ *
17+ * @return filter that can be applied when building a query for getting a list
18+ */
19+ public String [] getAvailableContentFilter () {
20+ return new String [0 ];
21+ }
22+
23+ /**
24+ * Will returns sort filter the corresponding extractor can handle like "A-Z", "oldest first", "size", etc.
25+ *
26+ * @return filter that can be applied when building a query for getting a list
27+ */
28+ public String [] getAvailableSortFilter () {
29+ return new String [0 ];
30+ }
31+ }
Original file line number Diff line number Diff line change 2222 * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2323 */
2424
25- public interface UrlIdHandler {
25+ public abstract class UrlIdHandler {
2626
27- String getUrl (String id ) throws ParsingException ;
28- String getId (String url ) throws ParsingException ;
29- String cleanUrl (String complexUrl ) throws ParsingException ;
27+ public abstract String getUrl (String id ) throws ParsingException ;
28+ public abstract String getId (String url ) throws ParsingException ;
29+ public abstract String cleanUrl (String complexUrl ) throws ParsingException ;
3030
3131 /**
3232 * When a VIEW_ACTION is caught this function will test if the url delivered within the calling
3333 * Intent was meant to be watched with this Service.
3434 * Return false if this service shall not allow to be called through ACTIONs.
3535 */
36- boolean acceptUrl (String url );
36+ public abstract boolean acceptUrl (String url );
3737}
Original file line number Diff line number Diff line change 22
33import org .jsoup .Jsoup ;
44import org .jsoup .nodes .Element ;
5+ import org .schabi .newpipe .extractor .ListUrlIdHandler ;
56import org .schabi .newpipe .extractor .NewPipe ;
67import org .schabi .newpipe .extractor .UrlIdHandler ;
78import org .schabi .newpipe .extractor .exceptions .ParsingException ;
1011
1112import static org .schabi .newpipe .extractor .utils .Utils .replaceHttpWithHttps ;
1213
13- public class SoundcloudChannelUrlIdHandler implements UrlIdHandler {
14+ public class SoundcloudChannelUrlIdHandler extends ListUrlIdHandler {
1415 private static final SoundcloudChannelUrlIdHandler instance = new SoundcloudChannelUrlIdHandler ();
1516 private final String URL_PATTERN = "^https?://(www\\ .|m\\ .)?soundcloud.com/[0-9a-z_-]+" +
1617 "(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$" ;
@@ -20,7 +21,7 @@ public static SoundcloudChannelUrlIdHandler getInstance() {
2021 }
2122
2223 @ Override
23- public String getUrl (String id ) throws ParsingException {
24+ public String getUrl (String id , String [] contentFilter , String sortFilter ) throws ParsingException {
2425 try {
2526 return SoundcloudParsingHelper .resolveUrlWithEmbedPlayer ("https://api.soundcloud.com/users/" + id );
2627 } catch (Exception e ) {
Original file line number Diff line number Diff line change 11package org .schabi .newpipe .extractor .services .soundcloud ;
22
3+ import org .schabi .newpipe .extractor .ListUrlIdHandler ;
34import org .schabi .newpipe .extractor .UrlIdHandler ;
45import org .schabi .newpipe .extractor .utils .Parser ;
56
6- public class SoundcloudChartsUrlIdHandler implements UrlIdHandler {
7+ public class SoundcloudChartsUrlIdHandler extends ListUrlIdHandler {
78 private final String TOP_URL_PATTERN = "^https?://(www\\ .|m\\ .)?soundcloud.com/charts(/top)?/?([#?].*)?$" ;
89 private final String URL_PATTERN = "^https?://(www\\ .|m\\ .)?soundcloud.com/charts(/top|/new)?/?([#?].*)?$" ;
910
10- public String getUrl (String id ) {
11+ public String getUrl (String id , String [] contentFilter , String sortFilter ) {
1112 if (id .equals ("Top 50" )) {
1213 return "https://soundcloud.com/charts/top" ;
1314 } else {
Original file line number Diff line number Diff line change 22
33import org .jsoup .Jsoup ;
44import org .jsoup .nodes .Element ;
5+ import org .schabi .newpipe .extractor .ListUrlIdHandler ;
56import org .schabi .newpipe .extractor .NewPipe ;
67import org .schabi .newpipe .extractor .UrlIdHandler ;
78import org .schabi .newpipe .extractor .exceptions .ParsingException ;
1011
1112import static org .schabi .newpipe .extractor .utils .Utils .replaceHttpWithHttps ;
1213
13- public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
14+ public class SoundcloudPlaylistUrlIdHandler extends ListUrlIdHandler {
1415 private static final SoundcloudPlaylistUrlIdHandler instance = new SoundcloudPlaylistUrlIdHandler ();
1516 private final String URL_PATTERN = "^https?://(www\\ .|m\\ .)?soundcloud.com/[0-9a-z_-]+" +
1617 "/sets/[0-9a-z_-]+/?([#?].*)?$" ;
@@ -20,7 +21,7 @@ public static SoundcloudPlaylistUrlIdHandler getInstance() {
2021 }
2122
2223 @ Override
23- public String getUrl (String id ) throws ParsingException {
24+ public String getUrl (String id , String [] contentFilter , String sortFilter ) throws ParsingException {
2425 try {
2526 return SoundcloudParsingHelper .resolveUrlWithEmbedPlayer ("https://api.soundcloud.com/playlists/" + id );
2627 } catch (Exception e ) {
Original file line number Diff line number Diff line change 1010
1111import static org .schabi .newpipe .extractor .utils .Utils .replaceHttpWithHttps ;
1212
13- public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
13+ public class SoundcloudStreamUrlIdHandler extends UrlIdHandler {
1414 private static final SoundcloudStreamUrlIdHandler instance = new SoundcloudStreamUrlIdHandler ();
1515 private final String URL_PATTERN = "^https?://(www\\ .|m\\ .)?soundcloud.com/[0-9a-z_-]+" +
1616 "/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$" ;
Original file line number Diff line number Diff line change 11package org .schabi .newpipe .extractor .services .youtube ;
22
3+ import org .schabi .newpipe .extractor .ListUrlIdHandler ;
34import org .schabi .newpipe .extractor .UrlIdHandler ;
45import org .schabi .newpipe .extractor .exceptions .ParsingException ;
56import org .schabi .newpipe .extractor .utils .Parser ;
2425 * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2526 */
2627
27- public class YoutubeChannelUrlIdHandler implements UrlIdHandler {
28+ public class YoutubeChannelUrlIdHandler extends ListUrlIdHandler {
2829
2930 private static final YoutubeChannelUrlIdHandler instance = new YoutubeChannelUrlIdHandler ();
3031 private static final String ID_PATTERN = "/(user/[A-Za-z0-9_-]*|channel/[A-Za-z0-9_-]*)" ;
@@ -34,7 +35,7 @@ public static YoutubeChannelUrlIdHandler getInstance() {
3435 }
3536
3637 @ Override
37- public String getUrl (String id ) {
38+ public String getUrl (String id , String [] contentFilter , String sortFilter ) {
3839 return "https://www.youtube.com/" + id ;
3940 }
4041
Original file line number Diff line number Diff line change 11package org .schabi .newpipe .extractor .services .youtube ;
22
33
4+ import org .schabi .newpipe .extractor .ListUrlIdHandler ;
45import org .schabi .newpipe .extractor .UrlIdHandler ;
56import org .schabi .newpipe .extractor .exceptions .ParsingException ;
67import org .schabi .newpipe .extractor .utils .Parser ;
78
8- public class YoutubePlaylistUrlIdHandler implements UrlIdHandler {
9+ public class YoutubePlaylistUrlIdHandler extends ListUrlIdHandler {
910
1011 private static final YoutubePlaylistUrlIdHandler instance = new YoutubePlaylistUrlIdHandler ();
1112 private static final String ID_PATTERN = "([\\ -a-zA-Z0-9_]{10,})" ;
@@ -15,7 +16,7 @@ public static YoutubePlaylistUrlIdHandler getInstance() {
1516 }
1617
1718 @ Override
18- public String getUrl (String id ) {
19+ public String getUrl (String id , String [] contentFilter , String sortFilter ) {
1920 return "https://www.youtube.com/playlist?list=" + id ;
2021 }
2122
Original file line number Diff line number Diff line change 3737 * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
3838 */
3939
40- public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
40+ public class YoutubeStreamUrlIdHandler extends UrlIdHandler {
4141
4242 private static final YoutubeStreamUrlIdHandler instance = new YoutubeStreamUrlIdHandler ();
4343 private static final String ID_PATTERN = "([\\ -a-zA-Z0-9_]{11})" ;
Original file line number Diff line number Diff line change 2020 * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2121 */
2222
23+ import org .schabi .newpipe .extractor .ListUrlIdHandler ;
2324import org .schabi .newpipe .extractor .UrlIdHandler ;
25+ import org .schabi .newpipe .extractor .exceptions .ParsingException ;
2426import org .schabi .newpipe .extractor .utils .Parser ;
2527
26- public class YoutubeTrendingUrlIdHandler implements UrlIdHandler {
28+ public class YoutubeTrendingUrlIdHandler extends ListUrlIdHandler {
2729
28- public String getUrl (String id ) {
30+ public String getUrl (String id , String [] contentFilter , String sortFilter ) {
2931 return "https://www.youtube.com/feed/trending" ;
3032 }
3133
@@ -35,7 +37,7 @@ public String getId(String url) {
3537 }
3638
3739 @ Override
38- public String cleanUrl (String url ) {
40+ public String cleanUrl (String url ) throws ParsingException {
3941 return getUrl ("" );
4042 }
4143
You can’t perform that action at this time.
0 commit comments