Override getUploaderUrl fro YoutubeTrendingExtractor

This commit is contained in:
Coffeemakr 2017-11-25 04:00:19 +01:00
parent d76c8e1773
commit dacffda194
No known key found for this signature in database
GPG Key ID: 3F35676D8FF6E743
2 changed files with 21 additions and 5 deletions

View File

@ -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");
}

View File

@ -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);
}