2020-04-10 10:51:05 +02:00
|
|
|
package org.schabi.newpipe.extractor.services.soundcloud.linkHandler;
|
2017-08-20 10:03:41 +02:00
|
|
|
|
2023-06-29 22:56:51 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2018-07-13 18:02:40 +02:00
|
|
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
2017-08-20 10:03:41 +02:00
|
|
|
import org.schabi.newpipe.extractor.utils.Parser;
|
|
|
|
|
2018-07-01 16:21:40 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2023-06-29 22:56:51 +02:00
|
|
|
public final class SoundcloudChartsLinkHandlerFactory extends ListLinkHandlerFactory {
|
|
|
|
|
|
|
|
private static final SoundcloudChartsLinkHandlerFactory INSTANCE =
|
|
|
|
new SoundcloudChartsLinkHandlerFactory();
|
|
|
|
|
2021-05-15 17:51:43 +02:00
|
|
|
private static final String TOP_URL_PATTERN =
|
|
|
|
"^https?://(www\\.|m\\.)?soundcloud.com/charts(/top)?/?([#?].*)?$";
|
|
|
|
private static final String URL_PATTERN =
|
|
|
|
"^https?://(www\\.|m\\.)?soundcloud.com/charts(/top|/new)?/?([#?].*)?$";
|
2017-08-20 10:03:41 +02:00
|
|
|
|
2023-06-29 22:56:51 +02:00
|
|
|
private SoundcloudChartsLinkHandlerFactory() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SoundcloudChartsLinkHandlerFactory getInstance() {
|
|
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
|
2017-08-20 10:03:41 +02:00
|
|
|
@Override
|
2023-06-29 22:56:51 +02:00
|
|
|
public String getId(final String url) throws ParsingException, UnsupportedOperationException {
|
2018-01-20 18:48:15 +01:00
|
|
|
if (Parser.isMatch(TOP_URL_PATTERN, url.toLowerCase())) {
|
2017-08-20 10:03:41 +02:00
|
|
|
return "Top 50";
|
|
|
|
} else {
|
|
|
|
return "New & hot";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-01 16:21:40 +02:00
|
|
|
@Override
|
2021-05-15 17:51:43 +02:00
|
|
|
public String getUrl(final String id,
|
|
|
|
final List<String> contentFilter,
|
2023-06-29 22:56:51 +02:00
|
|
|
final String sortFilter)
|
|
|
|
throws ParsingException, UnsupportedOperationException {
|
2018-05-06 14:08:50 +02:00
|
|
|
if (id.equals("Top 50")) {
|
2017-08-20 10:03:41 +02:00
|
|
|
return "https://soundcloud.com/charts/top";
|
|
|
|
} else {
|
|
|
|
return "https://soundcloud.com/charts/new";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-05-06 14:08:50 +02:00
|
|
|
public boolean onAcceptUrl(final String url) {
|
2018-01-20 18:48:15 +01:00
|
|
|
return Parser.isMatch(URL_PATTERN, url.toLowerCase());
|
2017-08-20 10:03:41 +02:00
|
|
|
}
|
|
|
|
}
|