mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 22:00:32 +05:30
add channel donations for youtube
This commit is contained in:
parent
17e7e5a359
commit
016c2fc549
@ -35,7 +35,8 @@ public enum MediaFormat {
|
|||||||
// audio formats
|
// audio formats
|
||||||
M4A (0x3, "m4a", "m4a", "audio/mp4"),
|
M4A (0x3, "m4a", "m4a", "audio/mp4"),
|
||||||
WEBMA (0x4, "WebM", "webm", "audio/webm"),
|
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 int id;
|
||||||
public final String name;
|
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.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
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.Parser;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
|
|
||||||
@ -188,14 +189,16 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
public String[] getDonationLinks() throws ParsingException {
|
public String[] getDonationLinks() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
ArrayList<String> links = new ArrayList<>();
|
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) {
|
if(linkHolder == null) {
|
||||||
// this occures if no links are embeded into the channel
|
// this occures if no links are embeded into the channel
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
for(Element a : linkHolder.select("a")) {
|
for(Element a : linkHolder.select("a")) {
|
||||||
System.err.println(a.attr("abs:href"));
|
String link = a.attr("abs:href");
|
||||||
links.add(a.attr("abs:href"));
|
if(DonationLinkHelper.getServiceByLink(link) != DonationLinkHelper.DonationService.NO_DONATION) {
|
||||||
|
links.add(link);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String[] retLinks = new String[links.size()];
|
String[] retLinks = new String[links.size()];
|
||||||
retLinks = links.toArray(retLinks);
|
retLinks = links.toArray(retLinks);
|
||||||
|
@ -106,11 +106,10 @@ public class YoutubeChannelExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void testChannelDonation() throws Exception {
|
public void testChannelDonation() throws Exception {
|
||||||
// this needs to be ignored since wed have to upgrade channel extractor to the new yt interface
|
// this needs to be ignored since wed have to upgrade channel extractor to the new yt interface
|
||||||
// in order to make this work
|
// in order to make this work
|
||||||
assertTrue(extractor.getDonationLinks().length != 0);
|
assertTrue(extractor.getDonationLinks().length == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +216,7 @@ public class YoutubeChannelExtractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChannelDonation() throws Exception {
|
public void testChannelDonation() throws Exception {
|
||||||
assertTrue(extractor.getDonationLinks().length == 0);
|
assertTrue(extractor.getDonationLinks().length == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user