-Added hls manifest url extraction.

-Changed manifest url fields to nonnull.
This commit is contained in:
John Zhen Mo 2018-02-25 13:03:32 -08:00
parent e851c12230
commit 690f241357
4 changed files with 44 additions and 8 deletions

View File

@ -116,9 +116,16 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
return SoundcloudParsingHelper.getAvatarUrl(track); return SoundcloudParsingHelper.getAvatarUrl(track);
} }
@Nonnull
@Override @Override
public String getDashMpdUrl() { public String getDashMpdUrl() {
return null; return "";
}
@Nonnull
@Override
public String getHlsUrl() throws ParsingException {
return "";
} }
@Override @Override

View File

@ -66,12 +66,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} }
} }
public class LiveStreamException extends ContentNotAvailableException {
LiveStreamException(String message) {
super(message);
}
}
public class SubtitlesException extends ContentNotAvailableException { public class SubtitlesException extends ContentNotAvailableException {
SubtitlesException(String message, Throwable cause) { SubtitlesException(String message, Throwable cause) {
super(message, cause); super(message, cause);
@ -338,6 +332,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} }
} }
@Nonnull
@Override @Override
public String getDashMpdUrl() throws ParsingException { public String getDashMpdUrl() throws ParsingException {
assertPageFetched(); assertPageFetched();
@ -365,6 +360,24 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} }
} }
@Nonnull
@Override
public String getHlsUrl() throws ParsingException {
assertPageFetched();
try {
String hlsvp;
if (playerArgs != null && playerArgs.isString("hlsvp")) {
hlsvp = playerArgs.getString("hlsvp", "");
} else {
return "";
}
return hlsvp;
} catch (Exception e) {
throw new ParsingException("Could not get hls manifest url", e);
}
}
@Override @Override
public List<AudioStream> getAudioStreams() throws IOException, ExtractionException { public List<AudioStream> getAudioStreams() throws IOException, ExtractionException {
assertPageFetched(); assertPageFetched();

View File

@ -126,7 +126,8 @@ public abstract class StreamExtractor extends Extractor {
* @return the url as a string or an empty string * @return the url as a string or an empty string
* @throws ParsingException if an error occurs while reading * @throws ParsingException if an error occurs while reading
*/ */
public abstract String getDashMpdUrl() throws ParsingException; @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<AudioStream> getAudioStreams() throws IOException, ExtractionException;
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException; public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException; public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;

View File

@ -126,6 +126,10 @@ public class StreamInfo extends Info {
return dashMpdUrl; return dashMpdUrl;
} }
public String getHlsUrl() {
return hlsUrl;
}
public StreamInfoItem getNextVideo() { public StreamInfoItem getNextVideo() {
return next_video; return next_video;
} }
@ -206,6 +210,10 @@ public class StreamInfo extends Info {
this.dashMpdUrl = dashMpdUrl; this.dashMpdUrl = dashMpdUrl;
} }
public void setHlsUrl(String hlsUrl) {
this.hlsUrl = hlsUrl;
}
public void setNextVideo(StreamInfoItem next_video) { public void setNextVideo(StreamInfoItem next_video) {
this.next_video = next_video; this.next_video = next_video;
} }
@ -298,6 +306,12 @@ public class StreamInfo extends Info {
streamInfo.addError(new ExtractionException("Couldn't get Dash manifest", e)); streamInfo.addError(new ExtractionException("Couldn't get Dash manifest", e));
} }
try {
streamInfo.setHlsUrl(extractor.getHlsUrl());
} catch (Exception e) {
streamInfo.addError(new ExtractionException("Couldn't get HLS manifest", e));
}
/* Load and extract audio */ /* Load and extract audio */
try { try {
streamInfo.setAudioStreams(extractor.getAudioStreams()); streamInfo.setAudioStreams(extractor.getAudioStreams());
@ -447,6 +461,7 @@ public class StreamInfo extends Info {
// crawling such a file is not service dependent. Therefore getting audio only streams by yust // crawling such a file is not service dependent. Therefore getting audio only streams by yust
// providing the dash mpd file will be possible in the future. // providing the dash mpd file will be possible in the future.
public String dashMpdUrl; public String dashMpdUrl;
public String hlsUrl;
public StreamInfoItem next_video; public StreamInfoItem next_video;
public List<InfoItem> related_streams; public List<InfoItem> related_streams;