Merge branch 'master' into misc-utils
This commit is contained in:
commit
905f84757e
|
@ -188,12 +188,12 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public StreamInfoItem getNextVideo() throws IOException, ExtractionException {
|
||||
public StreamInfoItem getNextStream() throws IOException, ExtractionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException {
|
||||
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
|
||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||
|
||||
String apiUrl = "https://api-v2.soundcloud.com/tracks/" + urlEncode(getId()) + "/related"
|
||||
|
|
|
@ -490,7 +490,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public StreamInfoItem getNextVideo() throws IOException, ExtractionException {
|
||||
public StreamInfoItem getNextStream() throws IOException, ExtractionException {
|
||||
assertPageFetched();
|
||||
try {
|
||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||
|
@ -504,7 +504,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException {
|
||||
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
|
||||
assertPageFetched();
|
||||
try {
|
||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.schabi.newpipe.extractor.stream;
|
|||
|
||||
import org.schabi.newpipe.extractor.Extractor;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.Subtitles;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
|
@ -34,7 +33,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Scrapes information from a video streaming service (eg, YouTube).
|
||||
* Scrapes information from a video/audio streaming service (eg, YouTube).
|
||||
*/
|
||||
public abstract class StreamExtractor extends Extractor {
|
||||
|
||||
|
@ -44,22 +43,234 @@ public abstract class StreamExtractor extends Extractor {
|
|||
super(service, linkHandler, localization);
|
||||
}
|
||||
|
||||
/**
|
||||
* The day on which the stream got uploaded/created. The return information should be in the format
|
||||
* dd.mm.yyyy, however it NewPipe will not crash if its not.
|
||||
* @return The day on which the stream got uploaded.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getUploadDate() throws ParsingException;
|
||||
|
||||
/**
|
||||
* This will return the url to the thumbnail of the stream. Try to return the medium resolution here.
|
||||
* @return The url of the thumbnail.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getThumbnailUrl() throws ParsingException;
|
||||
|
||||
/**
|
||||
* This is the stream description. On YouTube this is the video description. You can return simple HTML here.
|
||||
* @return The description of the stream/video.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getDescription() throws ParsingException;
|
||||
|
||||
/**
|
||||
* Get the age limit
|
||||
* Get the age limit.
|
||||
* @return The age which limits the content or {@value NO_AGE_LIMIT} if there is no limit
|
||||
* @throws ParsingException if an error occurs while parsing
|
||||
*/
|
||||
public abstract int getAgeLimit() throws ParsingException;
|
||||
|
||||
/**
|
||||
* This should return the length of a video in seconds.
|
||||
* @return The length of the stream in seconds.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
public abstract long getLength() throws ParsingException;
|
||||
|
||||
/**
|
||||
* If the url you are currently handling contains a time stamp/seek, you can return the
|
||||
* position it represents here.
|
||||
* If the url has no time stamp simply return zero.
|
||||
* @return the timestamp in seconds
|
||||
* @throws ParsingException
|
||||
*/
|
||||
public abstract long getTimeStamp() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The count of how many people have watched the video/listened to the audio stream.
|
||||
* If the current stream has no view count or its not available simply return -1
|
||||
* @return amount of views.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
public abstract long getViewCount() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The Amount of likes a video/audio stream got.
|
||||
* If the current stream has no likes or its not available simply return -1
|
||||
* @return the amount of likes the stream got
|
||||
* @throws ParsingException
|
||||
*/
|
||||
public abstract long getLikeCount() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The Amount of dislikes a video/audio stream got.
|
||||
* If the current stream has no dislikes or its not available simply return -1
|
||||
* @return the amount of likes the stream got
|
||||
* @throws ParsingException
|
||||
*/
|
||||
public abstract long getDislikeCount() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The Url to the page of the creator/uploader of the stream. This must not be a homepage,
|
||||
* but the page offered by the service the extractor handles. This url will be handled by the
|
||||
* <a href="https://teamnewpipe.github.io/documentation/03_Implement_a_service/#channel">ChannelExtractor</a>,
|
||||
* so be sure to implement that one before you return a value here, otherwise NewPipe will crash if one selects
|
||||
* this url.
|
||||
* @return the url to the page of the creator/uploader of the stream or an empty String
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getUploaderUrl() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The name of the creator/uploader of the stream.
|
||||
* If the name is not available you can simply return an empty string.
|
||||
* @return the name of the creator/uploader of the stream or an empty String
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getUploaderName() throws ParsingException;
|
||||
|
||||
/**
|
||||
* The url to the image file/profile picture/avatar of the creator/uploader of the stream.
|
||||
* If the url is not available you can return an empty String.
|
||||
* @return The url of the image file of the uploader or an empty String
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract String getUploaderAvatarUrl() throws ParsingException;
|
||||
|
||||
/**
|
||||
* Get the dash mpd url. If you don't know what a dash MPD is you can read about it
|
||||
* <a href="https://www.brendanlong.com/the-structure-of-an-mpeg-dash-mpd.html">here</a>.
|
||||
* @return the url as a string or an empty string
|
||||
* @throws ParsingException if an error occurs while reading
|
||||
*/
|
||||
@Nonnull public abstract String getDashMpdUrl() throws ParsingException;
|
||||
|
||||
/**
|
||||
* I am not sure if this is in use, and how this is used. However the frontend is missing support
|
||||
* for HLS streams. Prove me if I am wrong. Please open an
|
||||
* <a href="https://github.com/teamnewpipe/newpipe/issues">issue</a>,
|
||||
* or fix this description if you know whats up with this.
|
||||
* @return The Url to the hls stream.
|
||||
* @throws ParsingException
|
||||
*/
|
||||
@Nonnull public abstract String getHlsUrl() throws ParsingException;
|
||||
|
||||
/**
|
||||
* This should return a list of available
|
||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/AudioStream.html">AudioStream</a>s
|
||||
* You can also return null or an empty list, however be aware that if you don't return anything
|
||||
* in getVideoStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will handle this as
|
||||
* a failed extraction procedure.
|
||||
* @return a list of audio only streams in the format of AudioStream
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* This should return a list of available
|
||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/VideoStream.html">VideoStream</a>s
|
||||
* Be aware this is the list of video streams which do contain an audio stream.
|
||||
* You can also return null or an empty list, however be aware that if you don't return anything
|
||||
* in getAudioStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will handle this as
|
||||
* a failed extraction procedure.
|
||||
* @return a list of combined video and streams in the format of AudioStream
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* This should return a list of available
|
||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/VideoStream.html">VideoStream</a>s.
|
||||
* Be aware this is the list of video streams which do NOT contain an audio stream.
|
||||
* You can also return null or an empty list, however be aware that if you don't return anything
|
||||
* in getAudioStreams(), getVideoStreams() and getDashMpdUrl() either the Collector will handle this as
|
||||
* a failed extraction procedure.
|
||||
* @return a list of video and streams in the format of AudioStream
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* This will return a list of available
|
||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/Subtitles.html">Subtitles</a>s.
|
||||
* If no subtitles are available an empty list can returned.
|
||||
* @return a list of available subtitles or an empty list
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* This will return a list of available
|
||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/Subtitles.html">Subtitles</a>s.
|
||||
* given by a specific type.
|
||||
* If no subtitles in that specific format are available an empty list can returned.
|
||||
* @return a list of available subtitles or an empty list
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
@Nonnull
|
||||
public abstract List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* Get the <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/">StreamType</a>.
|
||||
* @return the type of the stream
|
||||
* @throws ParsingException
|
||||
*/
|
||||
public abstract StreamType getStreamType() throws ParsingException;
|
||||
|
||||
/**
|
||||
* should return the url of the next stream. NewPipe will automatically play
|
||||
* the next stream if the user wants that.
|
||||
* If the next stream is is not available simply return null
|
||||
* @return the InfoItem of the next stream
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
public abstract StreamInfoItem getNextStream() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* Should return a list of streams related to the current handled. Many services show suggested
|
||||
* streams. If you don't like suggested streams you should implement them anyway since they can
|
||||
* be disabled by the user later in the frontend.
|
||||
* This list MUST NOT contain the next available video as this should be return through getNextStream()
|
||||
* If is is not available simply return null
|
||||
* @return a list of InfoItems showing the related videos/streams
|
||||
* @throws IOException
|
||||
* @throws ExtractionException
|
||||
*/
|
||||
public abstract StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* Should analyse the webpage's document and extracts any error message there might be. (e.g. GEMA block)
|
||||
*
|
||||
* @return Error message; null if there is no error message.
|
||||
*/
|
||||
public abstract String getErrorMessage();
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
/// Helper
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Override this function if the format of time stamp in the url is not the same format as that form youtube.
|
||||
* Honestly I don't even know the time stamp fromat of youtube.
|
||||
* @param regexPattern
|
||||
* @return the sime stamp/seek for the video in seconds
|
||||
* @throws ParsingException
|
||||
*/
|
||||
protected long getTimestampSeconds(String regexPattern) throws ParsingException {
|
||||
String timeStamp;
|
||||
try {
|
||||
|
@ -104,42 +315,4 @@ public abstract class StreamExtractor extends Extractor {
|
|||
} else {
|
||||
return 0;
|
||||
}};
|
||||
|
||||
public abstract long getViewCount() throws ParsingException;
|
||||
public abstract long getLikeCount() throws ParsingException;
|
||||
public abstract long getDislikeCount() throws ParsingException;
|
||||
|
||||
@Nonnull
|
||||
public abstract String getUploaderUrl() throws ParsingException;
|
||||
@Nonnull
|
||||
public abstract String getUploaderName() throws ParsingException;
|
||||
@Nonnull
|
||||
public abstract String getUploaderAvatarUrl() throws ParsingException;
|
||||
|
||||
/**
|
||||
* Get the dash mpd url
|
||||
* @return the url as a string or an empty string
|
||||
* @throws ParsingException if an error occurs while reading
|
||||
*/
|
||||
@Nonnull public abstract String getDashMpdUrl() throws ParsingException;
|
||||
@Nonnull public abstract String getHlsUrl() throws ParsingException;
|
||||
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
||||
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
||||
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
||||
|
||||
@Nonnull
|
||||
public abstract List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException;
|
||||
@Nonnull
|
||||
public abstract List<Subtitles> getSubtitles(SubtitlesFormat format) throws IOException, ExtractionException;
|
||||
|
||||
public abstract StreamType getStreamType() throws ParsingException;
|
||||
public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException;
|
||||
public abstract StreamInfoItemsCollector getRelatedVideos() throws IOException, ExtractionException;
|
||||
|
||||
/**
|
||||
* Analyses the webpage's document and extracts any error message there might be.
|
||||
*
|
||||
* @return Error message; null if there is no error message.
|
||||
*/
|
||||
public abstract String getErrorMessage();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
|||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -152,6 +151,9 @@ public class StreamInfo extends Info {
|
|||
streamInfo.getVideoOnlyStreams().addAll(result.getVideoOnlyStreams());
|
||||
streamInfo.getAudioStreams().addAll(result.getAudioStreams());
|
||||
streamInfo.getVideoStreams().addAll(result.getVideoStreams());
|
||||
streamInfo.segmentedVideoOnlyStreams = result.getSegmentedVideoOnlyStreams();
|
||||
streamInfo.segmentedAudioStreams = result.getSegmentedAudioStreams();
|
||||
streamInfo.segmentedVideoStreams = result.getSegmentedVideoStreams();
|
||||
} catch (Exception e) {
|
||||
// Sometimes we receive 403 (forbidden) error when trying to download the manifest (similar to what happens with youtube-dl),
|
||||
// just skip the exception (but store it somewhere), as we later check if we have streams anyway.
|
||||
|
@ -237,7 +239,7 @@ public class StreamInfo extends Info {
|
|||
streamInfo.addError(e);
|
||||
}
|
||||
try {
|
||||
streamInfo.setNextVideo(extractor.getNextVideo());
|
||||
streamInfo.setNextVideo(extractor.getNextStream());
|
||||
} catch (Exception e) {
|
||||
streamInfo.addError(e);
|
||||
}
|
||||
|
@ -271,6 +273,11 @@ public class StreamInfo extends Info {
|
|||
private List<VideoStream> videoOnlyStreams;
|
||||
|
||||
private String dashMpdUrl;
|
||||
private List<VideoStream> segmentedVideoStreams;
|
||||
private List<AudioStream> segmentedAudioStreams;
|
||||
private List<VideoStream> segmentedVideoOnlyStreams;
|
||||
|
||||
|
||||
private String hlsUrl;
|
||||
private StreamInfoItem nextVideo;
|
||||
private List<InfoItem> relatedStreams;
|
||||
|
@ -431,6 +438,30 @@ public class StreamInfo extends Info {
|
|||
this.dashMpdUrl = dashMpdUrl;
|
||||
}
|
||||
|
||||
public List<VideoStream> getSegmentedVideoStreams() {
|
||||
return segmentedVideoStreams;
|
||||
}
|
||||
|
||||
public void setSegmentedVideoStreams(List<VideoStream> segmentedVideoStreams) {
|
||||
this.segmentedVideoStreams = segmentedVideoStreams;
|
||||
}
|
||||
|
||||
public List<AudioStream> getSegmentedAudioStreams() {
|
||||
return segmentedAudioStreams;
|
||||
}
|
||||
|
||||
public void setSegmentedAudioStreams(List<AudioStream> segmentedAudioStreams) {
|
||||
this.segmentedAudioStreams = segmentedAudioStreams;
|
||||
}
|
||||
|
||||
public List<VideoStream> getSegmentedVideoOnlyStreams() {
|
||||
return segmentedVideoOnlyStreams;
|
||||
}
|
||||
|
||||
public void setSegmentedVideoOnlyStreams(List<VideoStream> segmentedVideoOnlyStreams) {
|
||||
this.segmentedVideoOnlyStreams = segmentedVideoOnlyStreams;
|
||||
}
|
||||
|
||||
public String getHlsUrl() {
|
||||
return hlsUrl;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.schabi.newpipe.extractor;
|
||||
package org.schabi.newpipe.extractor.stream;
|
||||
|
||||
import org.schabi.newpipe.extractor.stream.SubtitlesFormat;
|
||||
|
|
@ -59,10 +59,23 @@ public class DashMpdParser {
|
|||
private final List<AudioStream> audioStreams;
|
||||
private final List<VideoStream> videoOnlyStreams;
|
||||
|
||||
public ParserResult(List<VideoStream> videoStreams, List<AudioStream> audioStreams, List<VideoStream> videoOnlyStreams) {
|
||||
private final List<VideoStream> segmentedVideoStreams;
|
||||
private final List<AudioStream> segmentedAudioStreams;
|
||||
private final List<VideoStream> segmentedVideoOnlyStreams;
|
||||
|
||||
|
||||
public ParserResult(List<VideoStream> videoStreams,
|
||||
List<AudioStream> audioStreams,
|
||||
List<VideoStream> videoOnlyStreams,
|
||||
List<VideoStream> segmentedVideoStreams,
|
||||
List<AudioStream> segmentedAudioStreams,
|
||||
List<VideoStream> segmentedVideoOnlyStreams) {
|
||||
this.videoStreams = videoStreams;
|
||||
this.audioStreams = audioStreams;
|
||||
this.videoOnlyStreams = videoOnlyStreams;
|
||||
this.segmentedVideoStreams = segmentedVideoStreams;
|
||||
this.segmentedAudioStreams = segmentedAudioStreams;
|
||||
this.segmentedVideoOnlyStreams = segmentedVideoOnlyStreams;
|
||||
}
|
||||
|
||||
public List<VideoStream> getVideoStreams() {
|
||||
|
@ -76,10 +89,22 @@ public class DashMpdParser {
|
|||
public List<VideoStream> getVideoOnlyStreams() {
|
||||
return videoOnlyStreams;
|
||||
}
|
||||
|
||||
public List<VideoStream> getSegmentedVideoStreams() {
|
||||
return segmentedVideoStreams;
|
||||
}
|
||||
|
||||
public List<AudioStream> getSegmentedAudioStreams() {
|
||||
return segmentedAudioStreams;
|
||||
}
|
||||
|
||||
public List<VideoStream> getSegmentedVideoOnlyStreams() {
|
||||
return segmentedVideoOnlyStreams;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Will try to download (using {@link StreamInfo#dashMpdUrl}) and parse the dash manifest,
|
||||
* Will try to download (using {@link StreamInfo#getDashMpdUrl()}) and parse the dash manifest,
|
||||
* then it will search for any stream that the ItagItem has (by the id).
|
||||
* <p>
|
||||
* It has video, video only and audio streams and will only add to the list if it don't
|
||||
|
@ -90,7 +115,8 @@ public class DashMpdParser {
|
|||
*
|
||||
* @param streamInfo where the parsed streams will be added
|
||||
*/
|
||||
public static ParserResult getStreams(final StreamInfo streamInfo) throws DashMpdParsingException, ReCaptchaException {
|
||||
public static ParserResult getStreams(final StreamInfo streamInfo)
|
||||
throws DashMpdParsingException, ReCaptchaException {
|
||||
String dashDoc;
|
||||
Downloader downloader = NewPipe.getDownloader();
|
||||
try {
|
||||
|
@ -113,6 +139,10 @@ public class DashMpdParser {
|
|||
final List<AudioStream> audioStreams = new ArrayList<>();
|
||||
final List<VideoStream> videoOnlyStreams = new ArrayList<>();
|
||||
|
||||
final List<VideoStream> segmentedVideoStreams = new ArrayList<>();
|
||||
final List<AudioStream> segmentedAudioStreams = new ArrayList<>();
|
||||
final List<VideoStream> segmentedVideoOnlyStreams = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < representationList.getLength(); i++) {
|
||||
final Element representation = (Element) representationList.item(i);
|
||||
try {
|
||||
|
@ -126,34 +156,61 @@ public class DashMpdParser {
|
|||
// instead we need to add the "media=" value from the <SegementURL/> tags inside the <SegmentList/>
|
||||
// tag in order to get a full working url. However each of these is just pointing to a part of the
|
||||
// video, so we can not return a URL with a working stream here.
|
||||
// We decided not to ignore such streams for the moment.
|
||||
if (itag != null && segmentationList == null) {
|
||||
// Instead of putting those streams into the list of regular stream urls wie put them in a
|
||||
// for example "segmentedVideoStreams" list.
|
||||
if (itag != null) {
|
||||
final MediaFormat mediaFormat = MediaFormat.getFromMimeType(mimeType);
|
||||
|
||||
if (itag.itagType.equals(ItagItem.ItagType.AUDIO)) {
|
||||
final AudioStream audioStream = new AudioStream(url, mediaFormat, itag.avgBitrate);
|
||||
|
||||
if (!Stream.containSimilarStream(audioStream, streamInfo.getAudioStreams())) {
|
||||
audioStreams.add(audioStream);
|
||||
if(segmentationList == null) {
|
||||
final AudioStream audioStream = new AudioStream(url, mediaFormat, itag.avgBitrate);
|
||||
if (!Stream.containSimilarStream(audioStream, streamInfo.getAudioStreams())) {
|
||||
audioStreams.add(audioStream);
|
||||
}
|
||||
} else {
|
||||
segmentedAudioStreams.add(
|
||||
new AudioStream(id, mediaFormat, itag.avgBitrate));
|
||||
}
|
||||
} else {
|
||||
boolean isVideoOnly = itag.itagType.equals(ItagItem.ItagType.VIDEO_ONLY);
|
||||
final VideoStream videoStream = new VideoStream(url, mediaFormat, itag.resolutionString, isVideoOnly);
|
||||
|
||||
if (isVideoOnly) {
|
||||
if (!Stream.containSimilarStream(videoStream, streamInfo.getVideoOnlyStreams())) {
|
||||
streamInfo.getVideoOnlyStreams().add(videoStream);
|
||||
videoOnlyStreams.add(videoStream);
|
||||
if(segmentationList == null) {
|
||||
final VideoStream videoStream = new VideoStream(url,
|
||||
mediaFormat,
|
||||
itag.resolutionString,
|
||||
isVideoOnly);
|
||||
|
||||
if (isVideoOnly) {
|
||||
if (!Stream.containSimilarStream(videoStream, streamInfo.getVideoOnlyStreams())) {
|
||||
videoOnlyStreams.add(videoStream);
|
||||
}
|
||||
} else if (!Stream.containSimilarStream(videoStream, streamInfo.getVideoStreams())) {
|
||||
videoStreams.add(videoStream);
|
||||
}
|
||||
} else {
|
||||
final VideoStream videoStream = new VideoStream(id,
|
||||
mediaFormat,
|
||||
itag.resolutionString,
|
||||
isVideoOnly);
|
||||
|
||||
if(isVideoOnly) {
|
||||
segmentedVideoOnlyStreams.add(videoStream);
|
||||
} else {
|
||||
segmentedVideoStreams.add(videoStream);
|
||||
}
|
||||
} else if (!Stream.containSimilarStream(videoStream, streamInfo.getVideoStreams())) {
|
||||
videoStreams.add(videoStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return new ParserResult(videoStreams, audioStreams, videoOnlyStreams);
|
||||
return new ParserResult(
|
||||
videoStreams,
|
||||
audioStreams,
|
||||
videoOnlyStreams,
|
||||
segmentedVideoStreams,
|
||||
segmentedAudioStreams,
|
||||
segmentedVideoOnlyStreams);
|
||||
} catch (Exception e) {
|
||||
throw new DashMpdParsingException("Could not parse Dash mpd", e);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ExtractorHelper {
|
|||
|
||||
public static List<InfoItem> getRelatedVideosOrLogError(StreamInfo info, StreamExtractor extractor) {
|
||||
try {
|
||||
InfoItemsCollector<? extends InfoItem, ?> collector = extractor.getRelatedVideos();
|
||||
InfoItemsCollector<? extends InfoItem, ?> collector = extractor.getRelatedStreams();
|
||||
info.addAllErrors(collector.getErrors());
|
||||
|
||||
//noinspection unchecked
|
||||
|
|
|
@ -101,7 +101,7 @@ public class SoundcloudStreamExtractorDefaultTest {
|
|||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException, IOException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedVideos();
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
}
|
||||
|
|
|
@ -47,15 +47,21 @@ public class YoutubeStreamExtractorDASHTest {
|
|||
|
||||
@Test
|
||||
public void testGetDashMpd() {
|
||||
System.out.println(info.getDashMpdUrl());
|
||||
assertTrue(info.getDashMpdUrl(),
|
||||
info.getDashMpdUrl() != null && !info.getDashMpdUrl().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDashMpdParser() {
|
||||
public void testRegularStreams() {
|
||||
assertEquals(0, info.getAudioStreams().size());
|
||||
assertEquals(0, info.getVideoOnlyStreams().size());
|
||||
assertEquals(4, info.getVideoStreams().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSegmentedStreams() {
|
||||
assertEquals(2, info.getSegmentedAudioStreams().size());
|
||||
assertEquals(3, info.getSegmentedVideoOnlyStreams().size());
|
||||
assertEquals(0, info.getSegmentedVideoStreams().size());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.*;
|
||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||
import org.schabi.newpipe.extractor.utils.Localization;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
|
@ -17,7 +16,6 @@ import java.io.IOException;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeTrendingExtractorTest.extractor;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 30.12.15.
|
||||
|
@ -151,7 +149,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
|
||||
@Test
|
||||
public void testGetRelatedVideos() throws ExtractionException, IOException {
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedVideos();
|
||||
StreamInfoItemsCollector relatedVideos = extractor.getRelatedStreams();
|
||||
Utils.printErrors(relatedVideos.getErrors());
|
||||
assertFalse(relatedVideos.getItems().isEmpty());
|
||||
assertTrue(relatedVideos.getErrors().isEmpty());
|
||||
|
|
|
@ -28,7 +28,7 @@ public class YoutubeSearchCountTest {
|
|||
public void testViewCount() {
|
||||
ChannelInfoItem ci = (ChannelInfoItem) itemsPage.getItems().get(0);
|
||||
assertTrue("Count does not fit: " + Long.toString(ci.getSubscriberCount()),
|
||||
65043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 68043316);
|
||||
69043316 < ci.getSubscriberCount() && ci.getSubscriberCount() < 73043316);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue