forked from j62/ctbrec
Use playlist type EVENT while the recording is ongoing and VOD, when the recording is finished
This commit is contained in:
parent
a030ba7e83
commit
2afd0820e5
|
@ -1,10 +1,17 @@
|
||||||
package ctbrec.recorder.download.hls;
|
package ctbrec.recorder.download.hls;
|
||||||
|
|
||||||
import java.io.File;
|
import com.iheartradio.m3u8.*;
|
||||||
import java.io.FileNotFoundException;
|
import com.iheartradio.m3u8.data.*;
|
||||||
import java.io.FileOutputStream;
|
import ctbrec.Config;
|
||||||
import java.io.IOException;
|
import ctbrec.Model;
|
||||||
import java.io.OutputStream;
|
import ctbrec.Recording;
|
||||||
|
import ctbrec.io.HttpClient;
|
||||||
|
import ctbrec.io.IoUtils;
|
||||||
|
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
|
@ -21,23 +28,6 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.iheartradio.m3u8.*;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.iheartradio.m3u8.data.MediaPlaylist;
|
|
||||||
import com.iheartradio.m3u8.data.Playlist;
|
|
||||||
import com.iheartradio.m3u8.data.PlaylistType;
|
|
||||||
import com.iheartradio.m3u8.data.TrackData;
|
|
||||||
import com.iheartradio.m3u8.data.TrackInfo;
|
|
||||||
|
|
||||||
import ctbrec.Config;
|
|
||||||
import ctbrec.Model;
|
|
||||||
import ctbrec.Recording;
|
|
||||||
import ctbrec.io.HttpClient;
|
|
||||||
import ctbrec.io.IoUtils;
|
|
||||||
import ctbrec.recorder.download.hls.SegmentPlaylist.Segment;
|
|
||||||
|
|
||||||
public class HlsDownload extends AbstractHlsDownload {
|
public class HlsDownload extends AbstractHlsDownload {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(HlsDownload.class);
|
private static final Logger LOG = LoggerFactory.getLogger(HlsDownload.class);
|
||||||
|
@ -67,7 +57,7 @@ public class HlsDownload extends AbstractHlsDownload {
|
||||||
@Override
|
@Override
|
||||||
public AbstractHlsDownload call() throws Exception {
|
public AbstractHlsDownload call() throws Exception {
|
||||||
super.call();
|
super.call();
|
||||||
updatePlaylist();
|
updatePlaylist(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +68,7 @@ public class HlsDownload extends AbstractHlsDownload {
|
||||||
return segmentPlaylist;
|
return segmentPlaylist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updatePlaylist() {
|
private void updatePlaylist(boolean ongoing) {
|
||||||
downloadExecutor.submit(() -> {
|
downloadExecutor.submit(() -> {
|
||||||
addNewSegmentsToPlaylist();
|
addNewSegmentsToPlaylist();
|
||||||
if (segments.isEmpty() || targetDuration <= 0) {
|
if (segments.isEmpty() || targetDuration <= 0) {
|
||||||
|
@ -86,7 +76,8 @@ public class HlsDownload extends AbstractHlsDownload {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
MediaPlaylist playlist = new MediaPlaylist.Builder()
|
MediaPlaylist playlist = new MediaPlaylist.Builder()
|
||||||
.withPlaylistType(PlaylistType.VOD)
|
.withPlaylistType(ongoing ? PlaylistType.EVENT : PlaylistType.VOD)
|
||||||
|
.withIsOngoing(ongoing)
|
||||||
.withMediaSequenceNumber(0)
|
.withMediaSequenceNumber(0)
|
||||||
.withTargetDuration(Math.round(targetDuration))
|
.withTargetDuration(Math.round(targetDuration))
|
||||||
.withTracks(segments)
|
.withTracks(segments)
|
||||||
|
@ -159,6 +150,7 @@ public class HlsDownload extends AbstractHlsDownload {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finalizeDownload() {
|
public void finalizeDownload() {
|
||||||
|
updatePlaylist(false);
|
||||||
LOG.debug("Download for {} terminated", model);
|
LOG.debug("Download for {} terminated", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue