NewPipeExtractor/extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudChannelUIHFactory...

45 lines
1.5 KiB
Java
Raw Normal View History

package org.schabi.newpipe.extractor.services.soundcloud;
2018-07-01 16:21:40 +02:00
import org.schabi.newpipe.extractor.uih.ListUIHFactory;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Parser;
import org.schabi.newpipe.extractor.utils.Utils;
2018-07-01 16:21:40 +02:00
import java.util.List;
2018-06-21 17:18:26 +02:00
public class SoundcloudChannelUIHFactory extends ListUIHFactory {
private static final SoundcloudChannelUIHFactory instance = new SoundcloudChannelUIHFactory();
2018-01-20 18:48:15 +01:00
private final String URL_PATTERN = "^https?://(www\\.|m\\.)?soundcloud.com/[0-9a-z_-]+" +
"(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
2018-06-21 17:18:26 +02:00
public static SoundcloudChannelUIHFactory getInstance() {
return instance;
}
@Override
2018-07-01 16:21:40 +02:00
public String getId(String url) throws ParsingException {
Utils.checkUrl(URL_PATTERN, url);
try {
2017-08-06 22:20:15 +02:00
return SoundcloudParsingHelper.resolveIdWithEmbedPlayer(url);
} catch (Exception e) {
throw new ParsingException(e.getMessage(), e);
}
}
@Override
2018-07-01 16:21:40 +02:00
public String getUrl(String id, List<String> contentFilter, String sortFilter) throws ParsingException {
try {
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/" + id);
} catch (Exception e) {
throw new ParsingException(e.getMessage(), e);
}
}
@Override
public boolean onAcceptUrl(final String url) {
return Parser.isMatch(URL_PATTERN, url.toLowerCase());
}
}