fix yt trending contains to less items
This commit is contained in:
parent
a0e5c88b13
commit
5f2d0cf6b5
|
@ -23,6 +23,7 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
import org.schabi.newpipe.extractor.*;
|
import org.schabi.newpipe.extractor.*;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
@ -81,7 +82,8 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
|
||||||
@Override
|
@Override
|
||||||
public StreamInfoItemCollector getStreams() throws ParsingException {
|
public StreamInfoItemCollector getStreams() throws ParsingException {
|
||||||
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
||||||
Element ul = doc.select("ul[class*=\"expanded-shelf-content-list\"]").first();
|
Elements uls = doc.select("ul[class*=\"expanded-shelf-content-list\"]");
|
||||||
|
for(Element ul : uls) {
|
||||||
for(final Element li : ul.children()) {
|
for(final Element li : ul.children()) {
|
||||||
final Element el = li.select("div[class*=\"yt-lockup-dismissable\"]").first();
|
final Element el = li.select("div[class*=\"yt-lockup-dismissable\"]").first();
|
||||||
collector.commit(new YoutubeStreamInfoItemExtractor(li) {
|
collector.commit(new YoutubeStreamInfoItemExtractor(li) {
|
||||||
|
@ -109,7 +111,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
|
||||||
public String getUploaderUrl() throws ParsingException {
|
public String getUploaderUrl() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
String link = getUploaderLink().attr("href");
|
String link = getUploaderLink().attr("href");
|
||||||
if(link.isEmpty()) {
|
if (link.isEmpty()) {
|
||||||
throw new IllegalArgumentException("is empty");
|
throw new IllegalArgumentException("is empty");
|
||||||
}
|
}
|
||||||
return link;
|
return link;
|
||||||
|
@ -152,6 +154,7 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return collector;
|
return collector;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class YoutubeTrendingExtractorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetStreams() throws Exception {
|
public void testGetStreamsQuantity() throws Exception {
|
||||||
StreamInfoItemCollector collector = extractor.getStreams();
|
StreamInfoItemCollector collector = extractor.getStreams();
|
||||||
Utils.printErrors(collector);
|
Utils.printErrors(collector);
|
||||||
assertFalse("no streams are received", collector.getItemList().isEmpty());
|
assertTrue("no streams are received", collector.getItemList().size() >= 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue