mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 22:00:32 +05:30
added comments to stream info
This commit is contained in:
parent
06898f47b2
commit
f62f147ea0
@ -44,6 +44,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
|||||||
public InfoItemsPage<CommentsInfoItem> getInitialPage() throws IOException, ExtractionException {
|
public InfoItemsPage<CommentsInfoItem> getInitialPage() throws IOException, ExtractionException {
|
||||||
// initial page does not load any comments but is required to get session token
|
// initial page does not load any comments but is required to get session token
|
||||||
// and cookies
|
// and cookies
|
||||||
|
super.fetchPage();
|
||||||
return getPage(getNextPageUrl());
|
return getPage(getNextPageUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package org.schabi.newpipe.extractor.stream;
|
package org.schabi.newpipe.extractor.stream;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.*;
|
import org.schabi.newpipe.extractor.*;
|
||||||
|
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||||
|
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||||
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||||
@ -247,6 +251,19 @@ public class StreamInfo extends Info {
|
|||||||
}
|
}
|
||||||
|
|
||||||
streamInfo.setRelatedStreams(ExtractorHelper.getRelatedVideosOrLogError(streamInfo, extractor));
|
streamInfo.setRelatedStreams(ExtractorHelper.getRelatedVideosOrLogError(streamInfo, extractor));
|
||||||
|
|
||||||
|
CommentsExtractor commentsExtractor = null;
|
||||||
|
try {
|
||||||
|
commentsExtractor = NewPipe.getService(streamInfo.getServiceId()).getCommentsExtractor(streamInfo.getUrl());
|
||||||
|
} catch (ExtractionException e) {
|
||||||
|
streamInfo.addError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(null != commentsExtractor) {
|
||||||
|
InfoItemsPage<CommentsInfoItem> initialCommentsPage = ExtractorHelper.getItemsPageOrLogError(streamInfo, commentsExtractor);
|
||||||
|
streamInfo.setComments(initialCommentsPage.getItems());
|
||||||
|
}
|
||||||
|
|
||||||
return streamInfo;
|
return streamInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +290,7 @@ public class StreamInfo extends Info {
|
|||||||
private String hlsUrl;
|
private String hlsUrl;
|
||||||
private StreamInfoItem nextVideo;
|
private StreamInfoItem nextVideo;
|
||||||
private List<InfoItem> relatedStreams;
|
private List<InfoItem> relatedStreams;
|
||||||
|
private List<CommentsInfoItem> comments;
|
||||||
|
|
||||||
private long startPosition = 0;
|
private long startPosition = 0;
|
||||||
private List<Subtitles> subtitles;
|
private List<Subtitles> subtitles;
|
||||||
@ -470,4 +488,14 @@ public class StreamInfo extends Info {
|
|||||||
this.subtitles = subtitles;
|
this.subtitles = subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CommentsInfoItem> getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(List<CommentsInfoItem> comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.InfoItem;
|
|||||||
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||||
|
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||||
|
|
||||||
@ -39,4 +40,5 @@ public class ExtractorHelper {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -184,10 +185,7 @@ public class Downloader implements org.schabi.newpipe.extractor.Downloader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DownloadResponse get(String siteUrl) throws IOException, ReCaptchaException {
|
public DownloadResponse get(String siteUrl) throws IOException, ReCaptchaException {
|
||||||
URL url = new URL(siteUrl);
|
return get(siteUrl, Collections.emptyMap());
|
||||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
|
||||||
String responseBody = dl(con);
|
|
||||||
return new DownloadResponse(responseBody, con.getHeaderFields());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,6 @@ public class YoutubeCommentsExtractorTest {
|
|||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = (YoutubeCommentsExtractor) YouTube
|
extractor = (YoutubeCommentsExtractor) YouTube
|
||||||
.getCommentsExtractor("https://www.youtube.com/watch?v=rrgFN3AxGfs");
|
.getCommentsExtractor("https://www.youtube.com/watch?v=rrgFN3AxGfs");
|
||||||
extractor.fetchPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user