Handle 100+ items in playlist
This commit is contained in:
parent
fb9b9691b7
commit
2b9b2a78e8
|
@ -7,6 +7,9 @@ import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
|
|
||||||
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
|
public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
|
||||||
|
public final static long UNKNOWN_ITEMS = -1;
|
||||||
|
public final static long INFINITE_ITEMS = -2;
|
||||||
|
public final static long MORE_THAN_100_ITEMS = -3;
|
||||||
|
|
||||||
public PlaylistExtractor(StreamingService service, ListLinkHandler linkHandler) {
|
public PlaylistExtractor(StreamingService service, ListLinkHandler linkHandler) {
|
||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
|
|
|
@ -30,6 +30,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import static org.schabi.newpipe.extractor.playlist.PlaylistExtractor.MORE_THAN_100_ITEMS;
|
||||||
|
import static org.schabi.newpipe.extractor.playlist.PlaylistExtractor.UNKNOWN_ITEMS;
|
||||||
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.fixThumbnailUrl;
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.fixThumbnailUrl;
|
||||||
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.getJsonResponse;
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.getJsonResponse;
|
||||||
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.getTextFromObject;
|
import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper.getTextFromObject;
|
||||||
|
@ -494,10 +496,16 @@ public class YoutubeSearchExtractor extends SearchExtractor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getStreamCount() throws ParsingException {
|
public long getStreamCount() throws ParsingException {
|
||||||
if (searchType.equals(MUSIC_ALBUMS)) return -1;
|
if (searchType.equals(MUSIC_ALBUMS)) return UNKNOWN_ITEMS;
|
||||||
String count = getTextFromObject(info.getArray("flexColumns").getObject(2)
|
String count = getTextFromObject(info.getArray("flexColumns").getObject(2)
|
||||||
.getObject("musicResponsiveListItemFlexColumnRenderer").getObject("text"));
|
.getObject("musicResponsiveListItemFlexColumnRenderer").getObject("text"));
|
||||||
if (count != null && !count.isEmpty()) return Long.parseLong(Utils.removeNonDigitCharacters(count));
|
if (count != null && !count.isEmpty()) {
|
||||||
|
if (count.contains("100+")) {
|
||||||
|
return MORE_THAN_100_ITEMS;
|
||||||
|
} else {
|
||||||
|
return Long.parseLong(Utils.removeNonDigitCharacters(count));
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new ParsingException("Could not get count");
|
throw new ParsingException("Could not get count");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue