mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 22:00:32 +05:30
Fix uploader name when requesting next streams
This commit is contained in:
parent
bd3db34092
commit
7ae274b299
@ -34,12 +34,12 @@ import java.util.ArrayList;
|
||||
|
||||
public class ChannelInfo extends ListInfo {
|
||||
|
||||
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
|
||||
public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return getMoreItems(serviceItem.getService(), url, nextStreamsUrl);
|
||||
}
|
||||
|
||||
public static NextItemsResult getMoreItems(StreamingService service, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return service.getChannelExtractor(null, nextStreamsUrl).getNextStreams();
|
||||
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return service.getChannelExtractor(url, nextStreamsUrl).getNextStreams();
|
||||
}
|
||||
|
||||
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
||||
|
@ -14,12 +14,12 @@ import java.util.ArrayList;
|
||||
|
||||
public class PlaylistInfo extends ListInfo {
|
||||
|
||||
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
|
||||
public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return getMoreItems(serviceItem.getService(), url, nextStreamsUrl);
|
||||
}
|
||||
|
||||
public static NextItemsResult getMoreItems(StreamingService service, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return service.getPlaylistExtractor(null, nextStreamsUrl).getNextStreams();
|
||||
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams();
|
||||
}
|
||||
|
||||
public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException {
|
||||
|
@ -45,8 +45,6 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||
private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id=";
|
||||
private static final String CHANNEL_URL_PARAMETERS = "/videos?view=0&flow=list&sort=dd&live_view=10000";
|
||||
|
||||
private String channelName = ""; //Small hack used to make the channelName available to NextStreams
|
||||
|
||||
private Document doc;
|
||||
/**
|
||||
* It's lazily initialized (when getNextStreams is called)
|
||||
@ -69,6 +67,13 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||
nextStreamsAjax = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean fetchPageUponCreation() {
|
||||
// Unfortunately, we have to fetch the page even if we are getting only next streams,
|
||||
// as they don't deliver enough information on their own (the channel name, for example).
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCleanUrl() {
|
||||
try {
|
||||
@ -93,8 +98,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||
@Override
|
||||
public String getName() throws ParsingException {
|
||||
try {
|
||||
channelName = doc.select("span[class=\"qualified-channel-title-text\"]").first().select("a").first().text();
|
||||
return channelName;
|
||||
return doc.select("meta[property=\"og:title\"]").first().attr("content");
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get channel name", e);
|
||||
}
|
||||
@ -204,10 +208,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||
}
|
||||
}
|
||||
|
||||
private void collectStreamsFrom(StreamInfoItemCollector collector,
|
||||
Element element) throws ParsingException {
|
||||
private void collectStreamsFrom(StreamInfoItemCollector collector, Element element) throws ParsingException {
|
||||
collector.getItemList().clear();
|
||||
|
||||
final String uploaderName = getName();
|
||||
for (final Element li : element.children()) {
|
||||
if (li.select("div[class=\"feed-item-dismissable\"]").first() != null) {
|
||||
collector.commit(new YoutubeStreamInfoItemExtractor(li) {
|
||||
@ -235,11 +239,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||
|
||||
@Override
|
||||
public String getUploaderName() throws ParsingException {
|
||||
if(channelName.isEmpty()) {
|
||||
return "";
|
||||
} else {
|
||||
return channelName;
|
||||
}
|
||||
return uploaderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,6 @@ import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.ListExtractor;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
Loading…
Reference in New Issue
Block a user