forked from j62/ctbrec
Improve error handling for loading the master playlist for Cam4Models
This commit is contained in:
parent
5b2ddfb825
commit
c774a29421
|
@ -157,15 +157,17 @@ public class Cam4Model extends AbstractModel {
|
||||||
private MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException {
|
private MasterPlaylist getMasterPlaylist() throws IOException, ParseException, PlaylistException {
|
||||||
LOG.trace("Loading master playlist {}", getPlaylistUrl());
|
LOG.trace("Loading master playlist {}", getPlaylistUrl());
|
||||||
Request req = new Request.Builder().url(getPlaylistUrl()).build();
|
Request req = new Request.Builder().url(getPlaylistUrl()).build();
|
||||||
Response response = site.getHttpClient().execute(req);
|
|
||||||
try {
|
try (Response response = site.getHttpClient().execute(req)) {
|
||||||
InputStream inputStream = response.body().byteStream();
|
if (response.isSuccessful()) {
|
||||||
PlaylistParser parser = new PlaylistParser(inputStream, Format.EXT_M3U, Encoding.UTF_8, ParsingMode.LENIENT);
|
InputStream inputStream = response.body().byteStream();
|
||||||
Playlist playlist = parser.parse();
|
PlaylistParser parser = new PlaylistParser(inputStream, Format.EXT_M3U, Encoding.UTF_8, ParsingMode.LENIENT);
|
||||||
MasterPlaylist master = playlist.getMasterPlaylist();
|
Playlist playlist = parser.parse();
|
||||||
return master;
|
MasterPlaylist master = playlist.getMasterPlaylist();
|
||||||
} finally {
|
return master;
|
||||||
response.close();
|
} else {
|
||||||
|
throw new HttpException(response.code(), "Couldn't download HLS playlist");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue