56 lines
1.7 KiB
Java
56 lines
1.7 KiB
Java
// Created by Fynn Godau 2019, licensed GNU GPL version 3 or later
|
|
|
|
package org.schabi.newpipe.extractor.services.bandcamp.linkHandler;
|
|
|
|
import org.schabi.newpipe.extractor.search.filter.FilterItem;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
|
|
import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Just as with streams, the album ids are essentially useless for us.
|
|
*/
|
|
public final class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
|
|
|
|
private static final BandcampPlaylistLinkHandlerFactory INSTANCE
|
|
= new BandcampPlaylistLinkHandlerFactory();
|
|
|
|
private BandcampPlaylistLinkHandlerFactory() {
|
|
}
|
|
|
|
public static BandcampPlaylistLinkHandlerFactory getInstance() {
|
|
return INSTANCE;
|
|
}
|
|
|
|
@Override
|
|
public String getId(final String url) throws ParsingException, UnsupportedOperationException {
|
|
return getUrl(url);
|
|
}
|
|
|
|
@Override
|
|
public String getUrl(final String url,
|
|
final List<FilterItem> contentFilter,
|
|
final List<FilterItem> sortFilter)
|
|
throws ParsingException, UnsupportedOperationException {
|
|
return url;
|
|
}
|
|
|
|
/**
|
|
* Accepts all bandcamp URLs that contain /album/ behind their domain name.
|
|
*/
|
|
@Override
|
|
public boolean onAcceptUrl(final String url) throws ParsingException {
|
|
|
|
// Exclude URLs which do not lead to an album
|
|
if (!url.toLowerCase().matches("https?://.+\\..+/album/.+")) {
|
|
return false;
|
|
}
|
|
|
|
// Test whether domain is supported
|
|
return BandcampExtractorHelper.isSupportedDomain(url);
|
|
}
|
|
}
|