mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
sync updates
This commit is contained in:
parent
5f044cfd68
commit
07de09f350
@ -296,7 +296,7 @@ namespace MediaBrowser.Api
|
|||||||
// TODO: Lower this hls timeout
|
// TODO: Lower this hls timeout
|
||||||
var timerDuration = job.Type == TranscodingJobType.Progressive ?
|
var timerDuration = job.Type == TranscodingJobType.Progressive ?
|
||||||
1000 :
|
1000 :
|
||||||
14400000;
|
7200000;
|
||||||
|
|
||||||
if (job.KillTimer == null)
|
if (job.KillTimer == null)
|
||||||
{
|
{
|
||||||
|
@ -272,6 +272,11 @@ namespace MediaBrowser.Api.Playback
|
|||||||
|
|
||||||
// Set this back to what it was
|
// Set this back to what it was
|
||||||
mediaSource.SupportsDirectStream = supportsDirectStream;
|
mediaSource.SupportsDirectStream = supportsDirectStream;
|
||||||
|
|
||||||
|
if (streamInfo != null)
|
||||||
|
{
|
||||||
|
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaSource.SupportsDirectStream)
|
if (mediaSource.SupportsDirectStream)
|
||||||
@ -285,6 +290,11 @@ namespace MediaBrowser.Api.Playback
|
|||||||
{
|
{
|
||||||
mediaSource.SupportsDirectStream = false;
|
mediaSource.SupportsDirectStream = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (streamInfo != null)
|
||||||
|
{
|
||||||
|
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaSource.SupportsTranscoding)
|
if (mediaSource.SupportsTranscoding)
|
||||||
@ -297,10 +307,36 @@ namespace MediaBrowser.Api.Playback
|
|||||||
if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode)
|
if (streamInfo != null && streamInfo.PlayMethod == PlayMethod.Transcode)
|
||||||
{
|
{
|
||||||
streamInfo.StartPositionTicks = startTimeTicks;
|
streamInfo.StartPositionTicks = startTimeTicks;
|
||||||
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).Substring(1);
|
mediaSource.TranscodingUrl = streamInfo.ToUrl("-", auth.Token).TrimStart('-');
|
||||||
mediaSource.TranscodingContainer = streamInfo.Container;
|
mediaSource.TranscodingContainer = streamInfo.Container;
|
||||||
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
|
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (streamInfo != null)
|
||||||
|
{
|
||||||
|
SetDeviceSpecificSubtitleInfo(streamInfo, mediaSource, auth.Token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetDeviceSpecificSubtitleInfo(StreamInfo info, MediaSourceInfo mediaSource, string accessToken)
|
||||||
|
{
|
||||||
|
var profiles = info.GetSubtitleProfiles(false, "-", accessToken);
|
||||||
|
|
||||||
|
foreach (var profile in profiles)
|
||||||
|
{
|
||||||
|
foreach (var stream in mediaSource.MediaStreams)
|
||||||
|
{
|
||||||
|
if (stream.Type == MediaStreamType.Subtitle && stream.Index == profile.Index)
|
||||||
|
{
|
||||||
|
stream.DeliveryMethod = profile.DeliveryMethod;
|
||||||
|
|
||||||
|
if (profile.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||||
|
{
|
||||||
|
stream.DeliveryUrl = profile.Url.TrimStart('-');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,11 +167,14 @@ namespace MediaBrowser.Dlna.Didl
|
|||||||
AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
|
AddVideoResource(container, video, deviceId, filter, contentFeature, streamInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var subtitle in streamInfo.GetExternalSubtitles(_serverAddress, _accessToken, false))
|
foreach (var subtitle in streamInfo.GetSubtitleProfiles(false, _serverAddress, _accessToken))
|
||||||
|
{
|
||||||
|
if (subtitle.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||||
{
|
{
|
||||||
AddSubtitleElement(container, subtitle);
|
AddSubtitleElement(container, subtitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void AddSubtitleElement(XmlElement container, SubtitleStreamInfo info)
|
private void AddSubtitleElement(XmlElement container, SubtitleStreamInfo info)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,8 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
|
|
||||||
public bool IsDirectStream
|
public bool IsDirectStream
|
||||||
{
|
{
|
||||||
get {
|
get
|
||||||
|
{
|
||||||
return PlayMethod == PlayMethod.DirectStream ||
|
return PlayMethod == PlayMethod.DirectStream ||
|
||||||
PlayMethod == PlayMethod.DirectPlay;
|
PlayMethod == PlayMethod.DirectPlay;
|
||||||
}
|
}
|
||||||
@ -216,53 +217,25 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly)
|
public List<SubtitleStreamInfo> GetExternalSubtitles(bool includeSelectedTrackOnly, string baseUrl, string accessToken)
|
||||||
{
|
{
|
||||||
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
|
List<SubtitleStreamInfo> list = GetSubtitleProfiles(includeSelectedTrackOnly, baseUrl, accessToken);
|
||||||
|
List<SubtitleStreamInfo> newList = new List<SubtitleStreamInfo>();
|
||||||
|
|
||||||
// First add the selected track
|
// First add the selected track
|
||||||
if (SubtitleStreamIndex.HasValue)
|
foreach (SubtitleStreamInfo stream in list)
|
||||||
{
|
{
|
||||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
if (stream.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||||
{
|
{
|
||||||
if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value)
|
newList.Add(stream);
|
||||||
{
|
|
||||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
|
||||||
|
|
||||||
if (info != null)
|
|
||||||
{
|
|
||||||
list.Add(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!includeSelectedTrackOnly)
|
return newList;
|
||||||
{
|
|
||||||
foreach (MediaStream stream in MediaSource.MediaStreams)
|
|
||||||
{
|
|
||||||
if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value))
|
|
||||||
{
|
|
||||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
|
||||||
|
|
||||||
if (info != null)
|
|
||||||
{
|
|
||||||
list.Add(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
public List<SubtitleStreamInfo> GetSubtitleProfiles(bool includeSelectedTrackOnly, string baseUrl, string accessToken)
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubtitleStreamInfo> GetExternalSubtitles(string baseUrl, string accessToken, bool includeSelectedTrackOnly)
|
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(baseUrl))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(baseUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
|
List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>();
|
||||||
|
|
||||||
// HLS will preserve timestamps so we can just grab the full subtitle stream
|
// HLS will preserve timestamps so we can just grab the full subtitle stream
|
||||||
@ -279,13 +252,10 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
{
|
{
|
||||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
||||||
|
|
||||||
if (info != null)
|
|
||||||
{
|
|
||||||
list.Add(info);
|
list.Add(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!includeSelectedTrackOnly)
|
if (!includeSelectedTrackOnly)
|
||||||
{
|
{
|
||||||
@ -295,13 +265,10 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
{
|
{
|
||||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks);
|
||||||
|
|
||||||
if (info != null)
|
|
||||||
{
|
|
||||||
list.Add(info);
|
list.Add(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -310,7 +277,13 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
{
|
{
|
||||||
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
SubtitleStreamInfo info = GetSubtitleStreamInfo(stream);
|
||||||
|
|
||||||
if (info != null)
|
if (info.DeliveryMethod == SubtitleDeliveryMethod.External)
|
||||||
|
{
|
||||||
|
if (MediaSource.Protocol == MediaProtocol.Http)
|
||||||
|
{
|
||||||
|
info.Url = stream.Path;
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(baseUrl))
|
||||||
{
|
{
|
||||||
info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
|
info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}",
|
||||||
baseUrl,
|
baseUrl,
|
||||||
@ -320,6 +293,7 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
StringHelper.ToStringCultureInvariant(startPositionTicks),
|
||||||
SubtitleFormat);
|
SubtitleFormat);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
@ -328,18 +302,14 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
{
|
{
|
||||||
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile.SubtitleProfiles, Context);
|
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile.SubtitleProfiles, Context);
|
||||||
|
|
||||||
if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new SubtitleStreamInfo
|
return new SubtitleStreamInfo
|
||||||
{
|
{
|
||||||
IsForced = stream.IsForced,
|
IsForced = stream.IsForced,
|
||||||
Language = stream.Language,
|
Language = stream.Language,
|
||||||
Name = stream.Language ?? "Unknown",
|
Name = stream.Language ?? "Unknown",
|
||||||
Format = SubtitleFormat,
|
Format = SubtitleFormat,
|
||||||
Index = stream.Index
|
Index = stream.Index,
|
||||||
|
DeliveryMethod = subtitleProfile.Method
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,5 +8,6 @@ namespace MediaBrowser.Model.Dlna
|
|||||||
public bool IsForced { get; set; }
|
public bool IsForced { get; set; }
|
||||||
public string Format { get; set; }
|
public string Format { get; set; }
|
||||||
public int Index { get; set; }
|
public int Index { get; set; }
|
||||||
|
public SubtitleDeliveryMethod DeliveryMethod { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Dlna;
|
||||||
|
using MediaBrowser.Model.Extensions;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Entities
|
namespace MediaBrowser.Model.Entities
|
||||||
@ -135,6 +136,17 @@ namespace MediaBrowser.Model.Entities
|
|||||||
/// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
|
/// <value><c>true</c> if this instance is external; otherwise, <c>false</c>.</value>
|
||||||
public bool IsExternal { get; set; }
|
public bool IsExternal { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the method.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The method.</value>
|
||||||
|
public SubtitleDeliveryMethod? DeliveryMethod { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the delivery URL.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The delivery URL.</value>
|
||||||
|
public string DeliveryUrl { get; set; }
|
||||||
|
|
||||||
public bool IsTextSubtitleStream
|
public bool IsTextSubtitleStream
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -227,6 +227,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
{
|
{
|
||||||
Format = "srt",
|
Format = "srt",
|
||||||
Method = SubtitleDeliveryMethod.External
|
Method = SubtitleDeliveryMethod.External
|
||||||
|
},
|
||||||
|
new SubtitleProfile
|
||||||
|
{
|
||||||
|
Format = "vtt",
|
||||||
|
Method = SubtitleDeliveryMethod.External
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -495,7 +495,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
// No sense creating external subs if we're already burning one into the video
|
// No sense creating external subs if we're already burning one into the video
|
||||||
var externalSubs = streamInfo.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode ?
|
var externalSubs = streamInfo.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode ?
|
||||||
new List<SubtitleStreamInfo>() :
|
new List<SubtitleStreamInfo>() :
|
||||||
streamInfo.GetExternalSubtitles(false);
|
streamInfo.GetExternalSubtitles(false, null, null);
|
||||||
|
|
||||||
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
|
// Mark as requiring conversion if transcoding the video, or if any subtitles need to be extracted
|
||||||
var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && jobOptions.IsConverting;
|
var requiresVideoTranscoding = streamInfo.PlayMethod == PlayMethod.Transcode && jobOptions.IsConverting;
|
||||||
|
@ -677,7 +677,6 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
|
syncedItem.Item.MediaSources = new List<MediaSourceInfo>();
|
||||||
|
|
||||||
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
|
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
|
if (string.IsNullOrWhiteSpace(syncedItem.OriginalFileName))
|
||||||
{
|
{
|
||||||
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
|
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
|
||||||
@ -686,6 +685,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
// This will be null for items that are not audio/video
|
// This will be null for items that are not audio/video
|
||||||
if (mediaSource != null)
|
if (mediaSource != null)
|
||||||
{
|
{
|
||||||
|
syncedItem.OriginalFileName = Path.ChangeExtension(syncedItem.OriginalFileName, Path.GetExtension(mediaSource.Path));
|
||||||
syncedItem.Item.MediaSources.Add(mediaSource);
|
syncedItem.Item.MediaSources.Add(mediaSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user