Skip to content

Commit 7ae274b

Browse files
committed
Fix uploader name when requesting next streams
1 parent bd3db34 commit 7ae274b

4 files changed

Lines changed: 19 additions & 20 deletions

File tree

src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434

3535
public class ChannelInfo extends ListInfo {
3636

37-
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
38-
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
37+
public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException {
38+
return getMoreItems(serviceItem.getService(), url, nextStreamsUrl);
3939
}
4040

41-
public static NextItemsResult getMoreItems(StreamingService service, String nextStreamsUrl) throws IOException, ExtractionException {
42-
return service.getChannelExtractor(null, nextStreamsUrl).getNextStreams();
41+
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
42+
return service.getChannelExtractor(url, nextStreamsUrl).getNextStreams();
4343
}
4444

4545
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {

src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
public class PlaylistInfo extends ListInfo {
1616

17-
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
18-
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
17+
public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException {
18+
return getMoreItems(serviceItem.getService(), url, nextStreamsUrl);
1919
}
2020

21-
public static NextItemsResult getMoreItems(StreamingService service, String nextStreamsUrl) throws IOException, ExtractionException {
22-
return service.getPlaylistExtractor(null, nextStreamsUrl).getNextStreams();
21+
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
22+
return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams();
2323
}
2424

2525
public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException {

src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
4545
private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id=";
4646
private static final String CHANNEL_URL_PARAMETERS = "/videos?view=0&flow=list&sort=dd&live_view=10000";
4747

48-
private String channelName = ""; //Small hack used to make the channelName available to NextStreams
49-
5048
private Document doc;
5149
/**
5250
* It's lazily initialized (when getNextStreams is called)
@@ -69,6 +67,13 @@ public void fetchPage() throws IOException, ExtractionException {
6967
nextStreamsAjax = null;
7068
}
7169

70+
@Override
71+
protected boolean fetchPageUponCreation() {
72+
// Unfortunately, we have to fetch the page even if we are getting only next streams,
73+
// as they don't deliver enough information on their own (the channel name, for example).
74+
return true;
75+
}
76+
7277
@Override
7378
public String getCleanUrl() {
7479
try {
@@ -93,8 +98,7 @@ public String getId() throws ParsingException {
9398
@Override
9499
public String getName() throws ParsingException {
95100
try {
96-
channelName = doc.select("span[class=\"qualified-channel-title-text\"]").first().select("a").first().text();
97-
return channelName;
101+
return doc.select("meta[property=\"og:title\"]").first().attr("content");
98102
} catch (Exception e) {
99103
throw new ParsingException("Could not get channel name", e);
100104
}
@@ -204,10 +208,10 @@ private String getNextStreamsUrlFrom(Document d) throws ParsingException {
204208
}
205209
}
206210

207-
private void collectStreamsFrom(StreamInfoItemCollector collector,
208-
Element element) throws ParsingException {
211+
private void collectStreamsFrom(StreamInfoItemCollector collector, Element element) throws ParsingException {
209212
collector.getItemList().clear();
210213

214+
final String uploaderName = getName();
211215
for (final Element li : element.children()) {
212216
if (li.select("div[class=\"feed-item-dismissable\"]").first() != null) {
213217
collector.commit(new YoutubeStreamInfoItemExtractor(li) {
@@ -235,11 +239,7 @@ public String getName() throws ParsingException {
235239

236240
@Override
237241
public String getUploaderName() throws ParsingException {
238-
if(channelName.isEmpty()) {
239-
return "";
240-
} else {
241-
return channelName;
242-
}
242+
return uploaderName;
243243
}
244244

245245
@Override

src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.schabi.newpipe.extractor.ListExtractor;
77
import org.schabi.newpipe.extractor.NewPipe;
88
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
9-
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
109

1110
import static org.junit.Assert.*;
1211
import static org.schabi.newpipe.extractor.ServiceList.YouTube;

0 commit comments

Comments
 (0)