mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-09 15:20:34 +02:00
chapter downloading fixes
This commit is contained in:
parent
a18f4e37ac
commit
29ed437d79
|
@ -598,7 +598,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
|
|
||||||
return string.Format(",subtitles='{0}:si={1}',setpts=PTS -{2}/TB",
|
return string.Format(",subtitles='{0}:si={1}',setpts=PTS -{2}/TB",
|
||||||
state.MediaPath.Replace('\\', '/').Replace(":/", "\\:/"),
|
state.MediaPath.Replace('\\', '/').Replace(":/", "\\:/"),
|
||||||
state.SubtitleStream.Index.ToString(UsCulture),
|
state.InternalSubtitleStreamOffset.ToString(UsCulture),
|
||||||
Math.Round(seconds).ToString(UsCulture));
|
Math.Round(seconds).ToString(UsCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1474,7 +1474,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
|
|
||||||
state.IsoType = mediaSource.IsoType;
|
state.IsoType = mediaSource.IsoType;
|
||||||
|
|
||||||
//state.PlayableStreamFileNames = mediaSource.PlayableStreamFileNames.ToList();
|
state.PlayableStreamFileNames = mediaSource.PlayableStreamFileNames.ToList();
|
||||||
|
|
||||||
if (mediaSource.Timestamp.HasValue)
|
if (mediaSource.Timestamp.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -1552,6 +1552,11 @@ namespace MediaBrowser.Api.Playback
|
||||||
state.SubtitleStream = GetMediaStream(mediaStreams, videoRequest.SubtitleStreamIndex, MediaStreamType.Subtitle, false);
|
state.SubtitleStream = GetMediaStream(mediaStreams, videoRequest.SubtitleStreamIndex, MediaStreamType.Subtitle, false);
|
||||||
state.AudioStream = GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);
|
state.AudioStream = GetMediaStream(mediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);
|
||||||
|
|
||||||
|
if (state.SubtitleStream != null && !state.SubtitleStream.IsExternal)
|
||||||
|
{
|
||||||
|
state.InternalSubtitleStreamOffset = mediaStreams.Where(i => i.Type == MediaStreamType.Subtitle && !i.IsExternal).ToList().IndexOf(state.SubtitleStream);
|
||||||
|
}
|
||||||
|
|
||||||
if (state.VideoStream != null && state.VideoStream.IsInterlaced)
|
if (state.VideoStream != null && state.VideoStream.IsInterlaced)
|
||||||
{
|
{
|
||||||
state.DeInterlace = true;
|
state.DeInterlace = true;
|
||||||
|
|
|
@ -163,6 +163,8 @@ namespace MediaBrowser.Api.Playback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int InternalSubtitleStreamOffset { get; set; }
|
||||||
|
|
||||||
public string OutputFilePath { get; set; }
|
public string OutputFilePath { get; set; }
|
||||||
public string OutputVideoCodec { get; set; }
|
public string OutputVideoCodec { get; set; }
|
||||||
public string OutputAudioCodec { get; set; }
|
public string OutputAudioCodec { get; set; }
|
||||||
|
|
|
@ -560,7 +560,8 @@ namespace MediaBrowser.Controller.Entities
|
||||||
Size = i.Size,
|
Size = i.Size,
|
||||||
Formats = (i.FormatName ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
|
Formats = (i.FormatName ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(),
|
||||||
Timestamp = i.Timestamp,
|
Timestamp = i.Timestamp,
|
||||||
Type = type
|
Type = type,
|
||||||
|
PlayableStreamFileNames = i.PlayableStreamFileNames.ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(info.Container))
|
if (string.IsNullOrEmpty(info.Container))
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace MediaBrowser.Model.Dto
|
||||||
public Video3DFormat? Video3DFormat { get; set; }
|
public Video3DFormat? Video3DFormat { get; set; }
|
||||||
|
|
||||||
public List<MediaStream> MediaStreams { get; set; }
|
public List<MediaStream> MediaStreams { get; set; }
|
||||||
|
public List<string> PlayableStreamFileNames { get; set; }
|
||||||
|
|
||||||
public List<string> Formats { get; set; }
|
public List<string> Formats { get; set; }
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ namespace MediaBrowser.Model.Dto
|
||||||
Formats = new List<string>();
|
Formats = new List<string>();
|
||||||
MediaStreams = new List<MediaStream>();
|
MediaStreams = new List<MediaStream>();
|
||||||
RequiredHttpHeaders = new Dictionary<string, string>();
|
RequiredHttpHeaders = new Dictionary<string, string>();
|
||||||
|
PlayableStreamFileNames = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? DefaultAudioStreamIndex { get; set; }
|
public int? DefaultAudioStreamIndex { get; set; }
|
||||||
|
|
|
@ -67,7 +67,8 @@ namespace MediaBrowser.Providers.Chapters
|
||||||
ParentIndexNumber = video.ParentIndexNumber,
|
ParentIndexNumber = video.ParentIndexNumber,
|
||||||
ProductionYear = video.ProductionYear,
|
ProductionYear = video.ProductionYear,
|
||||||
ProviderIds = video.ProviderIds,
|
ProviderIds = video.ProviderIds,
|
||||||
RuntimeTicks = video.RunTimeTicks
|
RuntimeTicks = video.RunTimeTicks,
|
||||||
|
SearchAllProviders = false
|
||||||
};
|
};
|
||||||
|
|
||||||
var episode = video as Episode;
|
var episode = video as Episode;
|
||||||
|
@ -95,8 +96,12 @@ namespace MediaBrowser.Providers.Chapters
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return await Search(request, provider, cancellationToken).ConfigureAwait(false);
|
var currentResults = await Search(request, provider, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (currentResults.Count > 0)
|
||||||
|
{
|
||||||
|
return currentResults;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -124,19 +129,21 @@ namespace MediaBrowser.Providers.Chapters
|
||||||
return results.SelectMany(i => i);
|
return results.SelectMany(i => i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<RemoteChapterResult>> Search(ChapterSearchRequest request,
|
private async Task<List<RemoteChapterResult>> Search(ChapterSearchRequest request,
|
||||||
IChapterProvider provider,
|
IChapterProvider provider,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var searchResults = await provider.Search(request, cancellationToken).ConfigureAwait(false);
|
var searchResults = await provider.Search(request, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
foreach (var result in searchResults)
|
var list = searchResults.ToList();
|
||||||
|
|
||||||
|
foreach (var result in list)
|
||||||
{
|
{
|
||||||
result.Id = GetProviderId(provider.Name) + "_" + result.Id;
|
result.Id = GetProviderId(provider.Name) + "_" + result.Id;
|
||||||
result.ProviderName = provider.Name;
|
result.ProviderName = provider.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return searchResults;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ChapterResponse> GetChapters(string id, CancellationToken cancellationToken)
|
public Task<ChapterResponse> GetChapters(string id, CancellationToken cancellationToken)
|
||||||
|
@ -186,7 +193,7 @@ namespace MediaBrowser.Providers.Chapters
|
||||||
if (!includeDisabledProviders)
|
if (!includeDisabledProviders)
|
||||||
{
|
{
|
||||||
providers = providers
|
providers = providers
|
||||||
.Where(i => _config.Configuration.ChapterOptions.DisabledFetchers.Contains(i.Name))
|
.Where(i => !_config.Configuration.ChapterOptions.DisabledFetchers.Contains(i.Name))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh ||
|
if (options.MetadataRefreshMode == MetadataRefreshMode.FullRefresh ||
|
||||||
options.MetadataRefreshMode == MetadataRefreshMode.EnsureMetadata)
|
options.MetadataRefreshMode == MetadataRefreshMode.EnsureMetadata)
|
||||||
{
|
{
|
||||||
var remoteChapters = await DownloadChapters(video, cancellationToken).ConfigureAwait(false);
|
var remoteChapters = await DownloadChapters(video, chapters, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (remoteChapters.Count > 0)
|
if (remoteChapters.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -487,7 +487,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
currentStreams.AddRange(externalSubtitleStreams);
|
currentStreams.AddRange(externalSubtitleStreams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<ChapterInfo>> DownloadChapters(Video video, CancellationToken cancellationToken)
|
private async Task<List<ChapterInfo>> DownloadChapters(Video video, List<ChapterInfo> currentChapters, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if ((_config.Configuration.ChapterOptions.DownloadEpisodeChapters &&
|
if ((_config.Configuration.ChapterOptions.DownloadEpisodeChapters &&
|
||||||
video is Episode) ||
|
video is Episode) ||
|
||||||
|
@ -502,12 +502,31 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
{
|
{
|
||||||
var chapters = await _chapterManager.GetChapters(result.Id, cancellationToken).ConfigureAwait(false);
|
var chapters = await _chapterManager.GetChapters(result.Id, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
return chapters.Chapters.Select(i => new ChapterInfo
|
var chapterInfos = chapters.Chapters.Select(i => new ChapterInfo
|
||||||
{
|
{
|
||||||
Name = i.Name,
|
Name = i.Name,
|
||||||
StartPositionTicks = i.StartPositionTicks
|
StartPositionTicks = i.StartPositionTicks
|
||||||
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
|
if (chapterInfos.All(i => i.StartPositionTicks == 0))
|
||||||
|
{
|
||||||
|
if (currentChapters.Count >= chapterInfos.Count)
|
||||||
|
{
|
||||||
|
var index = 0;
|
||||||
|
foreach (var info in chapterInfos)
|
||||||
|
{
|
||||||
|
info.StartPositionTicks = currentChapters[index].StartPositionTicks;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chapterInfos.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return chapterInfos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue