forked from j62/ctbrec
1
0
Fork 0

Improve null-safety

This commit is contained in:
0xb00bface 2023-12-30 22:40:08 +01:00
parent 71c2d74857
commit 1d88bca3d5
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import com.iheartradio.m3u8.*;
import com.iheartradio.m3u8.data.MasterPlaylist;
import com.iheartradio.m3u8.data.Playlist;
import com.iheartradio.m3u8.data.PlaylistData;
import com.iheartradio.m3u8.data.StreamInfo;
import ctbrec.*;
import ctbrec.io.HttpException;
import ctbrec.recorder.download.StreamSource;
@ -118,8 +119,8 @@ public class CherryTvModel extends AbstractModel {
if (playlist.hasStreamInfo()) {
StreamSource src = new StreamSource();
src.setBandwidth(playlist.getStreamInfo().getBandwidth());
src.setHeight(playlist.getStreamInfo().getResolution().height);
src.setWidth(playlist.getStreamInfo().getResolution().width);
src.setHeight(Optional.ofNullable(playlist.getStreamInfo()).map(StreamInfo::getResolution).map(res -> res.height).orElse(0));
src.setWidth(Optional.ofNullable(playlist.getStreamInfo()).map(StreamInfo::getResolution).map(res -> res.width).orElse(0));
String masterUrl = masterPlaylistUrl;
String baseUrl = masterUrl.substring(0, masterUrl.lastIndexOf('/') + 1);
String segmentUri = baseUrl + playlist.getUri();