From 8051ea9b1bebcccfa1471c1a3db0e03fd7a70bcd Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 15 Feb 2015 19:33:06 -0500 Subject: update javascript connection manager to latest feature set --- MediaBrowser.Model/ApiClient/NetworkStatus.cs | 30 ++++++++ MediaBrowser.Model/Dlna/StreamInfo.cs | 99 +++++++++++++++++++++------ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + MediaBrowser.Model/Querying/EpisodeQuery.cs | 51 ++++++++++++-- 4 files changed, 154 insertions(+), 27 deletions(-) create mode 100644 MediaBrowser.Model/ApiClient/NetworkStatus.cs (limited to 'MediaBrowser.Model') diff --git a/MediaBrowser.Model/ApiClient/NetworkStatus.cs b/MediaBrowser.Model/ApiClient/NetworkStatus.cs new file mode 100644 index 000000000..715087607 --- /dev/null +++ b/MediaBrowser.Model/ApiClient/NetworkStatus.cs @@ -0,0 +1,30 @@ + +namespace MediaBrowser.Model.ApiClient +{ + public class NetworkStatus + { + /// + /// Gets or sets a value indicating whether this instance is network available. + /// + /// true if this instance is network available; otherwise, false. + public bool IsNetworkAvailable { get; set; } + /// + /// Gets or sets a value indicating whether this instance is local network available. + /// + /// null if [is local network available] contains no value, true if [is local network available]; otherwise, false. + public bool? IsLocalNetworkAvailable { get; set; } + /// + /// Gets the is any local network available. + /// + /// true if XXXX, false otherwise. + public bool GetIsAnyLocalNetworkAvailable() + { + if (!IsLocalNetworkAvailable.HasValue) + { + return IsNetworkAvailable; + } + + return IsLocalNetworkAvailable.Value; + } + } +} diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index 3c2f39b74..57a3899d4 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -85,12 +85,12 @@ namespace MediaBrowser.Model.Dlna } } - public string ToUrl(string baseUrl) + public string ToUrl(string baseUrl, string accessToken) { - return ToDlnaUrl(baseUrl); + return ToDlnaUrl(baseUrl, accessToken); } - public string ToDlnaUrl(string baseUrl) + public string ToDlnaUrl(string baseUrl, string accessToken) { if (PlayMethod == PlayMethod.DirectPlay) { @@ -152,7 +152,47 @@ namespace MediaBrowser.Model.Dlna return string.Format("Params={0}", string.Join(";", list.ToArray())); } - public List GetExternalSubtitles(string baseUrl, bool includeSelectedTrackOnly) + public List GetExternalSubtitles(bool includeSelectedTrackOnly) + { + List list = new List(); + + // First add the selected track + if (SubtitleStreamIndex.HasValue) + { + foreach (MediaStream stream in MediaSource.MediaStreams) + { + if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value) + { + SubtitleStreamInfo info = GetSubtitleStreamInfo(stream); + + if (info != null) + { + list.Add(info); + } + } + } + } + + if (!includeSelectedTrackOnly) + { + 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 GetExternalSubtitles(string baseUrl, string accessToken, bool includeSelectedTrackOnly) { if (string.IsNullOrEmpty(baseUrl)) { @@ -173,7 +213,12 @@ namespace MediaBrowser.Model.Dlna { if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value) { - AddSubtitle(list, stream, baseUrl, startPositionTicks); + SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks); + + if (info != null) + { + list.Add(info); + } } } } @@ -184,7 +229,12 @@ namespace MediaBrowser.Model.Dlna { if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value)) { - AddSubtitle(list, stream, baseUrl, startPositionTicks); + SubtitleStreamInfo info = GetSubtitleStreamInfo(stream, baseUrl, accessToken, startPositionTicks); + + if (info != null) + { + list.Add(info); + } } } } @@ -192,32 +242,41 @@ namespace MediaBrowser.Model.Dlna return list; } - private void AddSubtitle(List list, MediaStream stream, string baseUrl, long startPositionTicks) + private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks) { - var subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile); + SubtitleStreamInfo info = GetSubtitleStreamInfo(stream); - if (subtitleProfile.Method != SubtitleDeliveryMethod.External) + if (info != null) { - return; + info.Url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}", + baseUrl, + ItemId, + MediaSourceId, + StringHelper.ToStringCultureInvariant(stream.Index), + StringHelper.ToStringCultureInvariant(startPositionTicks), + SubtitleFormat); } - string url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}", - baseUrl, - ItemId, - MediaSourceId, - StringHelper.ToStringCultureInvariant(stream.Index), - StringHelper.ToStringCultureInvariant(startPositionTicks), - SubtitleFormat); + return info; + } + + private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream) + { + SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile); + + if (subtitleProfile.Method != SubtitleDeliveryMethod.External) + { + return null; + } - list.Add(new SubtitleStreamInfo + return new SubtitleStreamInfo { - Url = url, IsForced = stream.IsForced, Language = stream.Language, Name = stream.Language ?? "Unknown", Format = SubtitleFormat, Index = stream.Index - }); + }; } /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index c8e09dd82..9fd632cbd 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -72,6 +72,7 @@ + diff --git a/MediaBrowser.Model/Querying/EpisodeQuery.cs b/MediaBrowser.Model/Querying/EpisodeQuery.cs index e2fc3220a..78fe943e3 100644 --- a/MediaBrowser.Model/Querying/EpisodeQuery.cs +++ b/MediaBrowser.Model/Querying/EpisodeQuery.cs @@ -3,20 +3,57 @@ namespace MediaBrowser.Model.Querying { public class EpisodeQuery { + /// + /// Gets or sets the user identifier. + /// + /// The user identifier. public string UserId { get; set; } - + /// + /// Gets or sets the season identifier. + /// + /// The season identifier. public string SeasonId { get; set; } - + /// + /// Gets or sets the series identifier. + /// + /// The series identifier. public string SeriesId { get; set; } - + /// + /// Gets or sets a value indicating whether this instance is missing. + /// + /// null if [is missing] contains no value, true if [is missing]; otherwise, false. public bool? IsMissing { get; set; } - + /// + /// Gets or sets a value indicating whether this instance is virtual unaired. + /// + /// null if [is virtual unaired] contains no value, true if [is virtual unaired]; otherwise, false. public bool? IsVirtualUnaired { get; set; } - + /// + /// Gets or sets the season number. + /// + /// The season number. public int? SeasonNumber { get; set; } - + /// + /// Gets or sets the fields. + /// + /// The fields. public ItemFields[] Fields { get; set; } - + /// + /// Gets or sets the start index. + /// + /// The start index. + public int? StartIndex { get; set; } + /// + /// Gets or sets the limit. + /// + /// The limit. + public int? Limit { get; set; } + /// + /// Gets or sets the start item identifier. + /// + /// The start item identifier. + public string StartItemId { get; set; } + public EpisodeQuery() { Fields = new ItemFields[] { }; -- cgit v1.2.3