必要时才调用mp4解密 (#519)
This commit is contained in:
parent
6bd906e4e6
commit
8095c6e172
|
@ -1,4 +1,6 @@
|
|||
namespace N_m3u8DL_RE.Common.Entity;
|
||||
using N_m3u8DL_RE.Common.Enum;
|
||||
|
||||
namespace N_m3u8DL_RE.Common.Entity;
|
||||
|
||||
public class MediaSegment
|
||||
{
|
||||
|
@ -11,7 +13,9 @@ public class MediaSegment
|
|||
public long? StopRange => (StartRange != null && ExpectLength != null) ? StartRange + ExpectLength - 1 : null;
|
||||
public long? ExpectLength { get; set; }
|
||||
|
||||
public EncryptInfo EncryptInfo { get; set; } = new EncryptInfo();
|
||||
public EncryptInfo EncryptInfo { get; set; } = new();
|
||||
|
||||
public bool IsEncrypted => EncryptInfo.Method != EncryptMethod.NONE;
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ internal class SimpleDownloadManager
|
|||
// 从文件读取KEY
|
||||
await SearchKeyAsync(currentKID);
|
||||
// 实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID) && StreamExtractor.ExtractorType != ExtractorType.MSS)
|
||||
if (streamSpec.Playlist.MediaInit.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID) && StreamExtractor.ExtractorType != ExtractorType.MSS)
|
||||
{
|
||||
var enc = result.ActualFilePath;
|
||||
var dec = Path.Combine(Path.GetDirectoryName(enc)!, Path.GetFileNameWithoutExtension(enc) + "_dec" + Path.GetExtension(enc));
|
||||
|
@ -225,7 +225,7 @@ internal class SimpleDownloadManager
|
|||
var processor = new MSSMoovProcessor(streamSpec);
|
||||
var header = processor.GenHeader(File.ReadAllBytes(result.ActualFilePath));
|
||||
await File.WriteAllBytesAsync(FileDic[streamSpec.Playlist!.MediaInit!]!.ActualFilePath, header);
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
if (seg.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
{
|
||||
// 需要重新解密init
|
||||
var enc = FileDic[streamSpec.Playlist!.MediaInit!]!.ActualFilePath;
|
||||
|
@ -249,7 +249,7 @@ internal class SimpleDownloadManager
|
|||
// 从文件读取KEY
|
||||
await SearchKeyAsync(currentKID);
|
||||
// 实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
if (seg.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
{
|
||||
var enc = result.ActualFilePath;
|
||||
var dec = Path.Combine(Path.GetDirectoryName(enc)!, Path.GetFileNameWithoutExtension(enc) + "_dec" + Path.GetExtension(enc));
|
||||
|
@ -287,7 +287,7 @@ internal class SimpleDownloadManager
|
|||
if (result != null && result.Success)
|
||||
task.Increment(1);
|
||||
// 实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID))
|
||||
if (seg.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID))
|
||||
{
|
||||
var enc = result.ActualFilePath;
|
||||
var dec = Path.Combine(Path.GetDirectoryName(enc)!, Path.GetFileNameWithoutExtension(enc) + "_dec" + Path.GetExtension(enc));
|
||||
|
|
|
@ -211,7 +211,7 @@ internal class SimpleLiveRecordManager2
|
|||
// 从文件读取KEY
|
||||
await SearchKeyAsync(currentKID);
|
||||
// 实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID) && StreamExtractor.ExtractorType != ExtractorType.MSS)
|
||||
if (streamSpec.Playlist.MediaInit.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID) && StreamExtractor.ExtractorType != ExtractorType.MSS)
|
||||
{
|
||||
var enc = result.ActualFilePath;
|
||||
var dec = Path.Combine(Path.GetDirectoryName(enc)!, Path.GetFileNameWithoutExtension(enc) + "_dec" + Path.GetExtension(enc));
|
||||
|
@ -270,7 +270,7 @@ internal class SimpleLiveRecordManager2
|
|||
var processor = new MSSMoovProcessor(streamSpec);
|
||||
var header = processor.GenHeader(File.ReadAllBytes(result.ActualFilePath));
|
||||
await File.WriteAllBytesAsync(FileDic[streamSpec.Playlist!.MediaInit!]!.ActualFilePath, header);
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
if (seg.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
{
|
||||
// 需要重新解密init
|
||||
var enc = FileDic[streamSpec.Playlist!.MediaInit!]!.ActualFilePath;
|
||||
|
@ -290,7 +290,7 @@ internal class SimpleLiveRecordManager2
|
|||
// 从文件读取KEY
|
||||
await SearchKeyAsync(currentKID);
|
||||
// 实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
if (seg.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && !string.IsNullOrEmpty(currentKID))
|
||||
{
|
||||
var enc = result.ActualFilePath;
|
||||
var dec = Path.Combine(Path.GetDirectoryName(enc)!, Path.GetFileNameWithoutExtension(enc) + "_dec" + Path.GetExtension(enc));
|
||||
|
@ -333,7 +333,7 @@ internal class SimpleLiveRecordManager2
|
|||
if (result != null && result.Success)
|
||||
task.Increment(1);
|
||||
// 实时解密
|
||||
if (DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID))
|
||||
if (seg.IsEncrypted && DownloaderConfig.MyOptions.MP4RealTimeDecryption && result != null && result.Success && !string.IsNullOrEmpty(currentKID))
|
||||
{
|
||||
var enc = result.ActualFilePath;
|
||||
var dec = Path.Combine(Path.GetDirectoryName(enc)!, Path.GetFileNameWithoutExtension(enc) + "_dec" + Path.GetExtension(enc));
|
||||
|
|
Loading…
Reference in New Issue