Throw a HttpException if request is unsuccessful in getMasterPlaylist
This commit is contained in:
parent
5b8d65ab27
commit
ef3c5640e1
|
@ -299,15 +299,16 @@ public class Chaturbate extends AbstractSite {
|
||||||
public MasterPlaylist getMasterPlaylist(StreamInfo streamInfo) throws IOException, ParseException, PlaylistException {
|
public MasterPlaylist getMasterPlaylist(StreamInfo streamInfo) throws IOException, ParseException, PlaylistException {
|
||||||
LOG.trace("Loading master playlist {}", streamInfo.url);
|
LOG.trace("Loading master playlist {}", streamInfo.url);
|
||||||
Request req = new Request.Builder().url(streamInfo.url).build();
|
Request req = new Request.Builder().url(streamInfo.url).build();
|
||||||
Response response = getHttpClient().execute(req);
|
try (Response response = getHttpClient().execute(req)) {
|
||||||
try {
|
if(response.isSuccessful()) {
|
||||||
InputStream inputStream = response.body().byteStream();
|
InputStream inputStream = response.body().byteStream();
|
||||||
PlaylistParser parser = new PlaylistParser(inputStream, Format.EXT_M3U, Encoding.UTF_8);
|
PlaylistParser parser = new PlaylistParser(inputStream, Format.EXT_M3U, Encoding.UTF_8);
|
||||||
Playlist playlist = parser.parse();
|
Playlist playlist = parser.parse();
|
||||||
MasterPlaylist master = playlist.getMasterPlaylist();
|
MasterPlaylist master = playlist.getMasterPlaylist();
|
||||||
return master;
|
return master;
|
||||||
} finally {
|
} else {
|
||||||
response.close();
|
throw new HttpException(response.code(), response.message());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue