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
|
@Override
|
||||||
public String getUploaderName() throws ParsingException {
|
public String getUploaderName() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
Element uploaderEl = el.select("div[class*=\"yt-lockup-byline \"]").first();
|
return getUploaderLink().text();
|
||||||
return uploaderEl.select("a").text();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get Uploader name");
|
throw new ParsingException("Could not get Uploader name");
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static junit.framework.TestCase.assertFalse;
|
||||||
|
@ -40,12 +39,12 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
*/
|
*/
|
||||||
public class YoutubeTrendingExtractorTest {
|
public class YoutubeTrendingExtractorTest {
|
||||||
|
|
||||||
KioskExtractor extractor;
|
YoutubeTrendingExtractor extractor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = YouTube.getService()
|
extractor = (YoutubeTrendingExtractor) YouTube.getService()
|
||||||
.getKioskList()
|
.getKioskList()
|
||||||
.getExtractorById("Trending", null);
|
.getExtractorById("Trending", null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue