Replace deprecated calls

This commit is contained in:
jafea7 2025-04-11 13:36:02 +10:00
parent 5bbd74efd8
commit e7cbcfdb61
1 changed files with 23 additions and 7 deletions

View File

@ -4,6 +4,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
@ -40,14 +42,28 @@ public class RecordingDownload extends MergedFfmpegHlsDownload {
throws InvalidKeyException, NoSuchAlgorithmException, IllegalStateException, InterruptedException, IOException, ParseException, PlaylistException {
running = true;
if (Config.getInstance().getSettings().requireAuthentication) {
URL u = new URL(segmentPlaylistUri);
String path = u.getPath();
byte[] key = Config.getInstance().getSettings().key;
if (!Config.getInstance().getContextPath().isEmpty()) {
path = path.substring(Config.getInstance().getContextPath().length());
try {
URI uri = new URI(segmentPlaylistUri);
URL u = uri.toURL();
String path = u.getPath();
byte[] key = Config.getInstance().getSettings().key;
if (!Config.getInstance().getContextPath().isEmpty()) {
path = path.substring(Config.getInstance().getContextPath().length());
}
String hmac = Hmac.calculate(path, key);
segmentPlaylistUri = segmentPlaylistUri + "?hmac=" + hmac;
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid URI: " + segmentPlaylistUri, e);
}
String hmac = Hmac.calculate(path, key);
segmentPlaylistUri = segmentPlaylistUri + "?hmac=" + hmac;
// URL u = new URL(segmentPlaylistUri);
// String path = u.getPath();
// byte[] key = Config.getInstance().getSettings().key;
// if (!Config.getInstance().getContextPath().isEmpty()) {
// path = path.substring(Config.getInstance().getContextPath().length());
// }
// String hmac = Hmac.calculate(path, key);
}
startFfmpegProcess(target);