Try to update the segment playlist URL, if loading the playlist fails
This commit is contained in:
parent
0fe466bc1a
commit
d820d611f1
|
@ -124,6 +124,9 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
|||
}
|
||||
throw new InvalidPlaylistException("Playlist has no media playlist");
|
||||
} else {
|
||||
// update playlist url in case the streaming server has switched or something
|
||||
LOG.debug("Loading segment playlist failed - trying to get a playlist URL");
|
||||
segmentsURL = getSegmentPlaylistUrl(getModel());
|
||||
throw new HttpException(response.code(), response.message());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -148,27 +151,27 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
|||
LOG.debug("{} src {}", model.getName(), streamSource);
|
||||
}
|
||||
String url = null;
|
||||
if(model.getStreamUrlIndex() >= 0 && model.getStreamUrlIndex() < streamSources.size()) {
|
||||
if (model.getStreamUrlIndex() >= 0 && model.getStreamUrlIndex() < streamSources.size()) {
|
||||
// TODO don't use the index, but the bandwidth. if the bandwidth does not match, take the closest one
|
||||
LOG.debug("{} selected {}", model.getName(), streamSources.get(model.getStreamUrlIndex()));
|
||||
url = streamSources.get(model.getStreamUrlIndex()).getMediaPlaylistUrl();
|
||||
} else {
|
||||
// filter out stream resolutions, which are too high
|
||||
int maxRes = Config.getInstance().getSettings().maximumResolution;
|
||||
if(maxRes > 0) {
|
||||
if (maxRes > 0) {
|
||||
for (Iterator<StreamSource> iterator = streamSources.iterator(); iterator.hasNext();) {
|
||||
StreamSource streamSource = iterator.next();
|
||||
if(streamSource.height > 0 && maxRes < streamSource.height) {
|
||||
if (streamSource.height > 0 && maxRes < streamSource.height) {
|
||||
LOG.trace("Res too high {} > {}", streamSource.height, maxRes);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(streamSources.isEmpty()) {
|
||||
if (streamSources.isEmpty()) {
|
||||
throw new ExecutionException(new RuntimeException("No stream left in playlist"));
|
||||
} else {
|
||||
LOG.debug("{} selected {}", model.getName(), streamSources.get(streamSources.size()-1));
|
||||
url = streamSources.get(streamSources.size()-1).getMediaPlaylistUrl();
|
||||
LOG.debug("{} selected {}", model.getName(), streamSources.get(streamSources.size() - 1));
|
||||
url = streamSources.get(streamSources.size() - 1).getMediaPlaylistUrl();
|
||||
}
|
||||
}
|
||||
LOG.debug("Segment playlist url {}", url);
|
||||
|
|
Loading…
Reference in New Issue