mirror of
https://github.com/TeamNewPipe/NewPipeExtractor
synced 2024-12-13 12:30:51 +01:00
Override getUploaderUrl fro YoutubeTrendingExtractor
This commit is contained in:
parent
d76c8e1773
commit
dacffda194
@ -107,11 +107,28 @@ public class YoutubeTrendingExtractor extends KioskExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUploaderUrl() throws ParsingException {
|
||||
try {
|
||||
String link = getUploaderLink().attr("href");
|
||||
if(link.isEmpty()) {
|
||||
throw new IllegalArgumentException("is empty");
|
||||
}
|
||||
return link;
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get Uploader name");
|
||||
}
|
||||
}
|
||||
|
||||
private Element getUploaderLink() {
|
||||
Element uploaderEl = el.select("div[class*=\"yt-lockup-byline \"]").first();
|
||||
return uploaderEl.select("a").first();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUploaderName() throws ParsingException {
|
||||
try {
|
||||
Element uploaderEl = el.select("div[class*=\"yt-lockup-byline \"]").first();
|
||||
return uploaderEl.select("a").text();
|
||||
return getUploaderLink().text();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get Uploader name");
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
@ -40,12 +39,12 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
*/
|
||||
public class YoutubeTrendingExtractorTest {
|
||||
|
||||
KioskExtractor extractor;
|
||||
YoutubeTrendingExtractor extractor;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = YouTube.getService()
|
||||
extractor = (YoutubeTrendingExtractor) YouTube.getService()
|
||||
.getKioskList()
|
||||
.getExtractorById("Trending", null);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user