add channel donations for youtube
This commit is contained in:
parent
17e7e5a359
commit
016c2fc549
|
@ -35,7 +35,8 @@ public enum MediaFormat {
|
|||
// audio formats
|
||||
M4A (0x3, "m4a", "m4a", "audio/mp4"),
|
||||
WEBMA (0x4, "WebM", "webm", "audio/webm"),
|
||||
MP3 (0x5, "MP3", "mp3", "audio/mpeg");
|
||||
MP3 (0x5, "MP3", "mp3", "audio/mpeg"),
|
||||
OPUS (0x6, "opus", "opus", "audio/opus");
|
||||
|
||||
public final int id;
|
||||
public final String name;
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
import org.schabi.newpipe.extractor.utils.DonationLinkHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Parser;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
|
@ -188,14 +189,16 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
public String[] getDonationLinks() throws ParsingException {
|
||||
try {
|
||||
ArrayList<String> links = new ArrayList<>();
|
||||
Element linkHolder = doc.select("div[id=\"links-holder\"]").first();
|
||||
Element linkHolder = doc.select("div[id=\"header-links\"]").first();
|
||||
if(linkHolder == null) {
|
||||
// this occures if no links are embeded into the channel
|
||||
return new String[0];
|
||||
}
|
||||
for(Element a : linkHolder.select("a")) {
|
||||
System.err.println(a.attr("abs:href"));
|
||||
links.add(a.attr("abs:href"));
|
||||
String link = a.attr("abs:href");
|
||||
if(DonationLinkHelper.getServiceByLink(link) != DonationLinkHelper.DonationService.NO_DONATION) {
|
||||
links.add(link);
|
||||
}
|
||||
}
|
||||
String[] retLinks = new String[links.size()];
|
||||
retLinks = links.toArray(retLinks);
|
||||
|
|
|
@ -106,11 +106,10 @@ public class YoutubeChannelExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testChannelDonation() throws Exception {
|
||||
// this needs to be ignored since wed have to upgrade channel extractor to the new yt interface
|
||||
// in order to make this work
|
||||
assertTrue(extractor.getDonationLinks().length != 0);
|
||||
assertTrue(extractor.getDonationLinks().length == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +216,7 @@ public class YoutubeChannelExtractorTest {
|
|||
|
||||
@Test
|
||||
public void testChannelDonation() throws Exception {
|
||||
assertTrue(extractor.getDonationLinks().length == 0);
|
||||
assertTrue(extractor.getDonationLinks().length == 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue