优化m4s命名
This commit is contained in:
parent
ec26127b50
commit
ba3c47e27d
|
@ -21,6 +21,8 @@ namespace N_m3u8DL_RE.Common.Entity
|
||||||
|
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
public string? NameFromVar { get; set; } //MPD分段文件名
|
||||||
|
|
||||||
public override bool Equals(object? obj)
|
public override bool Equals(object? obj)
|
||||||
{
|
{
|
||||||
return obj is MediaSegment segment &&
|
return obj is MediaSegment segment &&
|
||||||
|
|
|
@ -337,9 +337,12 @@ namespace N_m3u8DL_RE.Parser.Extractor
|
||||||
var _repeatCount = Convert.ToInt64(_repeatCountStr);
|
var _repeatCount = Convert.ToInt64(_repeatCountStr);
|
||||||
varDic[DASHTags.TemplateTime] = currentTime;
|
varDic[DASHTags.TemplateTime] = currentTime;
|
||||||
varDic[DASHTags.TemplateNumber] = segNumber++;
|
varDic[DASHTags.TemplateNumber] = segNumber++;
|
||||||
var mediaUrl = ParserUtil.ReplaceVars(ParserUtil.CombineURL(segBaseUrl, media!), varDic);
|
var oriUrl = ParserUtil.CombineURL(segBaseUrl, media!);
|
||||||
|
var mediaUrl = ParserUtil.ReplaceVars(oriUrl, varDic);
|
||||||
MediaSegment mediaSegment = new();
|
MediaSegment mediaSegment = new();
|
||||||
mediaSegment.Url = mediaUrl;
|
mediaSegment.Url = mediaUrl;
|
||||||
|
if (oriUrl.Contains(DASHTags.TemplateTime))
|
||||||
|
mediaSegment.NameFromVar = currentTime.ToString();
|
||||||
mediaSegment.Duration = _duration / (double)timescale;
|
mediaSegment.Duration = _duration / (double)timescale;
|
||||||
mediaSegment.Index = segIndex++;
|
mediaSegment.Index = segIndex++;
|
||||||
streamSpec.Playlist.MediaParts[0].MediaSegments.Add(mediaSegment);
|
streamSpec.Playlist.MediaParts[0].MediaSegments.Add(mediaSegment);
|
||||||
|
@ -354,10 +357,13 @@ namespace N_m3u8DL_RE.Parser.Extractor
|
||||||
MediaSegment _mediaSegment = new();
|
MediaSegment _mediaSegment = new();
|
||||||
varDic[DASHTags.TemplateTime] = currentTime;
|
varDic[DASHTags.TemplateTime] = currentTime;
|
||||||
varDic[DASHTags.TemplateNumber] = segNumber++;
|
varDic[DASHTags.TemplateNumber] = segNumber++;
|
||||||
var _mediaUrl = ParserUtil.ReplaceVars(ParserUtil.CombineURL(segBaseUrl, media!), varDic);
|
var _oriUrl = ParserUtil.CombineURL(segBaseUrl, media!);
|
||||||
|
var _mediaUrl = ParserUtil.ReplaceVars(_oriUrl, varDic);
|
||||||
_mediaSegment.Url = _mediaUrl;
|
_mediaSegment.Url = _mediaUrl;
|
||||||
_mediaSegment.Index = segIndex++;
|
_mediaSegment.Index = segIndex++;
|
||||||
_mediaSegment.Duration = _duration / (double)timescale;
|
_mediaSegment.Duration = _duration / (double)timescale;
|
||||||
|
if (_oriUrl.Contains(DASHTags.TemplateTime))
|
||||||
|
_mediaSegment.NameFromVar = currentTime.ToString();
|
||||||
streamSpec.Playlist.MediaParts[0].MediaSegments.Add(_mediaSegment);
|
streamSpec.Playlist.MediaParts[0].MediaSegments.Add(_mediaSegment);
|
||||||
}
|
}
|
||||||
currentTime += _duration;
|
currentTime += _duration;
|
||||||
|
@ -387,9 +393,12 @@ namespace N_m3u8DL_RE.Parser.Extractor
|
||||||
for (long index = startNumber, segIndex = 0; index < startNumber + totalNumber; index++, segIndex++)
|
for (long index = startNumber, segIndex = 0; index < startNumber + totalNumber; index++, segIndex++)
|
||||||
{
|
{
|
||||||
varDic[DASHTags.TemplateNumber] = index;
|
varDic[DASHTags.TemplateNumber] = index;
|
||||||
var mediaUrl = ParserUtil.ReplaceVars(ParserUtil.CombineURL(segBaseUrl, media!), varDic);
|
var oriUrl = ParserUtil.CombineURL(segBaseUrl, media!);
|
||||||
|
var mediaUrl = ParserUtil.ReplaceVars(oriUrl, varDic);
|
||||||
MediaSegment mediaSegment = new();
|
MediaSegment mediaSegment = new();
|
||||||
mediaSegment.Url = mediaUrl;
|
mediaSegment.Url = mediaUrl;
|
||||||
|
if (oriUrl.Contains(DASHTags.TemplateNumber))
|
||||||
|
mediaSegment.NameFromVar = index.ToString();
|
||||||
mediaSegment.Index = isLive ? index : segIndex; //直播直接用startNumber
|
mediaSegment.Index = isLive ? index : segIndex; //直播直接用startNumber
|
||||||
mediaSegment.Duration = duration / (double)timescale;
|
mediaSegment.Duration = duration / (double)timescale;
|
||||||
streamSpec.Playlist.MediaParts[0].MediaSegments.Add(mediaSegment);
|
streamSpec.Playlist.MediaParts[0].MediaSegments.Add(mediaSegment);
|
||||||
|
|
|
@ -98,6 +98,11 @@ namespace N_m3u8DL_RE.DownloadManager
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetSegmentName(MediaSegment segment, bool allHasDatetime, bool allSamePath)
|
private string GetSegmentName(MediaSegment segment, bool allHasDatetime, bool allSamePath)
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(segment.NameFromVar))
|
||||||
|
{
|
||||||
|
return segment.NameFromVar;
|
||||||
|
}
|
||||||
|
|
||||||
bool hls = StreamExtractor.ExtractorType == ExtractorType.HLS;
|
bool hls = StreamExtractor.ExtractorType == ExtractorType.HLS;
|
||||||
|
|
||||||
string name = OtherUtil.GetFileNameFromInput(segment.Url, false);
|
string name = OtherUtil.GetFileNameFromInput(segment.Url, false);
|
||||||
|
@ -105,6 +110,7 @@ namespace N_m3u8DL_RE.DownloadManager
|
||||||
{
|
{
|
||||||
name = OtherUtil.GetValidFileName(segment.Url.Split('?').Last(), "_");
|
name = OtherUtil.GetValidFileName(segment.Url.Split('?').Last(), "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hls && allHasDatetime)
|
if (hls && allHasDatetime)
|
||||||
{
|
{
|
||||||
name = GetUnixTimestamp(segment.DateTime!.Value).ToString();
|
name = GetUnixTimestamp(segment.DateTime!.Value).ToString();
|
||||||
|
|
Loading…
Reference in New Issue