From 2b68dcd3c6903ce562beef4f0bb4dc02b4444ad8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Nov 2013 11:44:53 -0500 Subject: fix disc image saving for xbmc --- MediaBrowser.Server.Implementations/Providers/ImageSaver.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs index ff11b9a2be..4184003114 100644 --- a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs +++ b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs @@ -344,6 +344,9 @@ namespace MediaBrowser.Server.Implementations.Providers case ImageType.Art: filename = "clearart"; break; + case ImageType.Disc: + filename = item is MusicAlbum ? "cdart" : "disc"; + break; case ImageType.Primary: filename = item is Episode ? Path.GetFileNameWithoutExtension(item.Path) : "folder"; break; @@ -478,6 +481,11 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Primary) { + if (item is MusicAlbum || item is Artist || item is MusicArtist) + { + return new[] { Path.Combine(item.Path, "folder" + extension) }; + } + if (item is Season && item.IndexNumber.HasValue) { var seriesFolder = Path.GetDirectoryName(item.Path); -- cgit v1.2.3 From de339b8265f0e0da7771b02cb9d00c40dad0163f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Nov 2013 12:17:14 -0500 Subject: fixes #632 - Show yesterday's episodes in upcoming view --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 23 +++++++++++++++++++++- MediaBrowser.Model/Querying/ItemQuery.cs | 4 ++++ .../Providers/ImageSaver.cs | 13 ++++++------ 3 files changed, 32 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index c68e83047f..4239869a52 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Dto; +using System.Globalization; +using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.Movies; @@ -205,6 +206,12 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "AiredDuringSeason", Description = "Gets all episodes that aired during a season, including specials.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? AiredDuringSeason { get; set; } + + [ApiMember(Name = "MinPremiereDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string MinPremiereDate { get; set; } + + [ApiMember(Name = "MaxPremiereDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] + public string MaxPremiereDate { get; set; } } /// @@ -1022,6 +1029,20 @@ namespace MediaBrowser.Api.UserLibrary }); } + if (!string.IsNullOrEmpty(request.MinPremiereDate)) + { + var date = DateTime.ParseExact(request.MinPremiereDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); + + items = items.Where(i => i.PremiereDate.HasValue && i.PremiereDate.Value >= date); + } + + if (!string.IsNullOrEmpty(request.MaxPremiereDate)) + { + var date = DateTime.ParseExact(request.MaxPremiereDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); + + items = items.Where(i => i.PremiereDate.HasValue && i.PremiereDate.Value <= date); + } + return items; } diff --git a/MediaBrowser.Model/Querying/ItemQuery.cs b/MediaBrowser.Model/Querying/ItemQuery.cs index 14c946ba18..6602e031f5 100644 --- a/MediaBrowser.Model/Querying/ItemQuery.cs +++ b/MediaBrowser.Model/Querying/ItemQuery.cs @@ -266,6 +266,10 @@ namespace MediaBrowser.Model.Querying public double? MinCriticRating { get; set; } public int? AiredDuringSeason { get; set; } + + public DateTime? MinPremiereDate { get; set; } + + public DateTime? MaxPremiereDate { get; set; } /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs index 4184003114..d9ee9e219a 100644 --- a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs +++ b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs @@ -481,11 +481,6 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Primary) { - if (item is MusicAlbum || item is Artist || item is MusicArtist) - { - return new[] { Path.Combine(item.Path, "folder" + extension) }; - } - if (item is Season && item.IndexNumber.HasValue) { var seriesFolder = Path.GetDirectoryName(item.Path); @@ -513,8 +508,12 @@ namespace MediaBrowser.Server.Implementations.Providers return new[] { GetSavePathForItemInMixedFolder(item, type, string.Empty, extension) }; } - var filename = "poster" + extension; - return new[] { Path.Combine(item.MetaLocation, filename) }; + if (item is MusicAlbum || item is Artist || item is MusicArtist) + { + return new[] { Path.Combine(item.MetaLocation, "folder" + extension) }; + } + + return new[] { Path.Combine(item.MetaLocation, "poster" + extension) }; } if (type == ImageType.Banner) -- cgit v1.2.3 From bce86c502206b016cc448afc1934101b852a1994 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Nov 2013 22:15:48 -0500 Subject: pull person sort order from tvdb/tmdb data --- MediaBrowser.Api/ItemUpdateService.cs | 7 ++++++- MediaBrowser.Api/LibraryService.cs | 23 ++++++++++++++-------- MediaBrowser.Api/UserLibrary/PersonsService.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 21 +++++++++++++++----- .../Entities/IHasAspectRatio.cs | 14 +++++++++++++ MediaBrowser.Controller/Entities/Person.cs | 6 ++++++ MediaBrowser.Controller/Entities/Video.cs | 8 +++++++- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 11 ++++++++++- .../MediaBrowser.Controller.csproj | 1 + .../Providers/BaseItemXmlParser.cs | 5 +++-- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 2 +- MediaBrowser.Providers/Savers/XmlSaverHelpers.cs | 8 ++++++-- MediaBrowser.Providers/TV/TvdbSeriesProvider.cs | 17 ++++++++++++++++ .../Dto/DtoService.cs | 8 ++++++-- 14 files changed, 109 insertions(+), 24 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/IHasAspectRatio.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 6e1dbc08b9..cfbaf70c90 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -247,11 +247,16 @@ namespace MediaBrowser.Api item.PremiereDate = request.PremiereDate.HasValue ? request.PremiereDate.Value.ToUniversalTime() : (DateTime?)null; item.ProductionYear = request.ProductionYear; item.ProductionLocations = request.ProductionLocations; - item.AspectRatio = request.AspectRatio; item.Language = request.Language; item.OfficialRating = request.OfficialRating; item.CustomRating = request.CustomRating; + var hasAspectRatio = item as IHasAspectRatio; + if (hasAspectRatio != null) + { + hasAspectRatio.AspectRatio = request.AspectRatio; + } + item.DontFetchMeta = !(request.EnableInternetProviders ?? true); if (request.EnableInternetProviders ?? true) { diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index 582eb6f497..06b90b32cb 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -681,6 +681,11 @@ namespace MediaBrowser.Api { var album = originalItem as MusicAlbum; + if (album == null) + { + album = originalItem.Parents.OfType().FirstOrDefault(); + } + if (album != null) { var linkedItemWithThemes = album.SoundtrackIds @@ -744,17 +749,12 @@ namespace MediaBrowser.Api : (Folder)_libraryManager.RootFolder) : _dtoService.GetItemByDtoId(id, userId); - while (GetSoundtrackSongIds(item).Count == 0 && inheritFromParent && item.Parent != null) - { - item = item.Parent; - } - // Get everything var fields = Enum.GetNames(typeof(ItemFields)) .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) .ToList(); - var dtos = GetSoundtrackSongIds(item) + var dtos = GetSoundtrackSongIds(item, inheritFromParent) .Select(_libraryManager.GetItemById) .OfType() .SelectMany(i => i.RecursiveChildren) @@ -772,7 +772,7 @@ namespace MediaBrowser.Api }; } - private List GetSoundtrackSongIds(BaseItem item) + private IEnumerable GetSoundtrackSongIds(BaseItem item, bool inherit) { var hasSoundtracks = item as IHasSoundtracks; @@ -781,7 +781,14 @@ namespace MediaBrowser.Api return hasSoundtracks.SoundtrackIds; } - return new List(); + if (!inherit) + { + return null; + } + + hasSoundtracks = item.Parents.OfType().FirstOrDefault(); + + return hasSoundtracks != null ? hasSoundtracks.SoundtrackIds : new List(); } } } diff --git a/MediaBrowser.Api/UserLibrary/PersonsService.cs b/MediaBrowser.Api/UserLibrary/PersonsService.cs index 885a4a3e67..09b5ef09fe 100644 --- a/MediaBrowser.Api/UserLibrary/PersonsService.cs +++ b/MediaBrowser.Api/UserLibrary/PersonsService.cs @@ -155,7 +155,7 @@ namespace MediaBrowser.Api.UserLibrary /// IEnumerable{PersonInfo}. private IEnumerable GetAllPeople(IEnumerable itemsList, string[] personTypes) { - var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.Type)); + var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.SortOrder ?? int.MaxValue).ThenBy(p => p.Type)); return personTypes.Length == 0 ? diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index a6178536c6..6b6719f013 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -483,6 +483,22 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public Folder Parent { get; set; } + [IgnoreDataMember] + public IEnumerable Parents + { + get + { + var parent = Parent; + + while (parent != null) + { + yield return parent; + + parent = parent.Parent; + } + } + } + /// /// When the item first debuted. For movies this could be premiere date, episodes would be first aired /// @@ -630,11 +646,6 @@ namespace MediaBrowser.Controller.Entities /// The original run time ticks. public long? OriginalRunTimeTicks { get; set; } /// - /// Gets or sets the aspect ratio. - /// - /// The aspect ratio. - public string AspectRatio { get; set; } - /// /// Gets or sets the production year. /// /// The production year. diff --git a/MediaBrowser.Controller/Entities/IHasAspectRatio.cs b/MediaBrowser.Controller/Entities/IHasAspectRatio.cs new file mode 100644 index 0000000000..5aecf4eac1 --- /dev/null +++ b/MediaBrowser.Controller/Entities/IHasAspectRatio.cs @@ -0,0 +1,14 @@ +namespace MediaBrowser.Controller.Entities +{ + /// + /// Interface IHasAspectRatio + /// + public interface IHasAspectRatio + { + /// + /// Gets or sets the aspect ratio. + /// + /// The aspect ratio. + string AspectRatio { get; set; } + } +} diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index e5cf48ad08..17b9d77413 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -49,6 +49,12 @@ namespace MediaBrowser.Controller.Entities /// The type. public string Type { get; set; } + /// + /// Gets or sets the sort order - ascending + /// + /// The sort order. + public int? SortOrder { get; set; } + /// /// Returns a that represents this instance. /// diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index e900dd77e9..6a27ed6906 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class Video /// - public class Video : BaseItem, IHasMediaStreams + public class Video : BaseItem, IHasMediaStreams, IHasAspectRatio { public bool IsMultiPart { get; set; } @@ -65,6 +65,12 @@ namespace MediaBrowser.Controller.Entities return GetPlayableStreamFiles(Path); } + /// + /// Gets or sets the aspect ratio. + /// + /// The aspect ratio. + public string AspectRatio { get; set; } + /// /// Should be overridden to return the proper folder where metadata lives /// diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 5c019ae8c4..d39d98fa3c 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.LiveTv; +using System.IO; +using MediaBrowser.Model.LiveTv; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -23,6 +24,14 @@ namespace MediaBrowser.Controller.LiveTv /// Task{IEnumerable{ChannelInfo}}. Task> GetChannelsAsync(CancellationToken cancellationToken); + /// + /// Gets the channel image asynchronous. + /// + /// The channel identifier. + /// The cancellation token. + /// Task{Stream}. + Task GetChannelImageAsync(string channelId, CancellationToken cancellationToken); + /// /// Gets the recordings asynchronous. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index f2837a1f1d..8837d04f5e 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -89,6 +89,7 @@ + diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 9fdbbf3b7e..d3fa7b09b1 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -375,9 +375,10 @@ namespace MediaBrowser.Controller.Providers { var val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) + var hasAspectRatio = item as IHasAspectRatio; + if (!string.IsNullOrWhiteSpace(val) && hasAspectRatio != null) { - item.AspectRatio = val; + hasAspectRatio.AspectRatio = val; } break; } diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index cc6e07d622..f493353399 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -845,7 +845,7 @@ namespace MediaBrowser.Providers.Movies //actors come from cast if (movieData.casts != null && movieData.casts.cast != null) { - foreach (var actor in movieData.casts.cast.OrderBy(a => a.order)) movie.AddPerson(new PersonInfo { Name = actor.name.Trim(), Role = actor.character, Type = PersonType.Actor }); + foreach (var actor in movieData.casts.cast.OrderBy(a => a.order)) movie.AddPerson(new PersonInfo { Name = actor.name.Trim(), Role = actor.character, Type = PersonType.Actor, SortOrder = actor.order }); } //and the rest from crew diff --git a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs index 69276e0b8e..7c8d0431b2 100644 --- a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs @@ -301,9 +301,13 @@ namespace MediaBrowser.Providers.Savers builder.Append("" + SecurityElement.Escape(item.HomePageUrl) + ""); } - if (!string.IsNullOrEmpty(item.AspectRatio)) + var hasAspectRatio = item as IHasAspectRatio; + if (hasAspectRatio != null) { - builder.Append("" + SecurityElement.Escape(item.AspectRatio) + ""); + if (!string.IsNullOrEmpty(hasAspectRatio.AspectRatio)) + { + builder.Append("" + SecurityElement.Escape(hasAspectRatio.AspectRatio) + ""); + } } if (!string.IsNullOrEmpty(item.Language)) diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index a22f4f1c32..29e191a594 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -1056,6 +1056,23 @@ namespace MediaBrowser.Providers.TV break; } + case "SortOrder": + { + var val = reader.ReadElementContentAsString(); + + if (!string.IsNullOrWhiteSpace(val)) + { + int rval; + + // int.TryParse is local aware, so it can be probamatic, force us culture + if (int.TryParse(val, NumberStyles.Integer, UsCulture, out rval)) + { + personInfo.SortOrder = rval; + } + } + break; + } + default: reader.Skip(); break; diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 1f0e7d1e1e..4efafcd772 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -433,7 +433,7 @@ namespace MediaBrowser.Server.Implementations.Dto // Ordering by person type to ensure actors and artists are at the front. // This is taking advantage of the fact that they both begin with A // This should be improved in the future - var people = item.People.OrderBy(i => i.Type).ToList(); + var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue).ThenBy(i => i.Type).ToList(); // Attach People by transforming them into BaseItemPerson (DTO) dto.People = new BaseItemPerson[people.Count]; @@ -760,7 +760,11 @@ namespace MediaBrowser.Server.Implementations.Dto dto.ProductionLocations = item.ProductionLocations; } - dto.AspectRatio = item.AspectRatio; + var hasAspectRatio = item as IHasAspectRatio; + if (hasAspectRatio != null) + { + dto.AspectRatio = hasAspectRatio.AspectRatio; + } dto.BackdropImageTags = GetBackdropImageTags(item); -- cgit v1.2.3 From 977d9c7f3b92154642046f06c8ac2c4dfb31d35e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 20 Nov 2013 12:10:02 -0500 Subject: improve episode sorting with embedded specials --- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 21 +++- MediaBrowser.Model/Querying/ItemSortBy.cs | 1 + .../TV/EpisodeIndexNumberProvider.cs | 26 ++++ .../MediaBrowser.Server.Implementations.csproj | 1 + .../Sorting/AiredEpisodeOrderComparer.cs | 134 +++++++++++++++++++++ 5 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index d39d98fa3c..3d68a4ec71 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using MediaBrowser.Model.LiveTv; using System.Collections.Generic; using System.Threading; @@ -24,6 +25,24 @@ namespace MediaBrowser.Controller.LiveTv /// Task{IEnumerable{ChannelInfo}}. Task> GetChannelsAsync(CancellationToken cancellationToken); + /// + /// Cancels the recording asynchronous. + /// + /// The recording identifier. + /// The cancellation token. + /// Task. + Task CancelRecordingAsync(string recordingId, CancellationToken cancellationToken); + + /// + /// Schedules the recording asynchronous. + /// + /// The channel identifier. + /// The start time. + /// The duration. + /// The cancellation token. + /// Task. + Task ScheduleRecordingAsync(string channelId, DateTime startTime, TimeSpan duration, CancellationToken cancellationToken); + /// /// Gets the channel image asynchronous. /// diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs index 12dfa96261..57e09d724c 100644 --- a/MediaBrowser.Model/Querying/ItemSortBy.cs +++ b/MediaBrowser.Model/Querying/ItemSortBy.cs @@ -6,6 +6,7 @@ namespace MediaBrowser.Model.Querying /// public static class ItemSortBy { + public const string AiredEpisodeOrder = "AiredEpisodeOrder"; /// /// The album /// diff --git a/MediaBrowser.Providers/TV/EpisodeIndexNumberProvider.cs b/MediaBrowser.Providers/TV/EpisodeIndexNumberProvider.cs index fc8f55ae14..592c5dcac3 100644 --- a/MediaBrowser.Providers/TV/EpisodeIndexNumberProvider.cs +++ b/MediaBrowser.Providers/TV/EpisodeIndexNumberProvider.cs @@ -27,6 +27,22 @@ namespace MediaBrowser.Providers.TV { } + protected override bool RefreshOnVersionChange + { + get + { + return true; + } + } + + protected override string ProviderVersion + { + get + { + return "2"; + } + } + /// /// Supportses the specified item. /// @@ -51,6 +67,16 @@ namespace MediaBrowser.Providers.TV episode.IndexNumber = TVUtils.GetEpisodeNumberFromFile(item.Path, item.Parent is Season); episode.IndexNumberEnd = TVUtils.GetEndingEpisodeNumberFromFile(item.Path); + if (!episode.ParentIndexNumber.HasValue) + { + var season = episode.Parent as Season; + + if (season != null) + { + episode.ParentIndexNumber = season.IndexNumber; + } + } + SetLastRefreshed(item, DateTime.UtcNow); return TrueTaskResult; diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index ac451e1ebd..282991cc1f 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -188,6 +188,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs new file mode 100644 index 0000000000..cec9743bae --- /dev/null +++ b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -0,0 +1,134 @@ +using System; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities.TV; +using MediaBrowser.Controller.Sorting; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Server.Implementations.Sorting +{ + class AiredEpisodeOrderComparer : IBaseItemComparer + { + /// + /// Compares the specified x. + /// + /// The x. + /// The y. + /// System.Int32. + public int Compare(BaseItem x, BaseItem y) + { + var val = DateTime.Compare(x.PremiereDate ?? DateTime.MinValue, y.PremiereDate ?? DateTime.MinValue); + + if (val != 0) + { + return val; + } + + var episode1 = x as Episode; + var episode2 = y as Episode; + + if (episode1 == null) + { + if (episode2 == null) + { + return 0; + } + + return 1; + } + + if (episode2 == null) + { + return -1; + } + + return Compare(episode1, episode2); + } + + private int Compare(Episode x, Episode y) + { + var isXSpecial = (x.ParentIndexNumber ?? -1) == 0; + var isYSpecial = (y.ParentIndexNumber ?? -1) == 0; + + if (isXSpecial && isYSpecial) + { + return CompareSpecials(x, y); + } + + if (!isXSpecial && !isYSpecial) + { + return CompareEpisodes(x, y); + } + + if (!isXSpecial && isYSpecial) + { + return CompareEpisodeToSpecial(x, y); + } + + return CompareEpisodeToSpecial(x, y) * -1; + } + + private int CompareEpisodeToSpecial(Episode x, Episode y) + { + var xSeason = x.ParentIndexNumber ?? -1; + var ySeason = y.AirsAfterSeasonNumber ?? y.AirsBeforeSeasonNumber ?? -1; + + if (xSeason != ySeason) + { + return xSeason.CompareTo(ySeason); + } + + // Now we know they have the same season + + // Compare episode number + + // Add 1 to to non-specials to account for AirsBeforeEpisodeNumber + var xEpisode = (x.IndexNumber ?? 0) * 1000 + 1; + var yEpisode = (y.AirsBeforeEpisodeNumber ?? 0) * 1000; + + return xEpisode.CompareTo(yEpisode); + } + + private int CompareSpecials(Episode x, Episode y) + { + return GetSpecialCompareValue(x).CompareTo(GetSpecialCompareValue(y)); + } + + private int GetSpecialCompareValue(Episode item) + { + // First sort by season number + // Since there are three sort orders, pad with 9 digits (3 for each, figure 1000 episode buffer should be enough) + var val = (item.AirsBeforeSeasonNumber ?? item.AirsAfterSeasonNumber ?? 0) * 1000000000; + + // Second sort order is if it airs after the season + if (item.AirsAfterSeasonNumber.HasValue) + { + val += 1000000; + } + + // Third level is the episode number + val += (item.AirsBeforeEpisodeNumber ?? 0) * 1000; + + // Finally, if that's still the same, last resort is the special number itself + val += item.IndexNumber ?? 0; + + return val; + } + + private int CompareEpisodes(Episode x, Episode y) + { + var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1); + var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1); + + return xValue.CompareTo(yValue); + } + + /// + /// Gets the name. + /// + /// The name. + public string Name + { + get { return ItemSortBy.AiredEpisodeOrder; } + } + } +} -- cgit v1.2.3 From c3530e5e3255d2c2e8ec5fa4bc4635a21904235e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 20 Nov 2013 12:49:11 -0500 Subject: fixes #633 - Support Canadian ratings --- .../Localization/Ratings/ca.txt | 11 +++++++++++ .../MediaBrowser.Server.Implementations.csproj | 1 + 2 files changed, 12 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt b/MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt new file mode 100644 index 0000000000..e551223a8c --- /dev/null +++ b/MediaBrowser.Server.Implementations/Localization/Ratings/ca.txt @@ -0,0 +1,11 @@ +CA-G,1 +GB-U,1 +CA-PG,5 +DE-0,5 +CA-14A,7 +DE-12,7 +CA-A,8 +CA-18A,9 +SE-11,9 +DE-16,9 +CA-R,10 \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 282991cc1f..9347ea0ebe 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -266,6 +266,7 @@ + PreserveNewest -- cgit v1.2.3 From 71514af96be684dcbf432c5aca37712bbd773740 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 20 Nov 2013 16:08:12 -0500 Subject: render channels page --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 55 +++++++++++++++------- .../Sorting/AiredEpisodeOrderComparer.cs | 15 +++--- 2 files changed, 48 insertions(+), 22 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index 4239869a52..3936014c5c 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -206,7 +206,7 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "AiredDuringSeason", Description = "Gets all episodes that aired during a season, including specials.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? AiredDuringSeason { get; set; } - + [ApiMember(Name = "MinPremiereDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] public string MinPremiereDate { get; set; } @@ -1012,21 +1012,7 @@ namespace MediaBrowser.Api.UserLibrary if (request.AiredDuringSeason.HasValue) { - var val = request.AiredDuringSeason.Value; - - items = items.Where(i => - { - var episode = i as Episode; - - if (episode != null) - { - var seasonNumber = episode.AirsAfterSeasonNumber ?? episode.AirsBeforeSeasonNumber ?? episode.ParentIndexNumber; - - return episode.PremiereDate.HasValue && seasonNumber.HasValue && seasonNumber.Value == val; - } - - return false; - }); + items = FilterByAiredDuringSeason(items, request.AiredDuringSeason.Value); } if (!string.IsNullOrEmpty(request.MinPremiereDate)) @@ -1046,6 +1032,43 @@ namespace MediaBrowser.Api.UserLibrary return items; } + private IEnumerable FilterByAiredDuringSeason(IEnumerable items, int seasonNumber) + { + var episodes = items.OfType().ToList(); + + // We can only enforce the air date requirement if the episodes have air dates + var enforceAirDate = episodes.Any(i => i.PremiereDate.HasValue); + + return episodes.Where(i => + { + var episode = i; + + if (episode != null) + { + var currentSeasonNumber = episode.AirsAfterSeasonNumber ?? episode.AirsBeforeSeasonNumber ?? episode.ParentIndexNumber; + + // If this produced nothing, try and get it from the parent folder + if (!currentSeasonNumber.HasValue) + { + var season = episode.Parent as Season; + if (season != null) + { + currentSeasonNumber = season.IndexNumber; + } + } + + if (enforceAirDate && !episode.PremiereDate.HasValue) + { + return false; + } + + return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber; + } + + return false; + }); + } + /// /// Determines whether the specified item has image. /// diff --git a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index cec9743bae..23334aa412 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -1,8 +1,8 @@ -using System; -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; +using System; namespace MediaBrowser.Server.Implementations.Sorting { @@ -16,11 +16,14 @@ namespace MediaBrowser.Server.Implementations.Sorting /// System.Int32. public int Compare(BaseItem x, BaseItem y) { - var val = DateTime.Compare(x.PremiereDate ?? DateTime.MinValue, y.PremiereDate ?? DateTime.MinValue); - - if (val != 0) + if (x.PremiereDate.HasValue && y.PremiereDate.HasValue) { - return val; + var val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value); + + if (val != 0) + { + return val; + } } var episode1 = x as Episode; -- cgit v1.2.3 From bf5b4decb7ab1373fd59dfae7a4fba5631d61291 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 21 Nov 2013 11:02:31 -0500 Subject: check for zero bitrate coming from bdinfo --- MediaBrowser.Providers/Savers/MovieXmlSaver.cs | 3 ++- MediaBrowser.Server.Implementations/BdInfo/BdInfoExaminer.cs | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Providers/Savers/MovieXmlSaver.cs b/MediaBrowser.Providers/Savers/MovieXmlSaver.cs index a974fc13e9..1a287a918f 100644 --- a/MediaBrowser.Providers/Savers/MovieXmlSaver.cs +++ b/MediaBrowser.Providers/Savers/MovieXmlSaver.cs @@ -119,7 +119,8 @@ namespace MediaBrowser.Providers.Savers "IMDBrating", "Description", "Artist", - "Album" + "Album", + "TmdbCollectionName" }); // Set last refreshed so that the provider doesn't trigger after the file save diff --git a/MediaBrowser.Server.Implementations/BdInfo/BdInfoExaminer.cs b/MediaBrowser.Server.Implementations/BdInfo/BdInfoExaminer.cs index 219b76cd53..06768f353b 100644 --- a/MediaBrowser.Server.Implementations/BdInfo/BdInfoExaminer.cs +++ b/MediaBrowser.Server.Implementations/BdInfo/BdInfoExaminer.cs @@ -127,7 +127,6 @@ namespace MediaBrowser.Server.Implementations.BdInfo { var stream = new MediaStream { - BitRate = Convert.ToInt32(audioStream.BitRate), Codec = audioStream.CodecShortName, Language = audioStream.LanguageCode, Channels = audioStream.ChannelCount, @@ -136,6 +135,13 @@ namespace MediaBrowser.Server.Implementations.BdInfo Index = streams.Count }; + var bitrate = Convert.ToInt32(audioStream.BitRate); + + if (bitrate > 0) + { + stream.BitRate = bitrate; + } + if (audioStream.LFE > 0) { stream.Channels = audioStream.ChannelCount + 1; -- cgit v1.2.3 From ee1a746031f15bdfc5c5e38fab704f5fcb9b67ee Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 21 Nov 2013 11:02:49 -0500 Subject: use string.equals --- .../Library/Resolvers/Movies/MovieResolver.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 0f87b9d337..07beabb832 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -345,18 +345,9 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies /// true if [is DVD directory] [the specified directory name]; otherwise, false. private bool IsDvdDirectory(string directoryName) { - return directoryName.Equals("video_ts", StringComparison.OrdinalIgnoreCase); + return string.Equals(directoryName, "video_ts", StringComparison.OrdinalIgnoreCase); } - /// - /// Determines whether [is hd DVD directory] [the specified directory name]. - /// - /// Name of the directory. - /// true if [is hd DVD directory] [the specified directory name]; otherwise, false. - private bool IsHdDvdDirectory(string directoryName) - { - return directoryName.Equals("hvdvd_ts", StringComparison.OrdinalIgnoreCase); - } /// /// Determines whether [is blu ray directory] [the specified directory name]. /// @@ -364,7 +355,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies /// true if [is blu ray directory] [the specified directory name]; otherwise, false. private bool IsBluRayDirectory(string directoryName) { - return directoryName.Equals("bdmv", StringComparison.OrdinalIgnoreCase); + return string.Equals(directoryName, "bdmv", StringComparison.OrdinalIgnoreCase); } } } -- cgit v1.2.3 From 17bacee0890cb03a579f9469e435d922bbdfdd50 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 21 Nov 2013 15:48:26 -0500 Subject: consolidate Artist & MusicArtist --- MediaBrowser.Api/BaseApiService.cs | 18 +--- .../DefaultTheme/DefaultThemeService.cs | 15 +--- MediaBrowser.Api/ItemRefreshService.cs | 14 ++-- MediaBrowser.Api/ItemUpdateService.cs | 9 -- MediaBrowser.Api/LibraryService.cs | 16 +--- MediaBrowser.Api/SearchService.cs | 6 +- MediaBrowser.Api/UserLibrary/ArtistsService.cs | 21 +---- MediaBrowser.Controller/Entities/Audio/Artist.cs | 86 ------------------- .../Entities/Audio/MusicArtist.cs | 69 +++++++++++++++- MediaBrowser.Controller/Entities/BaseItem.cs | 5 ++ MediaBrowser.Controller/Entities/Folder.cs | 20 ++--- MediaBrowser.Controller/Entities/IItemByName.cs | 5 ++ MediaBrowser.Controller/Library/ILibraryManager.cs | 15 +++- .../MediaBrowser.Controller.csproj | 1 - MediaBrowser.Providers/FolderProviderFromXml.cs | 2 +- .../MediaBrowser.Providers.csproj | 2 - .../MediaInfo/BaseFFProbeProvider.cs | 4 +- .../Music/ArtistInfoFromSongProvider.cs | 42 ++++++---- .../Music/ArtistProviderFromXml.cs | 13 +-- .../Music/FanArtArtistByNameProvider.cs | 47 ----------- .../Music/LastFmImageProvider.cs | 2 +- .../Music/LastfmArtistByNameProvider.cs | 89 -------------------- .../Music/LastfmArtistProvider.cs | 11 --- MediaBrowser.Providers/Music/LastfmHelper.cs | 20 +---- .../Music/ManualFanartArtistProvider.cs | 2 +- .../Music/ManualLastFmImageProvider.cs | 9 +- MediaBrowser.Providers/Savers/ArtistXmlSaver.cs | 3 +- MediaBrowser.Providers/Savers/FolderXmlSaver.cs | 2 +- .../Dto/DtoService.cs | 4 +- .../Library/LibraryManager.cs | 96 ++++++++++++++++++---- .../Library/LuceneSearchEngine.cs | 16 +--- .../Library/Validators/ArtistsValidator.cs | 73 ++-------------- .../Providers/ImageSaver.cs | 2 +- MediaBrowser.WebDashboard/Api/DashboardService.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 6 ++ 35 files changed, 246 insertions(+), 500 deletions(-) delete mode 100644 MediaBrowser.Controller/Entities/Audio/Artist.cs delete mode 100644 MediaBrowser.Providers/Music/FanArtArtistByNameProvider.cs delete mode 100644 MediaBrowser.Providers/Music/LastfmArtistByNameProvider.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index d01e96a5ad..ee0721d5eb 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Api private readonly char[] _dashReplaceChars = new[] { '?', '/' }; private const char SlugChar = '-'; - protected Artist GetArtist(string name, ILibraryManager libraryManager) + protected MusicArtist GetArtist(string name, ILibraryManager libraryManager) { return libraryManager.GetArtist(DeSlugArtistName(name, libraryManager)); } @@ -147,21 +147,7 @@ namespace MediaBrowser.Api return name; } - return libraryManager.RootFolder.GetRecursiveChildren() - .OfType /// The recording identifier. public string RecordingId { get; set; } + + /// + /// Gets or sets the official rating. + /// + /// The official rating. + public string OfficialRating { get; set; } /// /// Gets or sets the name of the service. @@ -59,9 +65,38 @@ namespace MediaBrowser.Model.LiveTv /// public List Genres { get; set; } + /// + /// Gets or sets the quality. + /// + /// The quality. + public ProgramVideoQuality Quality { get; set; } + + /// + /// Gets or sets the audio. + /// + /// The audio. + public ProgramAudio Audio { get; set; } + + /// + /// Gets or sets the original air date. + /// + /// The original air date. + public DateTime? OriginalAirDate { get; set; } + public ProgramInfoDto() { Genres = new List(); } } + + public enum ProgramVideoQuality + { + StandardDefinition, + HighDefinition + } + + public enum ProgramAudio + { + Stereo + } } \ No newline at end of file diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.cs index 1276ddb9e4..ce0639aa0e 100644 --- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs +++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs @@ -17,6 +17,12 @@ /// The channel identifier. public string[] ChannelIdList { get; set; } + /// + /// Gets or sets the user identifier. + /// + /// The user identifier. + public string UserId { get; set; } + public ProgramQuery() { ChannelIdList = new string[] { }; diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index 782652f37b..8b0a28ed0c 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -55,5 +55,11 @@ namespace MediaBrowser.Model.LiveTv /// IsRecurring recording? /// public bool IsRecurring { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public RecordingStatus Status { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.cs new file mode 100644 index 0000000000..b8af8f6e22 --- /dev/null +++ b/MediaBrowser.Model/LiveTv/RecordingStatus.cs @@ -0,0 +1,13 @@ + +namespace MediaBrowser.Model.LiveTv +{ + public enum RecordingStatus + { + Pending, + InProgress, + Completed, + CompletedWithError, + Conflicted, + Deleted + } +} diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 1e94c6b5fb..1cbdc60efa 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -65,6 +65,7 @@ + diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 791da74e05..fda5496c76 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2,7 +2,11 @@ using MediaBrowser.Common.IO; using MediaBrowser.Controller; using MediaBrowser.Controller.Drawing; +using MediaBrowser.Controller.Dto; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Controller.Localization; using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; @@ -28,6 +32,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv private readonly IItemRepository _itemRepo; private readonly IImageProcessor _imageProcessor; + private readonly IUserManager _userManager; + private readonly ILocalizationManager _localization; + private readonly IUserDataManager _userDataManager; + private readonly IDtoService _dtoService; + private readonly List _services = new List(); private List _channels = new List(); @@ -36,13 +45,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv private readonly SemaphoreSlim _updateSemaphore = new SemaphoreSlim(1, 1); - public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor) + public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserManager userManager, ILocalizationManager localization, IUserDataManager userDataManager, IDtoService dtoService) { _appPaths = appPaths; _fileSystem = fileSystem; _logger = logger; _itemRepo = itemRepo; _imageProcessor = imageProcessor; + _userManager = userManager; + _localization = localization; + _userDataManager = userDataManager; + _dtoService = dtoService; } /// @@ -67,10 +80,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv /// Gets the channel info dto. /// /// The info. + /// The user. /// ChannelInfoDto. - public ChannelInfoDto GetChannelInfoDto(Channel info) + public ChannelInfoDto GetChannelInfoDto(Channel info, User user) { - return new ChannelInfoDto + var dto = new ChannelInfoDto { Name = info.Name, ServiceName = info.ServiceName, @@ -81,6 +95,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv Id = info.Id.ToString("N"), MediaType = info.MediaType }; + + if (user != null) + { + dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, info.GetUserDataKey())); + } + + return dto; } private ILiveTvService GetService(ChannelInfo channel) @@ -111,7 +132,28 @@ namespace MediaBrowser.Server.Implementations.LiveTv public QueryResult GetChannels(ChannelQuery query) { - var channels = _channels.OrderBy(i => + var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId)); + + IEnumerable channels = _channels; + + if (user != null) + { + channels = channels.Where(i => i.IsParentalAllowed(user, _localization)) + .OrderBy(i => + { + double number = 0; + + if (!string.IsNullOrEmpty(i.ChannelNumber)) + { + double.TryParse(i.ChannelNumber, out number); + } + + return number; + + }); + } + + var returnChannels = channels.OrderBy(i => { double number = 0; @@ -123,13 +165,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv return number; }).ThenBy(i => i.Name) - .Select(GetChannelInfoDto) + .Select(i => GetChannelInfoDto(i, user)) .ToArray(); return new QueryResult { - Items = channels, - TotalRecordCount = channels.Length + Items = returnChannels, + TotalRecordCount = returnChannels.Length }; } @@ -140,6 +182,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv return _channels.FirstOrDefault(i => i.Id == guid); } + public ChannelInfoDto GetChannelInfoDto(string id, string userId) + { + var channel = GetChannel(id); + + var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(new Guid(userId)); + + return channel == null ? null : GetChannelInfoDto(channel, user); + } + private ProgramInfoDto GetProgramInfoDto(ProgramInfo program, Channel channel) { var id = GetInternalProgramIdId(channel.ServiceName, program.Id).ToString("N"); @@ -154,7 +205,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv Id = id, Name = program.Name, ServiceName = channel.ServiceName, - StartDate = program.StartDate + StartDate = program.StartDate, + OfficialRating = program.OfficialRating, + Quality = program.Quality, + OriginalAirDate = program.OriginalAirDate, + Audio = program.Audio }; } @@ -367,7 +422,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv StartDate = info.StartDate, Id = id, ExternalId = info.Id, - ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N") + ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), + Status = info.Status }; if (!string.IsNullOrEmpty(info.ProgramId)) @@ -377,5 +433,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv return dto; } + + public QueryResult GetRecordings() + { + var returnArray = _recordings.ToArray(); + + return new QueryResult + { + Items = returnArray, + TotalRecordCount = returnArray.Length + }; + } } } diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index cd6ec18e13..c53277d778 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -294,7 +294,7 @@ namespace MediaBrowser.ServerApplication DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor); RegisterSingleInstance(DtoService); - LiveTvManager = new LiveTvManager(ApplicationPaths, FileSystemManager, Logger, ItemRepository, ImageProcessor); + LiveTvManager = new LiveTvManager(ApplicationPaths, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserManager, LocalizationManager, UserDataManager, DtoService); RegisterSingleInstance(LiveTvManager); var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false)); -- cgit v1.2.3 From 77e01e2461124af6229d0e10b7df01ef64802171 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Nov 2013 11:22:11 -0500 Subject: updated nuget for live tv --- MediaBrowser.Controller/LiveTv/ProgramInfo.cs | 10 ++++++++-- MediaBrowser.Model/LiveTv/ProgramInfoDto.cs | 6 ++++++ MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 3 ++- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 6 files changed, 21 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs index 2231b4eaa9..f6df495459 100644 --- a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs @@ -1,6 +1,6 @@ -using System; +using MediaBrowser.Model.LiveTv; +using System; using System.Collections.Generic; -using MediaBrowser.Model.LiveTv; namespace MediaBrowser.Controller.LiveTv { @@ -65,6 +65,12 @@ namespace MediaBrowser.Controller.LiveTv /// /// The audio. public ProgramAudio Audio { get; set; } + + /// + /// Gets or sets the community rating. + /// + /// The community rating. + public float? CommunityRating { get; set; } public ProgramInfo() { diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs index 8b0976671d..9e1a829c7c 100644 --- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs @@ -22,6 +22,12 @@ namespace MediaBrowser.Model.LiveTv /// The channel identifier. public string ChannelId { get; set; } + /// + /// Gets or sets the community rating. + /// + /// The community rating. + public float? CommunityRating { get; set; } + /// /// Gets or sets the recording identifier. /// diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index fda5496c76..e48cea0f7c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -209,7 +209,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv OfficialRating = program.OfficialRating, Quality = program.Quality, OriginalAirDate = program.OriginalAirDate, - Audio = program.Audio + Audio = program.Audio, + CommunityRating = program.CommunityRating }; } diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index f0c2c4308c..d5a264689e 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.249 + 3.0.250 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index ff211ee1b6..f5333c078e 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.249 + 3.0.250 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 25198e155d..6b3448f0e2 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.249 + 3.0.250 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From e05a84c789641966b49e780ea6111126a1102a86 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Nov 2013 16:36:11 -0500 Subject: updated nuget for live tv --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 22 +++- .../Entities/Audio/MusicArtist.cs | 15 ++- MediaBrowser.Controller/LiveTv/ChannelInfo.cs | 6 - MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 18 ++- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 33 +++-- MediaBrowser.Controller/LiveTv/ProgramInfo.cs | 6 + MediaBrowser.Controller/LiveTv/RecordingInfo.cs | 33 ----- MediaBrowser.Controller/LiveTv/TimerInfo.cs | 67 ++++++++++ .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Model/LiveTv/ProgramInfoDto.cs | 22 +++- MediaBrowser.Model/LiveTv/RecordingInfoDto.cs | 5 - MediaBrowser.Model/LiveTv/RecordingQuery.cs | 10 ++ .../Dto/DtoService.cs | 10 +- .../LiveTv/LiveTvManager.cs | 140 +++++++++++---------- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 17 files changed, 249 insertions(+), 149 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/TimerInfo.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 183b2bacb6..db50f463d4 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.LiveTv; +using System.Threading; +using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using ServiceStack.ServiceHost; @@ -49,8 +50,13 @@ namespace MediaBrowser.Api.LiveTv [Api(Description = "Gets live tv recordings")] public class GetRecordings : IReturn> { + [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ServiceName { get; set; } + + [ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ChannelId { get; set; } } - + [Route("/LiveTv/Programs", "GET")] [Api(Description = "Gets available live tv epgs..")] public class GetPrograms : IReturn> @@ -80,7 +86,7 @@ namespace MediaBrowser.Api.LiveTv if (!string.IsNullOrEmpty(serviceName)) { - services = services.Where(i => string.Equals(i.Name, serviceName, System.StringComparison.OrdinalIgnoreCase)); + services = services.Where(i => string.Equals(i.Name, serviceName, StringComparison.OrdinalIgnoreCase)); } return services; @@ -130,14 +136,20 @@ namespace MediaBrowser.Api.LiveTv ServiceName = request.ServiceName, ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray(), UserId = request.UserId - }); + + }, CancellationToken.None).Result; return ToOptimizedResult(result); } public object Get(GetRecordings request) { - var result = _liveTvManager.GetRecordings(); + var result = _liveTvManager.GetRecordings(new RecordingQuery + { + ChannelId = request.ChannelId, + ServiceName = request.ServiceName + + }, CancellationToken.None).Result; return ToOptimizedResult(result); } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index a234844ff6..8ebfe17e41 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -3,6 +3,8 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Runtime.Serialization; +using System.Threading; +using System.Threading.Tasks; namespace MediaBrowser.Controller.Entities.Audio { @@ -30,13 +32,24 @@ namespace MediaBrowser.Controller.Entities.Audio { if (IsAccessedByName) { - throw new InvalidOperationException("Artists accessed by name do not have children."); + return new List(); } return base.ActualChildren; } } + protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool? recursive = null, bool forceRefreshMetadata = false) + { + if (IsAccessedByName) + { + // Should never get in here anyway + return Task.FromResult(true); + } + + return base.ValidateChildrenInternal(progress, cancellationToken, recursive, forceRefreshMetadata); + } + public override string GetClientTypeName() { if (IsAccessedByName) diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs index 721c1e40a8..27fc596303 100644 --- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs @@ -25,12 +25,6 @@ namespace MediaBrowser.Controller.LiveTv /// The id of the channel. public string Id { get; set; } - /// - /// Gets or sets the name of the service. - /// - /// The name of the service. - public string ServiceName { get; set; } - /// /// Gets or sets the type of the channel. /// diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 9e49813318..a04072d28d 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -1,6 +1,8 @@ -using MediaBrowser.Model.LiveTv; +using System.Threading; +using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using System.Collections.Generic; +using System.Threading.Tasks; namespace MediaBrowser.Controller.LiveTv { @@ -15,6 +17,13 @@ namespace MediaBrowser.Controller.LiveTv /// The services. IReadOnlyList Services { get; } + /// + /// Schedules the recording. + /// + /// The program identifier. + /// Task. + Task ScheduleRecording(string programId); + /// /// Adds the parts. /// @@ -31,8 +40,10 @@ namespace MediaBrowser.Controller.LiveTv /// /// Gets the recordings. /// + /// The query. + /// The cancellation token. /// QueryResult{RecordingInfoDto}. - QueryResult GetRecordings(); + Task> GetRecordings(RecordingQuery query, CancellationToken cancellationToken); /// /// Gets the channel. @@ -53,7 +64,8 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the programs. /// /// The query. + /// The cancellation token. /// IEnumerable{ProgramInfo}. - QueryResult GetPrograms(ProgramQuery query); + Task> GetPrograms(ProgramQuery query, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 4e4f8dcc78..e903ad5ec6 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -1,5 +1,4 @@ using MediaBrowser.Common.Net; -using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -25,12 +24,12 @@ namespace MediaBrowser.Controller.LiveTv Task> GetChannelsAsync(CancellationToken cancellationToken); /// - /// Cancels the recording asynchronous. + /// Cancels the timer asynchronous. /// - /// The recording identifier. + /// The timer identifier. /// The cancellation token. /// Task. - Task CancelRecordingAsync(string recordingId, CancellationToken cancellationToken); + Task CancelTimerAsync(string timerId, CancellationToken cancellationToken); /// /// Deletes the recording asynchronous. @@ -39,18 +38,23 @@ namespace MediaBrowser.Controller.LiveTv /// The cancellation token. /// Task. Task DeleteRecordingAsync(string recordingId, CancellationToken cancellationToken); - + /// - /// Schedules the recording asynchronous. + /// Creates the timer asynchronous. /// - /// The name for the recording - /// The channel identifier. - /// The start time. - /// The duration. + /// The information. /// The cancellation token. /// Task. - Task ScheduleRecordingAsync(string name, string channelId, DateTime startTime, TimeSpan duration, CancellationToken cancellationToken); + Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken); + /// + /// Updates the timer asynchronous. + /// + /// The information. + /// The cancellation token. + /// Task. + Task UpdateTimerAsync(TimerInfo info, CancellationToken cancellationToken); + /// /// Gets the channel image asynchronous. /// @@ -66,6 +70,13 @@ namespace MediaBrowser.Controller.LiveTv /// Task{IEnumerable{RecordingInfo}}. Task> GetRecordingsAsync(CancellationToken cancellationToken); + /// + /// Gets the recordings asynchronous. + /// + /// The cancellation token. + /// Task{IEnumerable{RecordingInfo}}. + Task> GetTimersAsync(CancellationToken cancellationToken); + /// /// Gets the programs asynchronous. /// diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs index f6df495459..58a15be3e5 100644 --- a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs @@ -43,6 +43,12 @@ namespace MediaBrowser.Controller.LiveTv /// public DateTime EndDate { get; set; } + /// + /// Gets or sets the aspect ratio. + /// + /// The aspect ratio. + public string AspectRatio { get; set; } + /// /// Genre of the program. /// diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs index f61bd9e785..f0daac5f91 100644 --- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs +++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs @@ -1,6 +1,5 @@ using MediaBrowser.Model.LiveTv; using System; -using System.Collections.Generic; namespace MediaBrowser.Controller.LiveTv { @@ -20,12 +19,6 @@ namespace MediaBrowser.Controller.LiveTv /// ChannelName of the recording. /// public string ChannelName { get; set; } - - /// - /// Gets or sets the program identifier. - /// - /// The program identifier. - public string ProgramId { get; set; } /// /// Name of the recording. @@ -52,31 +45,5 @@ namespace MediaBrowser.Controller.LiveTv /// /// The status. public RecordingStatus Status { get; set; } - - /// - /// Gets or sets a value indicating whether this instance is recurring. - /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } - - /// - /// Parent recurring. - /// - public string RecurringParent { get; set; } - - /// - /// Start date for the recurring, in UTC. - /// - public DateTime RecurrringStartDate { get; set; } - - /// - /// End date for the recurring, in UTC - /// - public DateTime RecurringEndDate { get; set; } - - /// - /// When do we need the recording? - /// - public List DayMask { get; set; } } } diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs new file mode 100644 index 0000000000..f0f936b526 --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -0,0 +1,67 @@ +using MediaBrowser.Model.LiveTv; +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.LiveTv +{ + public class TimerInfo + { + /// + /// Id of the recording. + /// + public string Id { get; set; } + + /// + /// ChannelId of the recording. + /// + public string ChannelId { get; set; } + + /// + /// ChannelName of the recording. + /// + public string ChannelName { get; set; } + + /// + /// Name of the recording. + /// + public string Name { get; set; } + + /// + /// Description of the recording. + /// + public string Description { get; set; } + + /// + /// The start date of the recording, in UTC. + /// + public DateTime StartDate { get; set; } + + /// + /// The end date of the recording, in UTC. + /// + public DateTime EndDate { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public RecordingStatus Status { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is recurring. + /// + /// true if this instance is recurring; otherwise, false. + public bool IsRecurring { get; set; } + + /// + /// Gets or sets the recurring days. + /// + /// The recurring days. + public List RecurringDays { get; set; } + + public TimerInfo() + { + RecurringDays = new List(); + } + } +} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index ed63bc1647..2068fccf83 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,6 +110,7 @@ + diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs index 9e1a829c7c..2cafd288df 100644 --- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs @@ -27,13 +27,13 @@ namespace MediaBrowser.Model.LiveTv /// /// The community rating. public float? CommunityRating { get; set; } - + /// - /// Gets or sets the recording identifier. + /// Gets or sets the aspect ratio. /// - /// The recording identifier. - public string RecordingId { get; set; } - + /// The aspect ratio. + public string AspectRatio { get; set; } + /// /// Gets or sets the official rating. /// @@ -88,6 +88,18 @@ namespace MediaBrowser.Model.LiveTv /// /// The original air date. public DateTime? OriginalAirDate { get; set; } + + /// + /// Gets or sets the recording identifier. + /// + /// The recording identifier. + public string RecordingId { get; set; } + + /// + /// Gets or sets the recording status. + /// + /// The recording status. + public RecordingStatus? RecordingStatus { get; set; } public ProgramInfoDto() { diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index 8b0a28ed0c..926198b93f 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -51,11 +51,6 @@ namespace MediaBrowser.Model.LiveTv /// public DateTime EndDate { get; set; } - /// - /// IsRecurring recording? - /// - public bool IsRecurring { get; set; } - /// /// Gets or sets the status. /// diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.cs index 8d9866b5ec..8c83b0fcbd 100644 --- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs +++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs @@ -5,6 +5,16 @@ /// public class RecordingQuery { + /// + /// Gets or sets the channel identifier. + /// + /// The channel identifier. public string ChannelId { get; set; } + + /// + /// Gets or sets the name of the service. + /// + /// The name of the service. + public string ServiceName { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index dd1e2b9fa6..5333518753 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -207,7 +207,7 @@ namespace MediaBrowser.Server.Implementations.Dto if (!string.IsNullOrEmpty(image)) { - dto.PrimaryImageTag = _imageProcessor.GetImageCacheTag(user, ImageType.Primary, image); + dto.PrimaryImageTag = GetImageCacheTag(user, ImageType.Primary, image); try { @@ -285,13 +285,7 @@ namespace MediaBrowser.Server.Implementations.Dto if (!string.IsNullOrEmpty(imagePath)) { - try - { - info.PrimaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary, imagePath); - } - catch (IOException) - { - } + info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary, imagePath); } return info; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index e48cea0f7c..12241876a1 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -41,9 +41,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv private List _channels = new List(); private List _programs = new List(); - private List _recordings = new List(); - - private readonly SemaphoreSlim _updateSemaphore = new SemaphoreSlim(1, 1); public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserManager userManager, ILocalizationManager localization, IUserDataManager userDataManager, IDtoService dtoService) { @@ -104,11 +101,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv return dto; } - private ILiveTvService GetService(ChannelInfo channel) - { - return _services.FirstOrDefault(i => string.Equals(channel.ServiceName, i.Name, StringComparison.OrdinalIgnoreCase)); - } - private Guid? GetLogoImageTag(Channel info) { var path = info.PrimaryImagePath; @@ -210,7 +202,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv Quality = program.Quality, OriginalAirDate = program.OriginalAirDate, Audio = program.Audio, - CommunityRating = program.CommunityRating + CommunityRating = program.CommunityRating, + AspectRatio = program.AspectRatio }; } @@ -228,9 +221,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv return name.ToLower().GetMD5(); } - private async Task GetChannel(ChannelInfo channelInfo, CancellationToken cancellationToken) + private async Task GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken) { - var path = Path.Combine(_appPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(channelInfo.ServiceName), _fileSystem.GetValidFilename(channelInfo.Name)); + var path = Path.Combine(_appPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(serviceName), _fileSystem.GetValidFilename(channelInfo.Name)); var fileInfo = new DirectoryInfo(path); @@ -249,7 +242,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv isNew = true; } - var id = GetInternalChannelId(channelInfo.ServiceName, channelInfo.Id); + var id = GetInternalChannelId(serviceName, channelInfo.Id); var item = _itemRepo.RetrieveItem(id) as Channel; @@ -264,7 +257,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv Path = path, ChannelId = channelInfo.Id, ChannelNumber = channelInfo.Number, - ServiceName = channelInfo.ServiceName + ServiceName = serviceName }; isNew = true; @@ -278,7 +271,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return item; } - public QueryResult GetPrograms(ProgramQuery query) + public async Task> GetPrograms(ProgramQuery query, CancellationToken cancellationToken) { IEnumerable programs = _programs .OrderBy(i => i.StartDate) @@ -298,35 +291,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv var returnArray = programs.ToArray(); - return new QueryResult + var recordings = await GetRecordings(new RecordingQuery { - Items = returnArray, - TotalRecordCount = returnArray.Length - }; - } - internal async Task RefreshChannels(IProgress progress, CancellationToken cancellationToken) - { - await _updateSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - try - { - await RefreshChannelsInternal(progress, cancellationToken).ConfigureAwait(false); - } - finally + }, cancellationToken).ConfigureAwait(false); + + foreach (var program in returnArray) { - _updateSemaphore.Release(); + var recording = recordings.Items + .FirstOrDefault(i => string.Equals(i.ProgramId, program.Id)); + + program.RecordingId = recording == null ? null : recording.Id; + program.RecordingStatus = recording == null ? (RecordingStatus?)null : recording.Status; } - await RefreshRecordings(new Progress(), cancellationToken).ConfigureAwait(false); + return new QueryResult + { + Items = returnArray, + TotalRecordCount = returnArray.Length + }; } - private async Task RefreshChannelsInternal(IProgress progress, CancellationToken cancellationToken) + internal async Task RefreshChannels(IProgress progress, CancellationToken cancellationToken) { // Avoid implicitly captured closure var currentCancellationToken = cancellationToken; - var channelTasks = _services.Select(i => i.GetChannelsAsync(currentCancellationToken)); + var channelTasks = _services.Select(i => GetChannels(i, currentCancellationToken)); progress.Report(10); @@ -343,11 +335,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv { try { - var item = await GetChannel(channelInfo, cancellationToken).ConfigureAwait(false); + var item = await GetChannel(channelInfo.Item2, channelInfo.Item1, cancellationToken).ConfigureAwait(false); - var service = GetService(channelInfo); + var service = _services.First(i => string.Equals(channelInfo.Item1, i.Name, StringComparison.OrdinalIgnoreCase)); - var channelPrograms = await service.GetProgramsAsync(channelInfo.Id, cancellationToken).ConfigureAwait(false); + var channelPrograms = await service.GetProgramsAsync(channelInfo.Item2.Id, cancellationToken).ConfigureAwait(false); programs.AddRange(channelPrograms.Select(program => GetProgramInfoDto(program, item))); @@ -359,7 +351,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv } catch (Exception ex) { - _logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Name); + _logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Item2.Name); } numComplete++; @@ -373,32 +365,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv _channels = list; } - internal async Task RefreshRecordings(IProgress progress, CancellationToken cancellationToken) - { - await _updateSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); - - try - { - await RefreshRecordingsInternal(progress, cancellationToken).ConfigureAwait(false); - } - finally - { - _updateSemaphore.Release(); - } - } - - private async Task RefreshRecordingsInternal(IProgress progress, CancellationToken cancellationToken) + private async Task>> GetChannels(ILiveTvService service, CancellationToken cancellationToken) { - var list = new List(); - - foreach (var service in _services) - { - var recordings = await GetRecordings(service, cancellationToken).ConfigureAwait(false); - - list.AddRange(recordings); - } + var channels = await service.GetChannelsAsync(cancellationToken).ConfigureAwait(false); - _recordings = list; + return channels.Select(i => new Tuple(service.Name, i)); } private async Task> GetRecordings(ILiveTvService service, CancellationToken cancellationToken) @@ -419,7 +390,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv Description = info.Description, EndDate = info.EndDate, Name = info.Name, - IsRecurring = info.IsRecurring, StartDate = info.StartDate, Id = id, ExternalId = info.Id, @@ -427,17 +397,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv Status = info.Status }; - if (!string.IsNullOrEmpty(info.ProgramId)) - { - dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N"); - } - return dto; } - public QueryResult GetRecordings() + public async Task> GetRecordings(RecordingQuery query, CancellationToken cancellationToken) { - var returnArray = _recordings.ToArray(); + var list = new List(); + + foreach (var service in GetServices(query.ServiceName, query.ChannelId)) + { + var recordings = await GetRecordings(service, cancellationToken).ConfigureAwait(false); + + list.AddRange(recordings); + } + + if (!string.IsNullOrEmpty(query.ChannelId)) + { + list = list.Where(i => string.Equals(i.ChannelId, query.ChannelId)) + .ToList(); + } + + var returnArray = list.ToArray(); return new QueryResult { @@ -445,5 +425,31 @@ namespace MediaBrowser.Server.Implementations.LiveTv TotalRecordCount = returnArray.Length }; } + + private IEnumerable GetServices(string serviceName, string channelId) + { + IEnumerable services = _services; + + if (string.IsNullOrEmpty(serviceName) && !string.IsNullOrEmpty(channelId)) + { + var channelIdGuid = new Guid(channelId); + + serviceName = _channels.Where(i => i.Id == channelIdGuid) + .Select(i => i.ServiceName) + .FirstOrDefault(); + } + + if (!string.IsNullOrEmpty(serviceName)) + { + services = services.Where(i => string.Equals(i.Name, serviceName, StringComparison.OrdinalIgnoreCase)); + } + + return services; + } + + public Task ScheduleRecording(string programId) + { + throw new NotImplementedException(); + } } } diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index d5a264689e..2b2c47db80 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.250 + 3.0.251 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index f5333c078e..a7a3150e68 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.250 + 3.0.251 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 6b3448f0e2..da0705c77e 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.250 + 3.0.251 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From 64818ebd223880d1ef7d7173b10968077d2378b0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Nov 2013 21:38:11 -0500 Subject: fix directory watchers not picking up changes --- .../Library/LibraryStructureService.cs | 33 ++++++++++++++++++---- MediaBrowser.Api/TvShowsService.cs | 12 +------- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 4 +-- MediaBrowser.Model/LiveTv/ProgramInfoDto.cs | 12 ++++++++ .../TV/EpisodeProviderFromXml.cs | 1 - .../IO/DirectoryWatchers.cs | 2 +- .../Library/LibraryManager.cs | 14 +++++++++ .../LiveTv/RefreshChannelsScheduledTask.cs | 2 +- MediaBrowser.ServerApplication/ApplicationHost.cs | 2 -- 9 files changed, 59 insertions(+), 23 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index f3306bb63c..198bec1a0d 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -286,7 +286,12 @@ namespace MediaBrowser.Api.Library } finally { - _directoryWatchers.Start(); + // No need to start if scanning the library because it will handle it + if (!request.RefreshLibrary) + { + _directoryWatchers.Start(); + } + _directoryWatchers.RemoveTempIgnore(virtualFolderPath); } @@ -353,7 +358,12 @@ namespace MediaBrowser.Api.Library } finally { - _directoryWatchers.Start(); + // No need to start if scanning the library because it will handle it + if (!request.RefreshLibrary) + { + _directoryWatchers.Start(); + } + _directoryWatchers.RemoveTempIgnore(currentPath); _directoryWatchers.RemoveTempIgnore(newPath); } @@ -404,7 +414,12 @@ namespace MediaBrowser.Api.Library } finally { - _directoryWatchers.Start(); + // No need to start if scanning the library because it will handle it + if (!request.RefreshLibrary) + { + _directoryWatchers.Start(); + } + _directoryWatchers.RemoveTempIgnore(path); } @@ -442,7 +457,11 @@ namespace MediaBrowser.Api.Library } finally { - _directoryWatchers.Start(); + // No need to start if scanning the library because it will handle it + if (!request.RefreshLibrary) + { + _directoryWatchers.Start(); + } } if (request.RefreshLibrary) @@ -479,7 +498,11 @@ namespace MediaBrowser.Api.Library } finally { - _directoryWatchers.Start(); + // No need to start if scanning the library because it will handle it + if (!request.RefreshLibrary) + { + _directoryWatchers.Start(); + } } if (request.RefreshLibrary) diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 1774f1a8ed..b36005c1aa 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -372,22 +372,12 @@ namespace MediaBrowser.Api return episodes.Where(i => (i.PhysicalSeasonNumber ?? -1) == seasonNumber); } - var episodeList = episodes.ToList(); - - // We can only enforce the air date requirement if the episodes have air dates - var enforceAirDate = episodeList.Any(i => i.PremiereDate.HasValue); - - return episodeList.Where(i => + return episodes.Where(i => { var episode = i; if (episode != null) { - if (enforceAirDate && !episode.PremiereDate.HasValue) - { - return false; - } - var currentSeasonNumber = episode.AiredSeasonNumber; return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber; diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index a04072d28d..91634b4bfb 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -1,7 +1,7 @@ -using System.Threading; -using MediaBrowser.Model.LiveTv; +using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; namespace MediaBrowser.Controller.LiveTv diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs index 2cafd288df..26cfd3cf00 100644 --- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs @@ -100,6 +100,18 @@ namespace MediaBrowser.Model.LiveTv /// /// The recording status. public RecordingStatus? RecordingStatus { get; set; } + + /// + /// Gets or sets the timer identifier. + /// + /// The timer identifier. + public string TimerId { get; set; } + + /// + /// Gets or sets the timer status. + /// + /// The timer status. + public RecordingStatus? TimerStatus { get; set; } public ProgramInfoDto() { diff --git a/MediaBrowser.Providers/TV/EpisodeProviderFromXml.cs b/MediaBrowser.Providers/TV/EpisodeProviderFromXml.cs index b6fdaaa831..7ddf421b9b 100644 --- a/MediaBrowser.Providers/TV/EpisodeProviderFromXml.cs +++ b/MediaBrowser.Providers/TV/EpisodeProviderFromXml.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Persistence; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs index b24cc20635..870a14bd80 100644 --- a/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs +++ b/MediaBrowser.Server.Implementations/IO/DirectoryWatchers.cs @@ -69,7 +69,7 @@ namespace MediaBrowser.Server.Implementations.IO // This is an arbitraty amount of time, but delay it because file system writes often trigger events after RemoveTempIgnore has been called. // Seeing long delays in some situations, especially over the network. // Seeing delays up to 40 seconds, but not going to ignore changes for that long. - await Task.Delay(20000).ConfigureAwait(false); + await Task.Delay(1500).ConfigureAwait(false); string val; _tempIgnoredPaths.TryRemove(path, out val); diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 58a2fcd7ed..74c4f8b2a8 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -905,6 +905,20 @@ namespace MediaBrowser.Server.Implementations.Library /// The cancellation token. /// Task. public async Task ValidateMediaLibraryInternal(IProgress progress, CancellationToken cancellationToken) + { + _directoryWatchersFactory().Stop(); + + try + { + await PerformLibraryValidation(progress, cancellationToken).ConfigureAwait(false); + } + finally + { + _directoryWatchersFactory().Start(); + } + } + + private async Task PerformLibraryValidation(IProgress progress, CancellationToken cancellationToken) { _logger.Info("Validating media library"); diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index c3803d9bbc..3e7feeff79 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.LiveTv { - class RefreshChannelsScheduledTask : IScheduledTask + class RefreshChannelsScheduledTask { private readonly ILiveTvManager _liveTvManager; diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index c53277d778..fcd7d299cf 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -199,8 +199,6 @@ namespace MediaBrowser.ServerApplication { await base.RunStartupTasks().ConfigureAwait(false); - DirectoryWatchers.Start(); - Logger.Info("Core startup complete"); Parallel.ForEach(GetExports(), entryPoint => -- cgit v1.2.3 From 6e3b8420baeca7fce91979a78ccff48457ac82e6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 26 Nov 2013 21:41:29 -0500 Subject: removed test code --- .../LiveTv/RefreshChannelsScheduledTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index 3e7feeff79..c3803d9bbc 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.LiveTv { - class RefreshChannelsScheduledTask + class RefreshChannelsScheduledTask : IScheduledTask { private readonly ILiveTvManager _liveTvManager; -- cgit v1.2.3 From 1e9ffb83cf060bf2f755cd5a62782209eaaa6a4b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 27 Nov 2013 14:04:19 -0500 Subject: added live tv timers page --- MediaBrowser.Api/Images/ImageService.cs | 55 +++++++++++++++ MediaBrowser.Api/LiveTv/LiveTvService.cs | 23 +++++++ MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 8 +++ .../MediaBrowser.Model.Portable.csproj | 3 + .../MediaBrowser.Model.net35.csproj | 3 + MediaBrowser.Model/LiveTv/RecordingQuery.cs | 15 ++++ MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 72 ++++++++++++++++++++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../LiveTv/LiveTvManager.cs | 62 ++++++++++++++++- .../Sorting/AiredEpisodeOrderComparer.cs | 19 +++--- .../MediaBrowser.ServerApplication.csproj | 6 +- MediaBrowser.ServerApplication/packages.config | 2 +- MediaBrowser.WebDashboard/Api/DashboardService.cs | 3 +- MediaBrowser.WebDashboard/ApiClient.js | 79 ++++++++++++++++++++-- .../MediaBrowser.WebDashboard.csproj | 72 ++++++++++---------- MediaBrowser.WebDashboard/packages.config | 2 +- 16 files changed, 368 insertions(+), 57 deletions(-) create mode 100644 MediaBrowser.Model/LiveTv/TimerInfoDto.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs index 9112518b86..27881d12ba 100644 --- a/MediaBrowser.Api/Images/ImageService.cs +++ b/MediaBrowser.Api/Images/ImageService.cs @@ -269,6 +269,19 @@ namespace MediaBrowser.Api.Images public Guid Id { get; set; } } + [Route("/LiveTv/Channels/{Id}/Images/{Type}", "DELETE")] + [Route("/LiveTv/Channels/{Id}/Images/{Type}/{Index}", "DELETE")] + [Api(Description = "Deletes an item image")] + public class DeleteChannelImage : DeleteImageRequest, IReturnVoid + { + /// + /// Gets or sets the id. + /// + /// The id. + [ApiMember(Name = "Id", Description = "Channel Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] + public string Id { get; set; } + } + /// /// Class PostUserImage /// @@ -344,6 +357,25 @@ namespace MediaBrowser.Api.Images public Stream RequestStream { get; set; } } + [Route("/LiveTv/Channels/{Id}/Images/{Type}", "POST")] + [Route("/LiveTv/Channels/{Id}/Images/{Type}/{Index}", "POST")] + [Api(Description = "Posts an item image")] + public class PostChannelImage : DeleteImageRequest, IRequiresRequestStream, IReturnVoid + { + /// + /// Gets or sets the id. + /// + /// The id. + [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")] + public string Id { get; set; } + + /// + /// The raw Http Request Input Stream + /// + /// The request stream. + public Stream RequestStream { get; set; } + } + /// /// Class ImageService /// @@ -622,6 +654,20 @@ namespace MediaBrowser.Api.Images Task.WaitAll(task); } + public void Post(PostChannelImage request) + { + var pathInfo = PathInfo.Parse(RequestContext.PathInfo); + var id = pathInfo.GetArgumentValue(2); + + request.Type = (ImageType)Enum.Parse(typeof(ImageType), pathInfo.GetArgumentValue(4), true); + + var item = _liveTv.GetChannel(id); + + var task = PostImage(item, request.RequestStream, request.Type, RequestContext.ContentType); + + Task.WaitAll(task); + } + /// /// Deletes the specified request. /// @@ -648,6 +694,15 @@ namespace MediaBrowser.Api.Images Task.WaitAll(task); } + public void Delete(DeleteChannelImage request) + { + var item = _liveTv.GetChannel(request.Id); + + var task = item.DeleteImage(request.Type, request.Index); + + Task.WaitAll(task); + } + /// /// Deletes the specified request. /// diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index db50f463d4..2961c920f8 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -57,6 +57,17 @@ namespace MediaBrowser.Api.LiveTv public string ChannelId { get; set; } } + [Route("/LiveTv/Timers", "GET")] + [Api(Description = "Gets live tv timers")] + public class GetTimers : IReturn> + { + [ApiMember(Name = "ServiceName", Description = "Optional filter by service.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ServiceName { get; set; } + + [ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ChannelId { get; set; } + } + [Route("/LiveTv/Programs", "GET")] [Api(Description = "Gets available live tv epgs..")] public class GetPrograms : IReturn> @@ -153,5 +164,17 @@ namespace MediaBrowser.Api.LiveTv return ToOptimizedResult(result); } + + public object Get(GetTimers request) + { + var result = _liveTvManager.GetTimers(new TimerQuery + { + ChannelId = request.ChannelId, + ServiceName = request.ServiceName + + }, CancellationToken.None).Result; + + return ToOptimizedResult(result); + } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 91634b4bfb..7938c38ec9 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -45,6 +45,14 @@ namespace MediaBrowser.Controller.LiveTv /// QueryResult{RecordingInfoDto}. Task> GetRecordings(RecordingQuery query, CancellationToken cancellationToken); + /// + /// Gets the timers. + /// + /// The query. + /// The cancellation token. + /// Task{QueryResult{TimerInfoDto}}. + Task> GetTimers(TimerQuery query, CancellationToken cancellationToken); + /// /// Gets the channel. /// diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 6962cb470b..67888aa46d 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -251,6 +251,9 @@ LiveTv\RecordingStatus.cs + + LiveTv\TimerInfoDto.cs + Logging\ILogger.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 0bf2684bfd..cfe4a5462f 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -238,6 +238,9 @@ LiveTv\RecordingStatus.cs + + LiveTv\TimerInfoDto.cs + Logging\ILogger.cs diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.cs index 8c83b0fcbd..0820c7785e 100644 --- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs +++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs @@ -17,4 +17,19 @@ /// The name of the service. public string ServiceName { get; set; } } + + public class TimerQuery + { + /// + /// Gets or sets the channel identifier. + /// + /// The channel identifier. + public string ChannelId { get; set; } + + /// + /// Gets or sets the name of the service. + /// + /// The name of the service. + public string ServiceName { get; set; } + } } diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs new file mode 100644 index 0000000000..6a8339031a --- /dev/null +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Model.LiveTv +{ + public class TimerInfoDto + { + /// + /// Id of the recording. + /// + public string Id { get; set; } + + /// + /// Gets or sets the external identifier. + /// + /// The external identifier. + public string ExternalId { get; set; } + + /// + /// ChannelId of the recording. + /// + public string ChannelId { get; set; } + + /// + /// ChannelName of the recording. + /// + public string ChannelName { get; set; } + + /// + /// Name of the recording. + /// + public string Name { get; set; } + + /// + /// Description of the recording. + /// + public string Description { get; set; } + + /// + /// The start date of the recording, in UTC. + /// + public DateTime StartDate { get; set; } + + /// + /// The end date of the recording, in UTC. + /// + public DateTime EndDate { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public RecordingStatus Status { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is recurring. + /// + /// true if this instance is recurring; otherwise, false. + public bool IsRecurring { get; set; } + + /// + /// Gets or sets the recurring days. + /// + /// The recurring days. + public List RecurringDays { get; set; } + + public TimerInfoDto() + { + RecurringDays = new List(); + } + } +} diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 1cbdc60efa..103e583aed 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -66,6 +66,7 @@ + diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 12241876a1..00ac83f15c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -417,7 +417,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv .ToList(); } - var returnArray = list.ToArray(); + var returnArray = list.OrderByDescending(i => i.StartDate) + .ToArray(); return new QueryResult { @@ -451,5 +452,64 @@ namespace MediaBrowser.Server.Implementations.LiveTv { throw new NotImplementedException(); } + + public async Task> GetTimers(TimerQuery query, CancellationToken cancellationToken) + { + var list = new List(); + + foreach (var service in GetServices(query.ServiceName, query.ChannelId)) + { + var timers = await GetTimers(service, cancellationToken).ConfigureAwait(false); + + list.AddRange(timers); + } + + if (!string.IsNullOrEmpty(query.ChannelId)) + { + list = list.Where(i => string.Equals(i.ChannelId, query.ChannelId)) + .ToList(); + } + + var returnArray = list.OrderByDescending(i => i.StartDate) + .ToArray(); + + return new QueryResult + { + Items = returnArray, + TotalRecordCount = returnArray.Length + }; + } + + private async Task> GetTimers(ILiveTvService service, CancellationToken cancellationToken) + { + var timers = await service.GetTimersAsync(cancellationToken).ConfigureAwait(false); + + return timers.Select(i => GetTimerInfoDto(i, service)); + } + + private TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service) + { + var id = service.Name + info.ChannelId + info.Id; + id = id.GetMD5().ToString("N"); + + var dto = new TimerInfoDto + { + ChannelName = info.ChannelName, + Description = info.Description, + EndDate = info.EndDate, + Name = info.Name, + StartDate = info.StartDate, + Id = id, + ExternalId = info.Id, + ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), + Status = info.Status, + IsRecurring = info.IsRecurring, + RecurringDays = info.RecurringDays + }; + + return dto; + } + + } } diff --git a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index bdc343dea6..76971342a0 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (val != 0) { - return val; + //return val; } } @@ -49,8 +49,8 @@ namespace MediaBrowser.Server.Implementations.Sorting private int Compare(Episode x, Episode y) { - var isXSpecial = (x.ParentIndexNumber ?? -1) == 0; - var isYSpecial = (y.ParentIndexNumber ?? -1) == 0; + var isXSpecial = (x.PhysicalSeasonNumber ?? -1) == 0; + var isYSpecial = (y.PhysicalSeasonNumber ?? -1) == 0; if (isXSpecial && isYSpecial) { @@ -67,12 +67,12 @@ namespace MediaBrowser.Server.Implementations.Sorting return CompareEpisodeToSpecial(x, y); } - return CompareEpisodeToSpecial(x, y) * -1; + return CompareEpisodeToSpecial(y, x) * -1; } private int CompareEpisodeToSpecial(Episode x, Episode y) { - var xSeason = x.ParentIndexNumber ?? -1; + var xSeason = x.PhysicalSeasonNumber ?? -1; var ySeason = y.AirsAfterSeasonNumber ?? y.AirsBeforeSeasonNumber ?? -1; if (xSeason != ySeason) @@ -85,8 +85,9 @@ namespace MediaBrowser.Server.Implementations.Sorting // Compare episode number // Add 1 to to non-specials to account for AirsBeforeEpisodeNumber - var xEpisode = (x.IndexNumber ?? 0) * 1000 + 1; - var yEpisode = (y.AirsBeforeEpisodeNumber ?? 0) * 1000; + var xEpisode = x.IndexNumber ?? -1; + xEpisode++; + var yEpisode = y.AirsBeforeEpisodeNumber ?? 10000; return xEpisode.CompareTo(yEpisode); } @@ -119,8 +120,8 @@ namespace MediaBrowser.Server.Implementations.Sorting private int CompareEpisodes(Episode x, Episode y) { - var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1); - var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1); + var xValue = ((x.PhysicalSeasonNumber ?? -1) * 1000) + (x.IndexNumber ?? -1); + var yValue = ((y.PhysicalSeasonNumber ?? -1) * 1000) + (y.IndexNumber ?? -1); return xValue.CompareTo(yValue); } diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index f24283e70d..cfacffe087 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -119,9 +119,9 @@ ..\packages\Hardcodet.Wpf.TaskbarNotification.1.0.4.0\lib\net40\Hardcodet.Wpf.TaskbarNotification.dll - + False - ..\packages\MediaBrowser.IsoMounting.3.0.61\lib\net45\MediaBrowser.IsoMounter.dll + ..\packages\MediaBrowser.IsoMounting.3.0.65\lib\net45\MediaBrowser.IsoMounter.dll False @@ -129,7 +129,7 @@ False - ..\packages\MediaBrowser.IsoMounting.3.0.61\lib\net45\pfmclrapi.dll + ..\packages\MediaBrowser.IsoMounting.3.0.65\lib\net45\pfmclrapi.dll False diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index 0893a1b38a..e01ca1f672 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -1,7 +1,7 @@  - + diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 2b74eebb0c..69f05631f3 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -430,7 +430,7 @@ namespace MediaBrowser.WebDashboard.Api "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", "http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js", "scripts/all.js" + versionString, - "thirdparty/jstree1.0fix2/jquery.jstree.js" + "thirdparty/jstree1.0fix3/jquery.jstree.js" }; var tags = files.Select(s => string.Format("", s)).ToArray(); @@ -483,6 +483,7 @@ namespace MediaBrowser.WebDashboard.Api "livetvchannels.js", "livetvguide.js", "livetvrecordings.js", + "livetvtimers.js", "loginpage.js", "logpage.js", "medialibrarypage.js", diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index e63eb4d2b1..69f3f020cf 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -380,7 +380,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi self.getLiveTvServices = function (options) { - var url = self.getUrl("/LiveTv/Services", options || {}); + var url = self.getUrl("LiveTv/Services", options || {}); return self.ajax({ type: "GET", @@ -395,7 +395,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi throw new Error("null id"); } - var url = self.getUrl("/LiveTv/Channels/" + id); + var url = self.getUrl("LiveTv/Channels/" + id); return self.ajax({ type: "GET", @@ -406,7 +406,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi self.getLiveTvChannels = function (options) { - var url = self.getUrl("/LiveTv/Channels", options || {}); + var url = self.getUrl("LiveTv/Channels", options || {}); return self.ajax({ type: "GET", @@ -417,7 +417,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi self.getLiveTvPrograms = function (options) { - var url = self.getUrl("/LiveTv/Programs", options || {}); + var url = self.getUrl("LiveTv/Programs", options || {}); return self.ajax({ type: "GET", @@ -428,7 +428,76 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi self.getLiveTvRecordings = function (options) { - var url = self.getUrl("/LiveTv/Recordings", options || {}); + var url = self.getUrl("LiveTv/Recordings", options || {}); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + self.getLiveTvRecording = function (id) { + + if (!id) { + throw new Error("null id"); + } + + var url = self.getUrl("LiveTv/Recordings/" + id); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + self.deleteLiveTvRecording = function (id) { + + if (!id) { + throw new Error("null id"); + } + + var url = self.getUrl("LiveTv/Recordings/" + id); + + return self.ajax({ + type: "DELETE", + url: url + }); + }; + + self.cancelLiveTvTimer = function (id) { + + if (!id) { + throw new Error("null id"); + } + + var url = self.getUrl("LiveTv/Timers/" + id); + + return self.ajax({ + type: "DELETE", + url: url + }); + }; + + self.getLiveTvTimers = function (options) { + + var url = self.getUrl("LiveTv/Timers", options || {}); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + self.getLiveTvTimer = function (id) { + + if (!id) { + throw new Error("null id"); + } + + var url = self.getUrl("LiveTv/Timers/" + id); return self.ajax({ type: "GET", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 54e70cb9ab..5585e0db5e 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -80,9 +80,18 @@ + + PreserveNewest + + + PreserveNewest + PreserveNewest + + PreserveNewest + PreserveNewest @@ -281,18 +290,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -350,6 +347,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -595,76 +595,76 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index ab57a48b15..35511052f4 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file -- cgit v1.2.3 From 5bf12c3bad26a8eab095d33f200486549b88a265 Mon Sep 17 00:00:00 2001 From: tikuf Date: Thu, 28 Nov 2013 16:51:38 +1100 Subject: Better Thumb extraction. Remove Black bars if we make them. Fix fsbs and ftab image extraction. --- .../MediaEncoder/MediaEncoder.cs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index b8874fb548..2224c657ff 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -864,25 +864,33 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw new ArgumentNullException("outputPath"); } - var vf = "scale=iw*sar:ih, scale=600:-1"; - + var vf = "crop=min(iw\\,ih*dar):min(ih\\,iw/dar):(iw-min(iw\\,iw*sar))/2:(ih - min (ih\\,ih/sar))/2,scale=600:600/dar"; + // apply some filters to thumbnail extracted below (below) crop any black lines that we made and get the correct ar then scale to width 600. This filter chain may have adverse effects on recorded tv thumbnails if ar changes during presentation ex. commercials @ diff ar if (threedFormat.HasValue) { switch (threedFormat.Value) { case Video3DFormat.HalfSideBySide: + vf = "crop=iw/2:ih:0:0,scale=(iw*2):ih,setdar=dar=a,crop=min(iw\\,ih*dar):min(ih\\,iw/dar):(iw-min(iw\\,iw*sar))/2:(ih - min (ih\\,ih/sar))/2,scale=600:600/dar"; + // hsbs crop width in half,scale to correct size, set the display aspect,crop out any black bars we may have made the scale width to 600. Work out the correct height based on the display aspect it will maintain the aspect where -1 in this case (3d) may not. + break; case Video3DFormat.FullSideBySide: - vf = "crop=iw/2:ih:0:0,scale=(iw*2):ih,scale=600:-1"; + vf = "crop=iw/2:ih:0:0,setdar=dar=a,,crop=min(iw\\,ih*dar):min(ih\\,iw/dar):(iw-min(iw\\,iw*sar))/2:(ih - min (ih\\,ih/sar))/2,scale=600:600/dar"; + //fsbs crop width in half,set the display aspect,crop out any black bars we may have made the scale width to 600. break; case Video3DFormat.HalfTopAndBottom: + vf = "crop=iw:ih/2:0:0,scale=(iw*2):ih),setdar=dar=a,crop=min(iw\\,ih*dar):min(ih\\,iw/dar):(iw-min(iw\\,iw*sar))/2:(ih - min (ih\\,ih/sar))/2,scale=600:600/dar"; + //htab crop heigh in half,scale to correct size, set the display aspect,crop out any black bars we may have made the scale width to 600 + break; case Video3DFormat.FullTopAndBottom: - vf = "crop=iw:ih/2:0:0,scale=iw:(ih*2),scale=600:-1"; + vf = "crop=iw:ih/2:0:0,setdar=dar=a,crop=min(iw\\,ih*dar):min(ih\\,iw/dar):(iw-min(iw\\,iw*sar))/2:(ih - min (ih\\,ih/sar))/2,scale=600:600/dar"; + // ftab crop heigt in half, set the display aspect,crop out any black bars we may have made the scale width to 600 break; } } - var args = useIFrame ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -filter:v select=\"eq(pict_type\\,I)\" -vf \"{2}\" -f image2 \"{1}\"", inputPath, outputPath, vf) : - string.Format("-i {0} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, outputPath, vf); + var args = useIFrame ? string.Format("-i {0} -threads 0 -v quiet -vframes 1 -vf \"thumbnail,{2}\" -f image2 \"{1}\"", inputPath, outputPath, vf) : + string.Format("-i {0} -threads 0 -v quiet -vframes 1 -vf \"{2}\" -f image2 \"{1}\"", inputPath, outputPath, vf); //use ffmpeg to sample 100 (we can drop this if required using thumbnail=50 for 50 frames) frames and pick the best thumbnail. Have a fall back jic var probeSize = GetProbeSizeArgument(type); -- cgit v1.2.3 From 235b838fbe262f3f41cd64c8506d067c9ef9253e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Nov 2013 11:58:24 -0500 Subject: support deleting and canceling live tv recordings and timers --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 31 +++++++++++ .../ScheduledTasks/ScheduledTaskService.cs | 32 +++++++++-- .../ScheduledTasksWebSocketListener.cs | 6 +- MediaBrowser.Api/TvShowsService.cs | 64 +++++++++++++++++----- .../BaseApplicationHost.cs | 2 +- .../HttpClientManager/HttpClientManager.cs | 3 +- .../ScheduledTasks/Tasks/DeleteCacheFileTask.cs | 1 - .../ScheduledTasks/IScheduledTask.cs | 5 ++ .../ScheduledTasks/ScheduledTaskHelpers.cs | 12 +++- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 14 +++++ MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 8 --- MediaBrowser.Controller/LiveTv/RecordingInfo.cs | 6 ++ MediaBrowser.Controller/LiveTv/TimerInfo.cs | 18 ++---- MediaBrowser.Model/LiveTv/RecordingStatus.cs | 7 +++ MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 24 +++----- MediaBrowser.Model/Querying/EpisodeQuery.cs | 13 +++-- MediaBrowser.Model/Tasks/TaskInfo.cs | 6 ++ .../LiveTv/LiveTvManager.cs | 57 ++++++++++++++++++- .../LiveTv/RefreshChannelsScheduledTask.cs | 9 ++- .../Native/HttpClientFactory.cs | 7 ++- MediaBrowser.WebDashboard/ApiClient.js | 20 ++++++- .../MediaBrowser.WebDashboard.csproj | 4 +- MediaBrowser.WebDashboard/packages.config | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 26 files changed, 280 insertions(+), 81 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 2961c920f8..4cd75afca5 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -1,4 +1,5 @@ using System.Threading; +using System.Threading.Tasks; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; @@ -82,6 +83,22 @@ namespace MediaBrowser.Api.LiveTv public string UserId { get; set; } } + [Route("/LiveTv/Recordings/{Id}", "DELETE")] + [Api(Description = "Deletes a live tv recording")] + public class DeleteRecording : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Recording Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + + [Route("/LiveTv/Timers/{Id}", "DELETE")] + [Api(Description = "Cancels a live tv timer")] + public class CancelTimer : IReturnVoid + { + [ApiMember(Name = "Id", Description = "Timer Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + public class LiveTvService : BaseApiService { private readonly ILiveTvManager _liveTvManager; @@ -176,5 +193,19 @@ namespace MediaBrowser.Api.LiveTv return ToOptimizedResult(result); } + + public void Delete(DeleteRecording request) + { + var task = _liveTvManager.DeleteRecording(request.Id); + + Task.WaitAll(task); + } + + public void Delete(CancelTimer request) + { + var task = _liveTvManager.CancelTimer(request.Id); + + Task.WaitAll(task); + } } } \ No newline at end of file diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs index 2674529e51..d17a38e073 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTaskService.cs @@ -31,7 +31,8 @@ namespace MediaBrowser.Api.ScheduledTasks [Api(Description = "Gets scheduled tasks")] public class GetScheduledTasks : IReturn> { - + [ApiMember(Name = "IsHidden", Description = "Optional filter tasks that are hidden, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsHidden { get; set; } } /// @@ -112,10 +113,33 @@ namespace MediaBrowser.Api.ScheduledTasks /// IEnumerable{TaskInfo}. public object Get(GetScheduledTasks request) { - var result = TaskManager.ScheduledTasks.OrderBy(i => i.Name) - .Select(ScheduledTaskHelpers.GetTaskInfo).ToList(); + IEnumerable result = TaskManager.ScheduledTasks + .OrderBy(i => i.Name); - return ToOptimizedResult(result); + if (request.IsHidden.HasValue) + { + var val = request.IsHidden.Value; + + result = result.Where(i => + { + var isHidden = false; + + var configurableTask = i.ScheduledTask as IConfigurableScheduledTask; + + if (configurableTask != null) + { + isHidden = configurableTask.IsHidden; + } + + return isHidden == val; + }); + } + + var infos = result + .Select(ScheduledTaskHelpers.GetTaskInfo) + .ToList(); + + return ToOptimizedResult(infos); } /// diff --git a/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs b/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs index 20634301a3..c143635bfa 100644 --- a/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs +++ b/MediaBrowser.Api/ScheduledTasks/ScheduledTasksWebSocketListener.cs @@ -46,8 +46,10 @@ namespace MediaBrowser.Api.ScheduledTasks /// Task{IEnumerable{TaskInfo}}. protected override Task> GetDataToSend(object state) { - return Task.FromResult(TaskManager.ScheduledTasks.OrderBy(i => i.Name) - .Select(ScheduledTaskHelpers.GetTaskInfo)); + return Task.FromResult(TaskManager.ScheduledTasks + .OrderBy(i => i.Name) + .Select(ScheduledTaskHelpers.GetTaskInfo) + .Where(i => !i.IsHidden)); } } } diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 95bde2d283..23b8efa7bd 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -81,8 +81,11 @@ namespace MediaBrowser.Api [ApiMember(Name = "Season", Description = "Optional filter by season number.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public int? Season { get; set; } - [ApiMember(Name = "ExcludeLocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] - public string ExcludeLocationTypes { get; set; } + [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsMissing { get; set; } + + [ApiMember(Name = "IsVirtualUnaired", Description = "Optional filter by items that are virtual unaired episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsVirtualUnaired { get; set; } } [Route("/Shows/{Id}/Seasons", "GET")] @@ -106,11 +109,14 @@ namespace MediaBrowser.Api [ApiMember(Name = "Id", Description = "The series id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")] public Guid Id { get; set; } - [ApiMember(Name = "ExcludeLocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] - public string ExcludeLocationTypes { get; set; } - [ApiMember(Name = "IsSpecialSeason", Description = "Optional. Filter by special season.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsSpecialSeason { get; set; } + + [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsMissing { get; set; } + + [ApiMember(Name = "IsVirtualUnaired", Description = "Optional filter by items that are virtual unaired episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsVirtualUnaired { get; set; } } /// @@ -380,12 +386,7 @@ namespace MediaBrowser.Api } } - // ExcludeLocationTypes - if (!string.IsNullOrEmpty(request.ExcludeLocationTypes)) - { - var vals = request.ExcludeLocationTypes.Split(','); - seasons = seasons.Where(f => !vals.Contains(f.LocationType.ToString(), StringComparer.OrdinalIgnoreCase)); - } + seasons = FilterVirtualSeasons(request, seasons); seasons = _libraryManager.Sort(seasons, user, new[] { sortOrder }, SortOrder.Ascending) .Cast(); @@ -400,6 +401,34 @@ namespace MediaBrowser.Api }; } + private IEnumerable FilterVirtualSeasons(GetSeasons request, IEnumerable items) + { + if (request.IsMissing.HasValue && request.IsVirtualUnaired.HasValue) + { + var isMissing = request.IsMissing.Value; + var isVirtualUnaired = request.IsVirtualUnaired.Value; + + if (!isMissing && !isVirtualUnaired) + { + return items.Where(i => !i.IsMissingOrVirtualUnaired); + } + } + + if (request.IsMissing.HasValue) + { + var val = request.IsMissing.Value; + items = items.Where(i => i.IsMissingSeason == val); + } + + if (request.IsVirtualUnaired.HasValue) + { + var val = request.IsVirtualUnaired.Value; + items = items.Where(i => i.IsVirtualUnaired == val); + } + + return items; + } + public object Get(GetEpisodes request) { var user = _userManager.GetUserById(request.UserId); @@ -431,11 +460,16 @@ namespace MediaBrowser.Api episodes = episodes.Where(i => !i.IsVirtualUnaired); } - // ExcludeLocationTypes - if (!string.IsNullOrEmpty(request.ExcludeLocationTypes)) + if (request.IsMissing.HasValue) + { + var val = request.IsMissing.Value; + episodes = episodes.Where(i => i.IsMissingEpisode == val); + } + + if (request.IsVirtualUnaired.HasValue) { - var vals = request.ExcludeLocationTypes.Split(','); - episodes = episodes.Where(f => !vals.Contains(f.LocationType.ToString(), StringComparer.OrdinalIgnoreCase)); + var val = request.IsVirtualUnaired.Value; + episodes = episodes.Where(i => i.IsVirtualUnaired == val); } episodes = _libraryManager.Sort(episodes, user, new[] { sortOrder }, SortOrder.Ascending) diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index ee22b7baa2..f1d8c94e55 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -218,7 +218,7 @@ namespace MediaBrowser.Common.Implementations try { // Increase the max http request limit - ServicePointManager.DefaultConnectionLimit = Math.Max(48, ServicePointManager.DefaultConnectionLimit); + ServicePointManager.DefaultConnectionLimit = Math.Max(96, ServicePointManager.DefaultConnectionLimit); } catch (Exception ex) { diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 0d6ba5c1da..181c83fd3a 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Configuration; +using System.Reflection; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; using MediaBrowser.Model.Logging; diff --git a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs index e04cadfc5a..6d886bc696 100644 --- a/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs +++ b/MediaBrowser.Common.Implementations/ScheduledTasks/Tasks/DeleteCacheFileTask.cs @@ -29,7 +29,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks /// /// Initializes a new instance of the class. /// - /// The app paths. public DeleteCacheFileTask(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) { ApplicationPaths = appPaths; diff --git a/MediaBrowser.Common/ScheduledTasks/IScheduledTask.cs b/MediaBrowser.Common/ScheduledTasks/IScheduledTask.cs index 351e96c7d5..2ee4fb4b50 100644 --- a/MediaBrowser.Common/ScheduledTasks/IScheduledTask.cs +++ b/MediaBrowser.Common/ScheduledTasks/IScheduledTask.cs @@ -42,4 +42,9 @@ namespace MediaBrowser.Common.ScheduledTasks /// IEnumerable{BaseTaskTrigger}. IEnumerable GetDefaultTriggers(); } + + public interface IConfigurableScheduledTask + { + bool IsHidden { get; } + } } diff --git a/MediaBrowser.Common/ScheduledTasks/ScheduledTaskHelpers.cs b/MediaBrowser.Common/ScheduledTasks/ScheduledTaskHelpers.cs index f316509869..39148166bc 100644 --- a/MediaBrowser.Common/ScheduledTasks/ScheduledTaskHelpers.cs +++ b/MediaBrowser.Common/ScheduledTasks/ScheduledTaskHelpers.cs @@ -16,6 +16,15 @@ namespace MediaBrowser.Common.ScheduledTasks /// TaskInfo. public static TaskInfo GetTaskInfo(IScheduledTaskWorker task) { + var isHidden = false; + + var configurableTask = task.ScheduledTask as IConfigurableScheduledTask; + + if (configurableTask != null) + { + isHidden = configurableTask.IsHidden; + } + return new TaskInfo { Name = task.Name, @@ -25,7 +34,8 @@ namespace MediaBrowser.Common.ScheduledTasks LastExecutionResult = task.LastExecutionResult, Triggers = task.Triggers.Select(GetTriggerInfo).ToList(), Description = task.Description, - Category = task.Category + Category = task.Category, + IsHidden = isHidden }; } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 7938c38ec9..d5b9cea270 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -24,6 +24,20 @@ namespace MediaBrowser.Controller.LiveTv /// Task. Task ScheduleRecording(string programId); + /// + /// Deletes the recording. + /// + /// The identifier. + /// Task. + Task DeleteRecording(string id); + + /// + /// Cancels the timer. + /// + /// The identifier. + /// Task. + Task CancelTimer(string id); + /// /// Adds the parts. /// diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index e903ad5ec6..9bc032af35 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -47,14 +47,6 @@ namespace MediaBrowser.Controller.LiveTv /// Task. Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken); - /// - /// Updates the timer asynchronous. - /// - /// The information. - /// The cancellation token. - /// Task. - Task UpdateTimerAsync(TimerInfo info, CancellationToken cancellationToken); - /// /// Gets the channel image asynchronous. /// diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs index f0daac5f91..88d093f645 100644 --- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs +++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs @@ -40,6 +40,12 @@ namespace MediaBrowser.Controller.LiveTv /// public DateTime EndDate { get; set; } + /// + /// Gets or sets the program identifier. + /// + /// The program identifier. + public string ProgramId { get; set; } + /// /// Gets or sets the status. /// diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index f0f936b526..7401dafec9 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -1,6 +1,5 @@ using MediaBrowser.Model.LiveTv; using System; -using System.Collections.Generic; namespace MediaBrowser.Controller.LiveTv { @@ -21,6 +20,12 @@ namespace MediaBrowser.Controller.LiveTv /// public string ChannelName { get; set; } + /// + /// Gets or sets the program identifier. + /// + /// The program identifier. + public string ProgramId { get; set; } + /// /// Name of the recording. /// @@ -52,16 +57,5 @@ namespace MediaBrowser.Controller.LiveTv /// /// true if this instance is recurring; otherwise, false. public bool IsRecurring { get; set; } - - /// - /// Gets or sets the recurring days. - /// - /// The recurring days. - public List RecurringDays { get; set; } - - public TimerInfo() - { - RecurringDays = new List(); - } } } diff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.cs index b8af8f6e22..7789773407 100644 --- a/MediaBrowser.Model/LiveTv/RecordingStatus.cs +++ b/MediaBrowser.Model/LiveTv/RecordingStatus.cs @@ -10,4 +10,11 @@ namespace MediaBrowser.Model.LiveTv Conflicted, Deleted } + + public enum RecurrenceType + { + Manual, + NewProgramEvents, + AllProgramEvents + } } diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index 6a8339031a..ddefce59e2 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -1,11 +1,10 @@ using System; -using System.Collections.Generic; namespace MediaBrowser.Model.LiveTv { public class TimerInfoDto { - /// + /// /// Id of the recording. /// public string Id { get; set; } @@ -15,7 +14,7 @@ namespace MediaBrowser.Model.LiveTv /// /// The external identifier. public string ExternalId { get; set; } - + /// /// ChannelId of the recording. /// @@ -26,6 +25,12 @@ namespace MediaBrowser.Model.LiveTv /// public string ChannelName { get; set; } + /// + /// Gets or sets the program identifier. + /// + /// The program identifier. + public string ProgramId { get; set; } + /// /// Name of the recording. /// @@ -57,16 +62,5 @@ namespace MediaBrowser.Model.LiveTv /// /// true if this instance is recurring; otherwise, false. public bool IsRecurring { get; set; } - - /// - /// Gets or sets the recurring days. - /// - /// The recurring days. - public List RecurringDays { get; set; } - - public TimerInfoDto() - { - RecurringDays = new List(); - } - } + } } diff --git a/MediaBrowser.Model/Querying/EpisodeQuery.cs b/MediaBrowser.Model/Querying/EpisodeQuery.cs index 406ac9844f..56c50da7f7 100644 --- a/MediaBrowser.Model/Querying/EpisodeQuery.cs +++ b/MediaBrowser.Model/Querying/EpisodeQuery.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Model.Entities; - + namespace MediaBrowser.Model.Querying { public class EpisodeQuery @@ -8,7 +7,9 @@ namespace MediaBrowser.Model.Querying public string SeriesId { get; set; } - public LocationType[] ExcludeLocationTypes { get; set; } + public bool? IsMissing { get; set; } + + public bool? IsVirtualUnaired { get; set; } public int? SeasonNumber { get; set; } @@ -17,7 +18,6 @@ namespace MediaBrowser.Model.Querying public EpisodeQuery() { Fields = new ItemFields[] { }; - ExcludeLocationTypes = new LocationType[] { }; } } @@ -27,7 +27,9 @@ namespace MediaBrowser.Model.Querying public string SeriesId { get; set; } - public LocationType[] ExcludeLocationTypes { get; set; } + public bool? IsMissing { get; set; } + + public bool? IsVirtualUnaired { get; set; } public ItemFields[] Fields { get; set; } @@ -36,7 +38,6 @@ namespace MediaBrowser.Model.Querying public SeasonQuery() { Fields = new ItemFields[] { }; - ExcludeLocationTypes = new LocationType[] { }; } } } diff --git a/MediaBrowser.Model/Tasks/TaskInfo.cs b/MediaBrowser.Model/Tasks/TaskInfo.cs index dee4fea7fc..a7d500303d 100644 --- a/MediaBrowser.Model/Tasks/TaskInfo.cs +++ b/MediaBrowser.Model/Tasks/TaskInfo.cs @@ -56,6 +56,12 @@ namespace MediaBrowser.Model.Tasks /// The category. public string Category { get; set; } + /// + /// Gets or sets a value indicating whether this instance is hidden. + /// + /// true if this instance is hidden; otherwise, false. + public bool IsHidden { get; set; } + /// /// Initializes a new instance of the class. /// diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 00ac83f15c..4d3d877889 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -397,6 +397,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv Status = info.Status }; + if (!string.IsNullOrEmpty(info.ProgramId)) + { + dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N"); + } + return dto; } @@ -503,13 +508,61 @@ namespace MediaBrowser.Server.Implementations.LiveTv ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, - IsRecurring = info.IsRecurring, - RecurringDays = info.RecurringDays + IsRecurring = info.IsRecurring }; + if (!string.IsNullOrEmpty(info.ProgramId)) + { + dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N"); + } + return dto; } + public async Task DeleteRecording(string recordingId) + { + var recordings = await GetRecordings(new RecordingQuery + { + + }, CancellationToken.None).ConfigureAwait(false); + + var recording = recordings.Items + .FirstOrDefault(i => string.Equals(recordingId, i.Id, StringComparison.OrdinalIgnoreCase)); + + if (recording == null) + { + throw new ResourceNotFoundException(string.Format("Recording with Id {0} not found", recordingId)); + } + + var channel = GetChannel(recording.ChannelId); + var service = GetServices(channel.ServiceName, null) + .First(); + + await service.DeleteRecordingAsync(recording.ExternalId, CancellationToken.None).ConfigureAwait(false); + } + + public async Task CancelTimer(string id) + { + var timers = await GetTimers(new TimerQuery + { + + }, CancellationToken.None).ConfigureAwait(false); + + var timer = timers.Items + .FirstOrDefault(i => string.Equals(id, i.Id, StringComparison.OrdinalIgnoreCase)); + + if (timer == null) + { + throw new ResourceNotFoundException(string.Format("Timer with Id {0} not found", id)); + } + + var channel = GetChannel(timer.ChannelId); + + var service = GetServices(channel.ServiceName, null) + .First(); + + await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index c3803d9bbc..00bf9e55ba 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.LiveTv { - class RefreshChannelsScheduledTask : IScheduledTask + class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask { private readonly ILiveTvManager _liveTvManager; @@ -33,7 +33,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress progress) { - var manager = (LiveTvManager) _liveTvManager; + var manager = (LiveTvManager)_liveTvManager; return manager.RefreshChannels(progress, cancellationToken); } @@ -50,5 +50,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv new IntervalTrigger{ Interval = TimeSpan.FromHours(2)} }; } + + public bool IsHidden + { + get { return _liveTvManager.Services.Count == 0; } + } } } diff --git a/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs index 57f00ba03b..368c60254b 100644 --- a/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs +++ b/MediaBrowser.ServerApplication/Native/HttpClientFactory.cs @@ -17,14 +17,19 @@ namespace MediaBrowser.ServerApplication.Native /// HttpClient. public static HttpClient GetHttpClient(bool enableHttpCompression) { - return new HttpClient(new WebRequestHandler + var client = new HttpClient(new WebRequestHandler { CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate), AutomaticDecompression = enableHttpCompression ? DecompressionMethods.Deflate : DecompressionMethods.None + }) { Timeout = TimeSpan.FromSeconds(20) }; + + client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); + + return client; } } } diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js index 36476511ec..de96c4de94 100644 --- a/MediaBrowser.WebDashboard/ApiClient.js +++ b/MediaBrowser.WebDashboard/ApiClient.js @@ -506,6 +506,20 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi }); }; + self.createLiveTvTimer = function (options) { + + if (!options) { + throw new Error("null options"); + } + + var url = self.getUrl("LiveTv/Timers", options); + + return self.ajax({ + type: "POST", + url: url + }); + }; + /** * Gets the current server status */ @@ -1019,9 +1033,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi /** * Gets the server's scheduled tasks */ - self.getScheduledTasks = function () { + self.getScheduledTasks = function (options) { - var url = self.getUrl("ScheduledTasks"); + options = options || {}; + + var url = self.getUrl("ScheduledTasks", options); return self.ajax({ type: "GET", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 5585e0db5e..4aca619aa3 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -284,10 +284,10 @@ PreserveNewest - + PreserveNewest - + PreserveNewest diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index 25938a358a..a839ece186 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 51bdf43d66..77765ddc62 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.252 + 3.0.253 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 6ccfca542e..ac6b606cda 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.252 + 3.0.253 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index de9b90a461..a6c1bee112 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.252 + 3.0.253 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From 0c398a567041e5de37837b71f16d00fbc2913d3c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Nov 2013 13:44:51 -0500 Subject: added create live tv timer page --- MediaBrowser.Model/LiveTv/ChannelInfoDto.cs | 19 +++++++++++++------ .../LiveTv/LiveTvManager.cs | 8 +++++++- MediaBrowser.WebDashboard/Api/DashboardService.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 6 ++++++ 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs index f1d550e77a..020771e5ee 100644 --- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs @@ -1,5 +1,7 @@ -using System; -using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; namespace MediaBrowser.Model.LiveTv { @@ -19,12 +21,12 @@ namespace MediaBrowser.Model.LiveTv /// /// The identifier. public string Id { get; set; } - + /// - /// Gets or sets the logo image tag. + /// Gets or sets the image tags. /// - /// The logo image tag. - public Guid? PrimaryImageTag { get; set; } + /// The image tags. + public Dictionary ImageTags { get; set; } /// /// Gets or sets the number. @@ -61,5 +63,10 @@ namespace MediaBrowser.Model.LiveTv /// /// The user data. public UserItemDataDto UserData { get; set; } + + public ChannelInfoDto() + { + ImageTags = new Dictionary(); + } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 4d3d877889..688a4cc647 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -87,7 +87,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv ServiceName = info.ServiceName, ChannelType = info.ChannelType, Number = info.ChannelNumber, - PrimaryImageTag = GetLogoImageTag(info), Type = info.GetType().Name, Id = info.Id.ToString("N"), MediaType = info.MediaType @@ -98,6 +97,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, info.GetUserDataKey())); } + var imageTag = GetLogoImageTag(info); + + if (imageTag.HasValue) + { + dto.ImageTags[ImageType.Primary] = imageTag.Value; + } + return dto; } diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 69f05631f3..9076777a5b 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -483,6 +483,7 @@ namespace MediaBrowser.WebDashboard.Api "livetvchannels.js", "livetvguide.js", "livetvrecordings.js", + "livetvtimer.js", "livetvtimers.js", "loginpage.js", "logpage.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 4aca619aa3..73b281d9a4 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -347,6 +347,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest -- cgit v1.2.3 From 7ef1816b340d273280effa18fe7543d13baf9c8a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Nov 2013 15:10:31 -0500 Subject: add links to channel pages --- MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 688a4cc647..dc68670d2b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -213,9 +213,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } - private Guid GetInternalChannelId(string serviceName, string externalChannelId) + private Guid GetInternalChannelId(string serviceName, string externalChannelId, string channelName) { - var name = serviceName + externalChannelId; + var name = serviceName + externalChannelId + channelName; return name.ToLower().GetMBId(typeof(Channel)); } @@ -248,7 +248,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv isNew = true; } - var id = GetInternalChannelId(serviceName, channelInfo.Id); + var id = GetInternalChannelId(serviceName, channelInfo.Id, channelInfo.Name); var item = _itemRepo.RetrieveItem(id) as Channel; @@ -399,7 +399,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv StartDate = info.StartDate, Id = id, ExternalId = info.Id, - ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), + ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status }; @@ -512,7 +512,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv StartDate = info.StartDate, Id = id, ExternalId = info.Id, - ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), + ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, IsRecurring = info.IsRecurring }; -- cgit v1.2.3 From 9b9e5fc4e48aa8d2595691b5cf0c3354f723726a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 29 Nov 2013 16:28:12 -0500 Subject: added timer properties for pre/post padding seconds --- MediaBrowser.Controller/LiveTv/TimerInfo.cs | 12 ++++++++++++ MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 12 ++++++++++++ MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 4 +++- 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 7401dafec9..624dc62cab 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -57,5 +57,17 @@ namespace MediaBrowser.Controller.LiveTv /// /// true if this instance is recurring; otherwise, false. public bool IsRecurring { get; set; } + + /// + /// Gets or sets the pre padding seconds. + /// + /// The pre padding seconds. + public int PrePaddingSeconds { get; set; } + + /// + /// Gets or sets the post padding seconds. + /// + /// The post padding seconds. + public int PostPaddingSeconds { get; set; } } } diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index ddefce59e2..5d8ac20c45 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -62,5 +62,17 @@ namespace MediaBrowser.Model.LiveTv /// /// true if this instance is recurring; otherwise, false. public bool IsRecurring { get; set; } + + /// + /// Gets or sets the pre padding seconds. + /// + /// The pre padding seconds. + public int PrePaddingSeconds { get; set; } + + /// + /// Gets or sets the post padding seconds. + /// + /// The post padding seconds. + public int PostPaddingSeconds { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index dc68670d2b..b55393213c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -514,7 +514,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, - IsRecurring = info.IsRecurring + IsRecurring = info.IsRecurring, + PrePaddingSeconds = info.PrePaddingSeconds, + PostPaddingSeconds = info.PostPaddingSeconds }; if (!string.IsNullOrEmpty(info.ProgramId)) -- cgit v1.2.3 From 45a4d25e2615e5ec05befc61560ad54b419504eb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Nov 2013 01:49:38 -0500 Subject: updated live tv methods + nuget --- .../HttpClientManager/HttpClientManager.cs | 13 ++-- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 7 +++ .../LiveTv/RecurringTimerInfo.cs | 73 ++++++++++++++++++++++ MediaBrowser.Controller/LiveTv/TimerInfo.cs | 12 ++-- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Model/LiveTv/RecordingStatus.cs | 6 +- MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 6 +- .../LiveTv/LiveTvManager.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index ea1a5c7266..8d80185add 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -24,6 +24,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// public class HttpClientManager : IHttpClient { + /// + /// When one request to a host times out, we'll ban all other requests for this period of time, to prevent scans from stalling + /// + private int TimeoutSeconds = 30; + /// /// The _logger /// @@ -122,13 +127,13 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.UserAgent = options.UserAgent; } + // This is a hack to prevent KeepAlive from getting disabled internally by the HttpWebRequest + // May need to remove this for mono var sp = request.ServicePoint; - if (_httpBehaviorPropertyInfo == null) { _httpBehaviorPropertyInfo = sp.GetType().GetProperty("HttpBehaviour", BindingFlags.Instance | BindingFlags.NonPublic); } - _httpBehaviorPropertyInfo.SetValue(sp, (byte)0, null); return request; @@ -150,7 +155,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression); - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < TimeoutSeconds) { throw new HttpException(string.Format("Cancelling connection to {0} due to a previous timeout.", options.Url)) { IsTimedOut = true }; } @@ -162,7 +167,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); } - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < TimeoutSeconds) { if (options.ResourcePool != null) { diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 9bc032af35..2b58d8bc56 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -68,6 +68,13 @@ namespace MediaBrowser.Controller.LiveTv /// The cancellation token. /// Task{IEnumerable{RecordingInfo}}. Task> GetTimersAsync(CancellationToken cancellationToken); + + /// + /// Gets the recurring timers asynchronous. + /// + /// The cancellation token. + /// Task{IEnumerable{RecurringTimerInfo}}. + Task> GetRecurringTimersAsync(CancellationToken cancellationToken); /// /// Gets the programs asynchronous. diff --git a/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs new file mode 100644 index 0000000000..08a8b1f92f --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs @@ -0,0 +1,73 @@ +using MediaBrowser.Model.LiveTv; +using System; + +namespace MediaBrowser.Controller.LiveTv +{ + public class RecurringTimerInfo + { + /// + /// Id of the recording. + /// + public string Id { get; set; } + + /// + /// ChannelId of the recording. + /// + public string ChannelId { get; set; } + + /// + /// ChannelName of the recording. + /// + public string ChannelName { get; set; } + + /// + /// Gets or sets the program identifier. + /// + /// The program identifier. + public string ProgramId { get; set; } + + /// + /// Name of the recording. + /// + public string Name { get; set; } + + /// + /// Description of the recording. + /// + public string Description { get; set; } + + /// + /// The start date of the recording, in UTC. + /// + public DateTime StartDate { get; set; } + + /// + /// The end date of the recording, in UTC. + /// + public DateTime EndDate { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public RecordingStatus Status { get; set; } + + /// + /// Gets or sets the pre padding seconds. + /// + /// The pre padding seconds. + public int PrePaddingSeconds { get; set; } + + /// + /// Gets or sets the post padding seconds. + /// + /// The post padding seconds. + public int PostPaddingSeconds { get; set; } + + /// + /// Gets or sets the type of the recurrence. + /// + /// The type of the recurrence. + public RecurrenceType RecurrenceType { get; set; } + } +} diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 624dc62cab..0fe7c34f2d 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -10,6 +10,12 @@ namespace MediaBrowser.Controller.LiveTv /// public string Id { get; set; } + /// + /// Gets or sets the recurring timer identifier. + /// + /// The recurring timer identifier. + public string RecurringTimerId { get; set; } + /// /// ChannelId of the recording. /// @@ -52,12 +58,6 @@ namespace MediaBrowser.Controller.LiveTv /// The status. public RecordingStatus Status { get; set; } - /// - /// Gets or sets a value indicating whether this instance is recurring. - /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } - /// /// Gets or sets the pre padding seconds. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 2068fccf83..ec0439c2c7 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,6 +110,7 @@ + diff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.cs index 7789773407..08a7cfb0c2 100644 --- a/MediaBrowser.Model/LiveTv/RecordingStatus.cs +++ b/MediaBrowser.Model/LiveTv/RecordingStatus.cs @@ -14,7 +14,9 @@ namespace MediaBrowser.Model.LiveTv public enum RecurrenceType { Manual, - NewProgramEvents, - AllProgramEvents + NewProgramEventsOneChannel, + AllProgramEventsOneChannel, + NewProgramEventsAllChannels, + AllProgramEventsAllChannels } } diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index 5d8ac20c45..f7d63e9687 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -58,10 +58,10 @@ namespace MediaBrowser.Model.LiveTv public RecordingStatus Status { get; set; } /// - /// Gets or sets a value indicating whether this instance is recurring. + /// Gets or sets the recurring timer identifier. /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } + /// The recurring timer identifier. + public string RecurringTimerId { get; set; } /// /// Gets or sets the pre padding seconds. diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index b55393213c..ea8ea45b69 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -514,7 +514,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, - IsRecurring = info.IsRecurring, + RecurringTimerId = info.RecurringTimerId, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds }; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 77765ddc62..17311530fa 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.253 + 3.0.254 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index ac6b606cda..e95a638ab8 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.253 + 3.0.254 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index a6c1bee112..38bb37530e 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.253 + 3.0.254 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From 58f1a314b5ef3d13c2bc034f8a8949d9e88d1c20 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Nov 2013 13:32:39 -0500 Subject: update to service stack 3.0.70.0 --- MediaBrowser.Api/MediaBrowser.Api.csproj | 21 ++-- MediaBrowser.Api/TvShowsService.cs | 23 ++++- MediaBrowser.Api/packages.config | 4 +- .../HttpClientManager/HttpClientManager.cs | 112 ++++----------------- .../MediaBrowser.Common.Implementations.csproj | 7 +- .../Serialization/JsonSerializer.cs | 2 + .../packages.config | 2 +- MediaBrowser.Common/MediaBrowser.Common.csproj | 21 ++-- MediaBrowser.Common/packages.config | 4 +- MediaBrowser.Model/Querying/EpisodeQuery.cs | 2 + MediaBrowser.Model/System/SystemInfo.cs | 12 +++ .../MediaBrowser.Server.Implementations.csproj | 60 +++++------ .../packages.config | 10 +- .../swagger-ui/index.html | 2 +- MediaBrowser.ServerApplication/ApplicationHost.cs | 2 + .../MediaBrowser.ServerApplication.csproj | 20 ++-- MediaBrowser.ServerApplication/packages.config | 6 +- .../MediaBrowser.WebDashboard.csproj | 21 ++-- MediaBrowser.WebDashboard/packages.config | 4 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 22 files changed, 155 insertions(+), 190 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index a5720dfad1..706117fc26 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -38,6 +38,18 @@ Always + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + @@ -47,15 +59,6 @@ ..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll - - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 23b8efa7bd..9191bfc0c7 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -81,6 +81,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "Season", Description = "Optional filter by season number.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public int? Season { get; set; } + [ApiMember(Name = "SeasonId", Description = "Optional. Filter by season id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string SeasonId { get; set; } + [ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsMissing { get; set; } @@ -442,7 +445,25 @@ namespace MediaBrowser.Api var sortOrder = ItemSortBy.SortName; - if (request.Season.HasValue) + if (!string.IsNullOrEmpty(request.SeasonId)) + { + var season = _libraryManager.GetItemById(request.Id) as Season; + + if (season.IndexNumber.HasValue) + { + episodes = FilterEpisodesBySeason(episodes, season.IndexNumber.Value, true); + + sortOrder = ItemSortBy.AiredEpisodeOrder; + } + else + { + episodes = season.RecursiveChildren.OfType(); + + sortOrder = ItemSortBy.SortName; + } + } + + else if (request.Season.HasValue) { episodes = FilterEpisodesBySeason(episodes, request.Season.Value, true); diff --git a/MediaBrowser.Api/packages.config b/MediaBrowser.Api/packages.config index c9fec81005..e9a27e8ad8 100644 --- a/MediaBrowser.Api/packages.config +++ b/MediaBrowser.Api/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 8d80185add..8fccb7c2a9 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// /// When one request to a host times out, we'll ban all other requests for this period of time, to prevent scans from stalling /// - private int TimeoutSeconds = 30; + private const int TimeoutSeconds = 30; /// /// The _logger @@ -42,16 +42,14 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager private readonly IFileSystem _fileSystem; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The app paths. /// The logger. - /// The get HTTP client handler. - /// - /// appPaths + /// The file system. + /// appPaths /// or - /// logger - /// + /// logger public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem) { if (appPaths == null) @@ -143,7 +141,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// Gets the response internal. /// /// The options. - /// The HTTP method. /// Task{HttpResponseInfo}. /// /// @@ -490,27 +487,19 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } catch (OperationCanceledException ex) { - var exception = GetCancellationException(options.Url, options.CancellationToken, ex); - - throw exception; + throw GetTempFileException(ex, options, tempFile); } catch (HttpRequestException ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw new HttpException(ex.Message, ex); + throw GetTempFileException(ex, options, tempFile); } catch (WebException ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw new HttpException(ex.Message, ex); + throw GetTempFileException(ex, options, tempFile); } catch (Exception ex) { - _logger.ErrorException("Error getting response from " + options.Url, ex); - - throw; + throw GetTempFileException(ex, options, tempFile); } finally { @@ -521,65 +510,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } } - /// - /// Gets the message. - /// - /// The options. - /// HttpResponseMessage. - private HttpRequestMessage GetHttpRequestMessage(HttpRequestOptions options) - { - var message = new HttpRequestMessage(HttpMethod.Get, options.Url); - - foreach (var pair in options.RequestHeaders.ToList()) - { - if (!message.Headers.TryAddWithoutValidation(pair.Key, pair.Value)) - { - _logger.Error("Unable to add request header {0} with value {1}", pair.Key, pair.Value); - } - } - - return message; - } - - /// - /// Gets the length of the content. - /// - /// The response. - /// System.Nullable{System.Int64}. - private long? GetContentLength(HttpResponseMessage response) - { - IEnumerable lengthValues = null; - - // Seeing some InvalidOperationException here under mono - try - { - response.Headers.TryGetValues("content-length", out lengthValues); - } - catch (InvalidOperationException ex) - { - _logger.ErrorException("Error accessing response.Headers.TryGetValues Content-Length", ex); - } - - if (lengthValues == null) - { - try - { - response.Content.Headers.TryGetValues("content-length", out lengthValues); - } - catch (InvalidOperationException ex) - { - _logger.ErrorException("Error accessing response.Content.Headers.TryGetValues Content-Length", ex); - } - } - - if (lengthValues == null) - { - return null; - } - - return long.Parse(string.Join(string.Empty, lengthValues.ToArray()), UsCulture); - } - private long? GetContentLength(HttpWebResponse response) { var length = response.ContentLength; @@ -616,16 +546,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager _logger.ErrorException("Error getting response from " + options.Url, ex); - var httpRequestException = ex as HttpRequestException; - // Cleanup DeleteTempFile(tempFile); + var httpRequestException = ex as HttpRequestException; + if (httpRequestException != null) { return new HttpException(ex.Message, ex); } + var webException = ex as WebException; + + if (webException != null) + { + return new HttpException(ex.Message, ex); + } + return ex; } @@ -711,19 +648,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager return exception; } - /// - /// Ensures the success status code. - /// - /// The response. - /// - private void EnsureSuccessStatusCode(HttpResponseMessage response) - { - if (!response.IsSuccessStatusCode) - { - throw new HttpException(response.ReasonPhrase) { StatusCode = response.StatusCode }; - } - } - private void EnsureSuccessStatusCode(HttpWebResponse response) { var statusCode = response.StatusCode; diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index 9e48f3b3e9..9487855756 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -41,6 +41,10 @@ False ..\packages\NLog.2.1.0\lib\net45\NLog.dll + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + ..\packages\sharpcompress.0.10.1.3\lib\net40\SharpCompress.dll @@ -55,9 +59,6 @@ - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - diff --git a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs index 4a6b9255c1..3ff9560405 100644 --- a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs +++ b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs @@ -169,6 +169,8 @@ namespace MediaBrowser.Common.Implementations.Serialization ServiceStack.Text.JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601; ServiceStack.Text.JsConfig.ExcludeTypeInfo = true; ServiceStack.Text.JsConfig.IncludeNullValues = false; + ServiceStack.Text.JsConfig.AlwaysUseUtc = true; + ServiceStack.Text.JsConfig.AssumeUtc = true; } /// diff --git a/MediaBrowser.Common.Implementations/packages.config b/MediaBrowser.Common.Implementations/packages.config index f2fe488309..269ac0e561 100644 --- a/MediaBrowser.Common.Implementations/packages.config +++ b/MediaBrowser.Common.Implementations/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index f4d759a4d1..a9499dedda 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -35,18 +35,21 @@ 4 - - - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + + + diff --git a/MediaBrowser.Common/packages.config b/MediaBrowser.Common/packages.config index 6969b43c54..7411e313cd 100644 --- a/MediaBrowser.Common/packages.config +++ b/MediaBrowser.Common/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/MediaBrowser.Model/Querying/EpisodeQuery.cs b/MediaBrowser.Model/Querying/EpisodeQuery.cs index 56c50da7f7..589b46433a 100644 --- a/MediaBrowser.Model/Querying/EpisodeQuery.cs +++ b/MediaBrowser.Model/Querying/EpisodeQuery.cs @@ -5,6 +5,8 @@ namespace MediaBrowser.Model.Querying { public string UserId { get; set; } + public string SeasonId { get; set; } + public string SeriesId { get; set; } public bool? IsMissing { get; set; } diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs index 9491139dbc..6a17ad133a 100644 --- a/MediaBrowser.Model/System/SystemInfo.cs +++ b/MediaBrowser.Model/System/SystemInfo.cs @@ -92,6 +92,18 @@ namespace MediaBrowser.Model.System /// The program data path. public string ProgramDataPath { get; set; } + /// + /// Gets or sets the items by name path. + /// + /// The items by name path. + public string ItemsByNamePath { get; set; } + + /// + /// Gets or sets the log path. + /// + /// The log path. + public string LogPath { get; set; } + /// /// Gets or sets the HTTP server port number. /// diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index f5ade2516c..2d32811d33 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -41,8 +41,29 @@ False ..\packages\MediaBrowser.BdInfo.1.0.0.5\lib\net20\BDInfo.dll - - ..\packages\ServiceStack.OrmLite.Sqlite32.3.9.63\lib\net40\ServiceStack.OrmLite.SqliteNET.dll + + False + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.dll + + + False + ..\packages\ServiceStack.Api.Swagger.3.9.70\lib\net35\ServiceStack.Api.Swagger.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + + False + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.ServiceInterface.dll + + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll @@ -72,39 +93,12 @@ ..\packages\morelinq.1.0.16006\lib\net35\MoreLinq.dll - - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.dll - - - ..\packages\ServiceStack.Api.Swagger.3.9.59\lib\net35\ServiceStack.Api.Swagger.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll - ..\packages\ServiceStack.OrmLite.SqlServer.3.9.43\lib\ServiceStack.OrmLite.SqlServer.dll ..\packages\ServiceStack.Redis.3.9.43\lib\net35\ServiceStack.Redis.dll - - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.ServiceInterface.dll - - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.64\lib\net35\Mono.Data.Sqlite.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.64\lib\net35\ServiceStack.OrmLite.dll - - - ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.64\lib\net35\ServiceStack.OrmLite.Sqlite.dll - @@ -268,7 +262,6 @@ - PreserveNewest @@ -287,9 +280,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest @@ -323,6 +313,10 @@ PreserveNewest + + + PreserveNewest + diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index eeeedfe362..d5abe58caf 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -6,13 +6,11 @@ - - - - - + + + - + \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/swagger-ui/index.html b/MediaBrowser.Server.Implementations/swagger-ui/index.html index 0fcc069596..49f983a723 100644 --- a/MediaBrowser.Server.Implementations/swagger-ui/index.html +++ b/MediaBrowser.Server.Implementations/swagger-ui/index.html @@ -20,7 +20,7 @@ $(function () { window.swaggerUi = new SwaggerUi({ discoveryUrl: "../resources", - apiKey:"special-key", + apiKey: "special-key", dom_id:"swagger-ui-container", supportHeaderParams: false, supportedSubmitMethods: ['get', 'post', 'put'], diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index be865881af..d2d700839e 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -609,6 +609,8 @@ namespace MediaBrowser.ServerApplication CompletedInstallations = InstallationManager.CompletedInstallations.ToList(), Id = _systemId, ProgramDataPath = ApplicationPaths.ProgramDataPath, + LogPath = ApplicationPaths.LogDirectoryPath, + ItemsByNamePath = ApplicationPaths.ItemsByNamePath, MacAddress = GetMacAddress(), HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber, OperatingSystem = Environment.OSVersion.ToString(), diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 795799ca3e..5f05bc7875 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -131,17 +131,17 @@ False ..\packages\MediaBrowser.IsoMounting.3.0.65\lib\net45\pfmclrapi.dll - + False - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.dll + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.dll - + False - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll - + False - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll ..\packages\ServiceStack.OrmLite.SqlServer.3.9.44\lib\ServiceStack.OrmLite.SqlServer.dll @@ -149,13 +149,13 @@ ..\packages\ServiceStack.Redis.3.9.44\lib\net35\ServiceStack.Redis.dll - + False - ..\packages\ServiceStack.3.9.62\lib\net35\ServiceStack.ServiceInterface.dll + ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.ServiceInterface.dll - + False - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll False diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index e01ca1f672..5d7c3265f3 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -3,10 +3,10 @@ - - + + - + \ No newline at end of file diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 73b281d9a4..d36413fc2b 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -37,21 +37,24 @@ Always + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll + + + False + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + + False + ..\packages\ServiceStack.Text.3.9.70\lib\net35\ServiceStack.Text.dll + - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll - - - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll - - - ..\packages\ServiceStack.Text.3.9.62\lib\net35\ServiceStack.Text.dll - diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config index a839ece186..4fa4e5a9ec 100644 --- a/MediaBrowser.WebDashboard/packages.config +++ b/MediaBrowser.WebDashboard/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 17311530fa..150b081dc4 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.254 + 3.0.255 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index e95a638ab8..c28fa7922b 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.254 + 3.0.255 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 38bb37530e..32f1da5365 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.254 + 3.0.255 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From ccd51222e65cbc6faa409e4269bc5795bfd0f0ae Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 1 Dec 2013 01:25:19 -0500 Subject: updated live tv endpoints --- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 22 ++++++- .../LiveTv/RecurringTimerInfo.cs | 73 ---------------------- MediaBrowser.Controller/LiveTv/TimerInfo.cs | 6 +- .../MediaBrowser.Controller.csproj | 2 +- MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 6 +- .../Library/ResolverHelper.cs | 5 +- .../LiveTv/LiveTvManager.cs | 2 +- MediaBrowser.WebDashboard/Api/DashboardService.cs | 1 + .../MediaBrowser.WebDashboard.csproj | 7 ++- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 12 files changed, 42 insertions(+), 92 deletions(-) delete mode 100644 MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 2b58d8bc56..1627ad400f 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -47,6 +47,22 @@ namespace MediaBrowser.Controller.LiveTv /// Task. Task CreateTimerAsync(TimerInfo info, CancellationToken cancellationToken); + /// + /// Creates the series timer asynchronous. + /// + /// The information. + /// The cancellation token. + /// Task. + Task CreateSeriesTimerAsync(SeriesTimerInfo info, CancellationToken cancellationToken); + + /// + /// Updates the series timer asynchronous. + /// + /// The information. + /// The cancellation token. + /// Task. + Task UpdateSeriesTimerAsync(SeriesTimerInfo info, CancellationToken cancellationToken); + /// /// Gets the channel image asynchronous. /// @@ -70,11 +86,11 @@ namespace MediaBrowser.Controller.LiveTv Task> GetTimersAsync(CancellationToken cancellationToken); /// - /// Gets the recurring timers asynchronous. + /// Gets the series timers asynchronous. /// /// The cancellation token. - /// Task{IEnumerable{RecurringTimerInfo}}. - Task> GetRecurringTimersAsync(CancellationToken cancellationToken); + /// Task{IEnumerable{SeriesTimerInfo}}. + Task> GetSeriesTimersAsync(CancellationToken cancellationToken); /// /// Gets the programs asynchronous. diff --git a/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs deleted file mode 100644 index 08a8b1f92f..0000000000 --- a/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs +++ /dev/null @@ -1,73 +0,0 @@ -using MediaBrowser.Model.LiveTv; -using System; - -namespace MediaBrowser.Controller.LiveTv -{ - public class RecurringTimerInfo - { - /// - /// Id of the recording. - /// - public string Id { get; set; } - - /// - /// ChannelId of the recording. - /// - public string ChannelId { get; set; } - - /// - /// ChannelName of the recording. - /// - public string ChannelName { get; set; } - - /// - /// Gets or sets the program identifier. - /// - /// The program identifier. - public string ProgramId { get; set; } - - /// - /// Name of the recording. - /// - public string Name { get; set; } - - /// - /// Description of the recording. - /// - public string Description { get; set; } - - /// - /// The start date of the recording, in UTC. - /// - public DateTime StartDate { get; set; } - - /// - /// The end date of the recording, in UTC. - /// - public DateTime EndDate { get; set; } - - /// - /// Gets or sets the status. - /// - /// The status. - public RecordingStatus Status { get; set; } - - /// - /// Gets or sets the pre padding seconds. - /// - /// The pre padding seconds. - public int PrePaddingSeconds { get; set; } - - /// - /// Gets or sets the post padding seconds. - /// - /// The post padding seconds. - public int PostPaddingSeconds { get; set; } - - /// - /// Gets or sets the type of the recurrence. - /// - /// The type of the recurrence. - public RecurrenceType RecurrenceType { get; set; } - } -} diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 0fe7c34f2d..3df0b8ccab 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -11,10 +11,10 @@ namespace MediaBrowser.Controller.LiveTv public string Id { get; set; } /// - /// Gets or sets the recurring timer identifier. + /// Gets or sets the series timer identifier. /// - /// The recurring timer identifier. - public string RecurringTimerId { get; set; } + /// The series timer identifier. + public string SeriesTimerId { get; set; } /// /// ChannelId of the recording. diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index ec0439c2c7..a309d815c3 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,7 +110,7 @@ - + diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index f7d63e9687..59a320bfda 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -58,10 +58,10 @@ namespace MediaBrowser.Model.LiveTv public RecordingStatus Status { get; set; } /// - /// Gets or sets the recurring timer identifier. + /// Gets or sets the series timer identifier. /// - /// The recurring timer identifier. - public string RecurringTimerId { get; set; } + /// The series timer identifier. + public string SeriesTimerId { get; set; } /// /// Gets or sets the pre padding seconds. diff --git a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs index 620bcaee4a..e32fcd627b 100644 --- a/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs +++ b/MediaBrowser.Server.Implementations/Library/ResolverHelper.cs @@ -1,11 +1,11 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; using System; using System.IO; +using System.Linq; using System.Text.RegularExpressions; namespace MediaBrowser.Server.Implementations.Library @@ -48,7 +48,8 @@ namespace MediaBrowser.Server.Implementations.Library // Make sure the item has a name EnsureName(item); - item.DontFetchMeta = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1; + item.DontFetchMeta = item.Path.IndexOf("[dontfetchmeta]", StringComparison.OrdinalIgnoreCase) != -1 || + item.Parents.Any(i => i.DontFetchMeta); // Make sure DateCreated and DateModified have values EntityResolutionHelper.EnsureDates(fileSystem, item, args, true); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index ea8ea45b69..261c915cb2 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -514,7 +514,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, - RecurringTimerId = info.RecurringTimerId, + SeriesTimerId = info.SeriesTimerId, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds }; diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index 9076777a5b..17508b2bdc 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -482,6 +482,7 @@ namespace MediaBrowser.WebDashboard.Api "livetvchannel.js", "livetvchannels.js", "livetvguide.js", + "livetvrecording.js", "livetvrecordings.js", "livetvtimer.js", "livetvtimers.js", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index d36413fc2b..e9a70ad973 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -92,6 +92,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -353,6 +356,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -1214,7 +1220,6 @@ - diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 150b081dc4..946ec617bd 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.255 + 3.0.256 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index c28fa7922b..04ac3559c0 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.255 + 3.0.256 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 32f1da5365..d813a00ace 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.255 + 3.0.256 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From e191836ea0405c5a152a742fc5526d8ceb5c5db5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 1 Dec 2013 13:58:06 -0500 Subject: fix tmdbid override for movies --- .../Library/Resolvers/Movies/MovieResolver.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 07beabb832..03e29dd38f 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -172,7 +172,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies private void SetProviderIdFromPath(Video item) { //we need to only look at the name of this actual item (not parents) - var justName = Path.GetFileName(item.Path); + var justName = item.IsInMixedFolder ? Path.GetFileName(item.Path) : Path.GetFileName(Path.GetDirectoryName(item.Path)); var id = justName.GetAttributeValue("tmdbid"); -- cgit v1.2.3 From ad52d8b5d96bea85c17f37da7ff3334164f8d4a4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 1 Dec 2013 21:24:14 -0500 Subject: fixes #640 - Add management filters --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 100 +++++++++++++++++++++ MediaBrowser.Controller/Entities/BaseItem.cs | 1 + MediaBrowser.Controller/Entities/Video.cs | 5 +- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Controller/Providers/NameParser.cs | 39 ++++++++ MediaBrowser.Mono.userprefs | 21 +++-- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 33 +------ .../Movies/OpenMovieDatabaseProvider.cs | 12 +-- .../MediaBrowser.Server.Implementations.csproj | 11 +++ .../packages.config | 1 + .../MediaBrowser.Server.Mono.csproj | 7 +- .../Native/HttpClientFactory.cs | 24 ----- .../Providers/MovieDbProviderTests.cs | 13 +-- 13 files changed, 183 insertions(+), 85 deletions(-) create mode 100644 MediaBrowser.Controller/Providers/NameParser.cs delete mode 100644 MediaBrowser.Server.Mono/Native/HttpClientFactory.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index cae74cc2f4..d6f3488361 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.IO; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -6,6 +7,7 @@ using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using ServiceStack.ServiceHost; @@ -212,6 +214,21 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "MaxPremiereDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")] public string MaxPremiereDate { get; set; } + + [ApiMember(Name = "HasOverview", Description = "Optional filter by items that have an overview or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? HasOverview { get; set; } + + [ApiMember(Name = "HasImdbId", Description = "Optional filter by items that have an imdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? HasImdbId { get; set; } + + [ApiMember(Name = "HasTmdbId", Description = "Optional filter by items that have a tmdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? HasTmdbId { get; set; } + + [ApiMember(Name = "HasTvdbId", Description = "Optional filter by items that have a tvdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? HasTvdbId { get; set; } + + [ApiMember(Name = "IsYearMismatched", Description = "Optional filter by items that are potentially misidentified.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsYearMismatched { get; set; } } /// @@ -1029,9 +1046,92 @@ namespace MediaBrowser.Api.UserLibrary items = items.Where(i => i.PremiereDate.HasValue && i.PremiereDate.Value <= date); } + if (request.HasOverview.HasValue) + { + var filterValue = request.HasOverview.Value; + + items = items.Where(i => + { + var hasValue = !string.IsNullOrEmpty(i.Overview); + + return hasValue == filterValue; + }); + } + + if (request.HasImdbId.HasValue) + { + var filterValue = request.HasImdbId.Value; + + items = items.Where(i => + { + var hasValue = !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Imdb)); + + return hasValue == filterValue; + }); + } + + if (request.HasTmdbId.HasValue) + { + var filterValue = request.HasTmdbId.Value; + + items = items.Where(i => + { + var hasValue = !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tmdb)); + + return hasValue == filterValue; + }); + } + + if (request.HasTvdbId.HasValue) + { + var filterValue = request.HasTvdbId.Value; + + items = items.Where(i => + { + var hasValue = !string.IsNullOrEmpty(i.GetProviderId(MetadataProviders.Tvdb)); + + return hasValue == filterValue; + }); + } + + if (request.IsYearMismatched.HasValue) + { + var filterValue = request.IsYearMismatched.Value; + + items = items.Where(i => IsYearMismatched(i) == filterValue); + } + return items; } + private bool IsYearMismatched(BaseItem item) + { + if (item.ProductionYear.HasValue) + { + var path = item.Path; + + if (!string.IsNullOrEmpty(path)) + { + int? yearInName; + string name; + NameParser.ParseName(Path.GetFileName(path), out name, out yearInName); + + // Go up a level if we didn't get a year + if (!yearInName.HasValue) + { + NameParser.ParseName(Path.GetFileName(Path.GetDirectoryName(path)), out name, out yearInName); + } + + if (yearInName.HasValue) + { + return yearInName.Value != item.ProductionYear.Value; + } + } + } + + return false; + } + /// /// Determines whether the specified item has image. /// diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d882824293..25da18fcac 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -138,6 +138,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the type of the location. /// /// The type of the location. + [IgnoreDataMember] public virtual LocationType LocationType { get diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index ef768f6280..9b02571b00 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -262,7 +262,10 @@ namespace MediaBrowser.Controller.Entities { if (!IsInMixedFolder) { - return new[] { System.IO.Path.GetDirectoryName(Path) }; + if (VideoType == VideoType.VideoFile || VideoType == VideoType.Iso) + { + return new[] { System.IO.Path.GetDirectoryName(Path) }; + } } return base.GetDeletePaths(); diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index a309d815c3..9b89b12c50 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -117,6 +117,7 @@ + diff --git a/MediaBrowser.Controller/Providers/NameParser.cs b/MediaBrowser.Controller/Providers/NameParser.cs new file mode 100644 index 0000000000..726f0e60e3 --- /dev/null +++ b/MediaBrowser.Controller/Providers/NameParser.cs @@ -0,0 +1,39 @@ +using System; +using System.Text.RegularExpressions; + +namespace MediaBrowser.Controller.Providers +{ + public static class NameParser + { + static readonly Regex[] NameMatches = new[] { + new Regex(@"(?.*)\((?\d{4})\)"), // matches "My Movie (2001)" and gives us the name and the year + new Regex(@"(?.*)(\.(?\d{4})(\.|$)).*$"), + new Regex(@"(?.*)") // last resort matches the whole string as the name + }; + + + /// + /// Parses the name. + /// + /// The name. + /// Name of the just. + /// The year. + public static void ParseName(string name, out string justName, out int? year) + { + justName = null; + year = null; + foreach (var re in NameMatches) + { + Match m = re.Match(name); + if (m.Success) + { + justName = m.Groups["name"].Value.Trim(); + string y = m.Groups["year"] != null ? m.Groups["year"].Value : null; + int temp; + year = Int32.TryParse(y, out temp) ? temp : (int?)null; + break; + } + } + } + } +} diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs index f1260b1dad..4a91e2e60f 100644 --- a/MediaBrowser.Mono.userprefs +++ b/MediaBrowser.Mono.userprefs @@ -1,10 +1,14 @@  - + - - - + + + + + + + @@ -16,10 +20,13 @@ - + + + + + - - + diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index fe409c0900..e4fe2a914d 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -15,7 +15,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Net; -using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -190,12 +189,6 @@ namespace MediaBrowser.Providers.Movies internal static string ApiKey = "f6bd687ffa63cd282b6ff2c6877f2669"; internal static string AcceptHeader = "application/json,image/*"; - static readonly Regex[] NameMatches = new[] { - new Regex(@"(?.*)\((?\d{4})\)"), // matches "My Movie (2001)" and gives us the name and the year - new Regex(@"(?.*)(\.(?\d{4})(\.|$)).*$"), - new Regex(@"(?.*)") // last resort matches the whole string as the name - }; - protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo) { if (string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Tmdb))) @@ -309,30 +302,6 @@ namespace MediaBrowser.Providers.Movies return false; } - /// - /// Parses the name. - /// - /// The name. - /// Name of the just. - /// The year. - public static void ParseName(string name, out string justName, out int? year) - { - justName = null; - year = null; - foreach (var re in NameMatches) - { - Match m = re.Match(name); - if (m.Success) - { - justName = m.Groups["name"].Value.Trim(); - string y = m.Groups["year"] != null ? m.Groups["year"].Value : null; - int temp; - year = Int32.TryParse(y, out temp) ? temp : (int?)null; - break; - } - } - } - /// /// Finds the id. /// @@ -343,7 +312,7 @@ namespace MediaBrowser.Providers.Movies { int? yearInName; string name = item.Name; - ParseName(name, out name, out yearInName); + NameParser.ParseName(name, out name, out yearInName); var year = item.ProductionYear ?? yearInName; diff --git a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs index 6550396e51..d881859c6e 100644 --- a/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs +++ b/MediaBrowser.Providers/Movies/OpenMovieDatabaseProvider.cs @@ -109,19 +109,11 @@ namespace MediaBrowser.Providers.Movies public override async Task FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken) { - BaseProviderInfo data; - - if (!item.ProviderData.TryGetValue(Id, out data)) - { - data = new BaseProviderInfo(); - item.ProviderData[Id] = data; - } - var imdbId = item.GetProviderId(MetadataProviders.Imdb); if (string.IsNullOrEmpty(imdbId)) { - data.LastRefreshStatus = ProviderRefreshStatus.Success; + SetLastRefreshed(item, DateTime.UtcNow); return true; } @@ -182,9 +174,7 @@ namespace MediaBrowser.Providers.Movies ParseAdditionalMetadata(item, result); } - data.LastRefreshStatus = ProviderRefreshStatus.Success; SetLastRefreshed(item, DateTime.UtcNow); - return true; } diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 2d32811d33..3bfbdea3ea 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -41,6 +41,9 @@ False ..\packages\MediaBrowser.BdInfo.1.0.0.5\lib\net20\BDInfo.dll + + ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.70\lib\net35\Mono.Data.Sqlite.dll + False ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.dll @@ -57,6 +60,13 @@ False ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll + + False + ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.70\lib\net35\ServiceStack.OrmLite.dll + + + ..\packages\ServiceStack.OrmLite.Sqlite.Mono.3.9.70\lib\net35\ServiceStack.OrmLite.Sqlite.dll + False ..\packages\ServiceStack.3.9.70\lib\net35\ServiceStack.ServiceInterface.dll @@ -262,6 +272,7 @@ + PreserveNewest diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index d5abe58caf..488dbc1ae8 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -9,6 +9,7 @@ + diff --git a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj index 900169c707..e32dad8d7b 100644 --- a/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj +++ b/MediaBrowser.Server.Mono/MediaBrowser.Server.Mono.csproj @@ -44,13 +44,13 @@ + - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Common.dll + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Common.dll - ..\packages\ServiceStack.Common.3.9.62\lib\net35\ServiceStack.Interfaces.dll + ..\packages\ServiceStack.Common.3.9.70\lib\net35\ServiceStack.Interfaces.dll - @@ -82,7 +82,6 @@ - FFMpeg\FFMpegDownloader.cs diff --git a/MediaBrowser.Server.Mono/Native/HttpClientFactory.cs b/MediaBrowser.Server.Mono/Native/HttpClientFactory.cs deleted file mode 100644 index 0fceab0608..0000000000 --- a/MediaBrowser.Server.Mono/Native/HttpClientFactory.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Net.Http; - -namespace MediaBrowser.ServerApplication.Native -{ - /// - /// Class HttpClientFactory - /// - public static class HttpClientFactory - { - /// - /// Gets the HTTP client. - /// - /// if set to true [enable HTTP compression]. - /// HttpClient. - public static HttpClient GetHttpClient(bool enableHttpCompression) - { - return new HttpClient() - { - Timeout = TimeSpan.FromSeconds(20) - }; - } - } -} diff --git a/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs b/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs index f7a87c9d47..8f5dcc034a 100644 --- a/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs +++ b/MediaBrowser.Tests/Providers/MovieDbProviderTests.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Providers.Movies; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Providers.Movies; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace MediaBrowser.Tests.Providers { @@ -8,27 +9,27 @@ namespace MediaBrowser.Tests.Providers { public void TestNameMatches() { var name = string.Empty; int? year = null; - MovieDbProvider.ParseName("My Movie (2013)", out name, out year); + NameParser.ParseName("My Movie (2013)", out name, out year); Assert.AreEqual("My Movie", name); Assert.AreEqual(2013, year); name = string.Empty; year = null; - MovieDbProvider.ParseName("My Movie 2 (2013)", out name, out year); + NameParser.ParseName("My Movie 2 (2013)", out name, out year); Assert.AreEqual("My Movie 2", name); Assert.AreEqual(2013, year); name = string.Empty; year = null; - MovieDbProvider.ParseName("My Movie 2001 (2013)", out name, out year); + NameParser.ParseName("My Movie 2001 (2013)", out name, out year); Assert.AreEqual("My Movie 2001", name); Assert.AreEqual(2013, year); name = string.Empty; year = null; - MovieDbProvider.ParseName("My Movie - 2 (2013)", out name, out year); + NameParser.ParseName("My Movie - 2 (2013)", out name, out year); Assert.AreEqual("My Movie - 2", name); Assert.AreEqual(2013, year); name = string.Empty; year = null; - MovieDbProvider.ParseName("curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", out name, out year); + NameParser.ParseName("curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", out name, out year); Assert.AreEqual("curse.of.chucky", name); Assert.AreEqual(2013, year); } -- cgit v1.2.3 From 317f41107091a4334b9133a21e570d627a2d808a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 2 Dec 2013 11:16:03 -0500 Subject: Added IHasBudget --- MediaBrowser.Api/ItemUpdateService.cs | 8 ++++++-- MediaBrowser.Controller/Entities/BaseItem.cs | 12 ------------ MediaBrowser.Controller/Entities/IHasBudget.cs | 18 ++++++++++++++++++ MediaBrowser.Controller/Entities/Movies/Movie.cs | 14 +++++++++++++- MediaBrowser.Controller/Entities/MusicVideo.cs | 14 +++++++++++++- MediaBrowser.Controller/Entities/Trailer.cs | 14 +++++++++++++- .../MediaBrowser.Controller.csproj | 1 + .../Providers/BaseItemXmlParser.cs | 20 ++++++++++++++------ MediaBrowser.Providers/Movies/MovieDbProvider.cs | 8 ++++++-- MediaBrowser.Providers/Savers/XmlSaverHelpers.cs | 16 ++++++++++------ .../Dto/DtoService.cs | 16 ++++++++++------ .../Sorting/BudgetComparer.cs | 7 ++++++- .../Sorting/RevenueComparer.cs | 7 ++++++- 13 files changed, 116 insertions(+), 39 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/IHasBudget.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 48d292bbc2..90fe111292 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -248,8 +248,12 @@ namespace MediaBrowser.Api item.ForcedSortName = request.SortName; } - item.Budget = request.Budget; - item.Revenue = request.Revenue; + var hasBudget = item as IHasBudget; + if (hasBudget != null) + { + hasBudget.Budget = request.Budget; + hasBudget.Revenue = request.Revenue; + } var hasCriticRating = item as IHasCriticRating; if (hasCriticRating != null) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 25da18fcac..f5cdaa9880 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -86,24 +86,12 @@ namespace MediaBrowser.Controller.Entities /// The id. public Guid Id { get; set; } - /// - /// Gets or sets the budget. - /// - /// The budget. - public double? Budget { get; set; } - /// /// Gets or sets the taglines. /// /// The taglines. public List Taglines { get; set; } - /// - /// Gets or sets the revenue. - /// - /// The revenue. - public double? Revenue { get; set; } - /// /// Gets or sets the trailer URL. /// diff --git a/MediaBrowser.Controller/Entities/IHasBudget.cs b/MediaBrowser.Controller/Entities/IHasBudget.cs new file mode 100644 index 0000000000..f697715c16 --- /dev/null +++ b/MediaBrowser.Controller/Entities/IHasBudget.cs @@ -0,0 +1,18 @@ + +namespace MediaBrowser.Controller.Entities +{ + public interface IHasBudget + { + /// + /// Gets or sets the budget. + /// + /// The budget. + double? Budget { get; set; } + + /// + /// Gets or sets the revenue. + /// + /// The revenue. + double? Revenue { get; set; } + } +} diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index eef348f61c..30babe2383 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class Movie /// - public class Movie : Video, IHasCriticRating, IHasSoundtracks + public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget { public List SpecialFeatureIds { get; set; } @@ -23,6 +23,18 @@ namespace MediaBrowser.Controller.Entities.Movies SoundtrackIds = new List(); } + /// + /// Gets or sets the budget. + /// + /// The budget. + public double? Budget { get; set; } + + /// + /// Gets or sets the revenue. + /// + /// The revenue. + public double? Revenue { get; set; } + /// /// Gets or sets the critic rating. /// diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 207f76efda..68ad4630a5 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -4,7 +4,7 @@ using System; namespace MediaBrowser.Controller.Entities { - public class MusicVideo : Video, IHasArtist, IHasMusicGenres + public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasBudget { /// /// Gets or sets the artist. @@ -18,6 +18,18 @@ namespace MediaBrowser.Controller.Entities /// The album. public string Album { get; set; } + /// + /// Gets or sets the budget. + /// + /// The budget. + public double? Budget { get; set; } + + /// + /// Gets or sets the revenue. + /// + /// The revenue. + public double? Revenue { get; set; } + /// /// Determines whether the specified name has artist. /// diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 26814ad40b..7c14c9865d 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class Trailer /// - public class Trailer : Video, IHasCriticRating, IHasSoundtracks + public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget { public List SoundtrackIds { get; set; } @@ -19,6 +19,18 @@ namespace MediaBrowser.Controller.Entities SoundtrackIds = new List(); } + /// + /// Gets or sets the budget. + /// + /// The budget. + public double? Budget { get; set; } + + /// + /// Gets or sets the revenue. + /// + /// The revenue. + public double? Revenue { get; set; } + /// /// Gets or sets the critic rating. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 9b89b12c50..e5fe6a04f7 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -90,6 +90,7 @@ + diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 14c83bed43..44138a5989 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -162,10 +162,14 @@ namespace MediaBrowser.Controller.Providers case "Budget": { var text = reader.ReadElementContentAsString(); - double value; - if (double.TryParse(text, NumberStyles.Any, _usCulture, out value)) + var hasBudget = item as IHasBudget; + if (hasBudget != null) { - item.Budget = value; + double value; + if (double.TryParse(text, NumberStyles.Any, _usCulture, out value)) + { + hasBudget.Budget = value; + } } break; @@ -174,10 +178,14 @@ namespace MediaBrowser.Controller.Providers case "Revenue": { var text = reader.ReadElementContentAsString(); - double value; - if (double.TryParse(text, NumberStyles.Any, _usCulture, out value)) + var hasBudget = item as IHasBudget; + if (hasBudget != null) { - item.Revenue = value; + double value; + if (double.TryParse(text, NumberStyles.Any, _usCulture, out value)) + { + hasBudget.Revenue = value; + } } break; diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index e4fe2a914d..b812c93247 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -701,8 +701,12 @@ namespace MediaBrowser.Providers.Movies } movie.HomePageUrl = movieData.homepage; - movie.Budget = movieData.budget; - movie.Revenue = movieData.revenue; + var hasBudget = movie as IHasBudget; + if (hasBudget != null) + { + hasBudget.Budget = movieData.budget; + hasBudget.Revenue = movieData.revenue; + } if (!string.IsNullOrEmpty(movieData.tagline)) { diff --git a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs index 5a49e4f36b..4c032c8e78 100644 --- a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs @@ -280,14 +280,18 @@ namespace MediaBrowser.Providers.Savers builder.Append(""); } - if (item.Budget.HasValue) + var hasBudget = item as IHasBudget; + if (hasBudget != null) { - builder.Append("" + SecurityElement.Escape(item.Budget.Value.ToString(UsCulture)) + ""); - } + if (hasBudget.Budget.HasValue) + { + builder.Append("" + SecurityElement.Escape(hasBudget.Budget.Value.ToString(UsCulture)) + ""); + } - if (item.Revenue.HasValue) - { - builder.Append("" + SecurityElement.Escape(item.Revenue.Value.ToString(UsCulture)) + ""); + if (hasBudget.Revenue.HasValue) + { + builder.Append("" + SecurityElement.Escape(hasBudget.Revenue.Value.ToString(UsCulture)) + ""); + } } if (item.CommunityRating.HasValue) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 5333518753..b43449858e 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -727,14 +727,18 @@ namespace MediaBrowser.Server.Implementations.Dto dto.EnableInternetProviders = !item.DontFetchMeta; } - if (fields.Contains(ItemFields.Budget)) + var hasBudget = item as IHasBudget; + if (hasBudget != null) { - dto.Budget = item.Budget; - } + if (fields.Contains(ItemFields.Budget)) + { + dto.Budget = hasBudget.Budget; + } - if (fields.Contains(ItemFields.Revenue)) - { - dto.Revenue = item.Revenue; + if (fields.Contains(ItemFields.Revenue)) + { + dto.Revenue = hasBudget.Revenue; + } } dto.EndDate = item.EndDate; diff --git a/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs b/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs index d2dac65499..87a7325c63 100644 --- a/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/BudgetComparer.cs @@ -19,7 +19,12 @@ namespace MediaBrowser.Server.Implementations.Sorting private double GetValue(BaseItem x) { - return x.Budget ?? 0; + var hasBudget = x as IHasBudget; + if (hasBudget != null) + { + return hasBudget.Budget ?? 0; + } + return 0; } /// diff --git a/MediaBrowser.Server.Implementations/Sorting/RevenueComparer.cs b/MediaBrowser.Server.Implementations/Sorting/RevenueComparer.cs index e9d7912a16..6caa27ac39 100644 --- a/MediaBrowser.Server.Implementations/Sorting/RevenueComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/RevenueComparer.cs @@ -19,7 +19,12 @@ namespace MediaBrowser.Server.Implementations.Sorting private double GetValue(BaseItem x) { - return x.Revenue ?? 0; + var hasBudget = x as IHasBudget; + if (hasBudget != null) + { + return hasBudget.Revenue ?? 0; + } + return 0; } /// -- cgit v1.2.3 From cd279d98e0574c396c0a35984e46658151e54fc0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 2 Dec 2013 11:46:25 -0500 Subject: added IHasTrailers --- MediaBrowser.Api/UserLibrary/ItemsService.cs | 14 ++++++++++++- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 10 +++++++++- MediaBrowser.Controller/Entities/BaseItem.cs | 21 ++++++++------------ MediaBrowser.Controller/Entities/Extensions.cs | 2 +- MediaBrowser.Controller/Entities/Game.cs | 12 ++++++++++- MediaBrowser.Controller/Entities/IHasTrailers.cs | 21 ++++++++++++++++++++ MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 20 +++++++++++++++++-- MediaBrowser.Controller/Entities/Movies/Movie.cs | 8 +++++++- MediaBrowser.Controller/Entities/TV/Series.cs | 8 +++++++- MediaBrowser.Controller/Entities/Trailer.cs | 7 ++++++- .../MediaBrowser.Controller.csproj | 1 + .../Providers/BaseItemXmlParser.cs | 23 +++++++++++++++++----- MediaBrowser.Providers/Movies/MovieDbProvider.cs | 16 +++++++++------ MediaBrowser.Providers/Savers/XmlSaverHelpers.cs | 18 ++++++++++------- .../Dto/DtoService.cs | 17 ++++++++-------- 15 files changed, 150 insertions(+), 48 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/IHasTrailers.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs index d6f3488361..0e40ef3957 100644 --- a/MediaBrowser.Api/UserLibrary/ItemsService.cs +++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs @@ -885,7 +885,19 @@ namespace MediaBrowser.Api.UserLibrary if (request.HasTrailer.HasValue) { - items = items.Where(i => request.HasTrailer.Value ? i.LocalTrailerIds.Count > 0 : i.LocalTrailerIds.Count == 0); + var val = request.HasTrailer.Value; + items = items.Where(i => + { + var trailerCount = 0; + + var hasTrailers = i as IHasTrailers; + if (hasTrailers != null) + { + trailerCount = hasTrailers.LocalTrailerIds.Count; + } + + return val ? trailerCount > 0 : trailerCount == 0; + }); } if (request.HasThemeSong.HasValue) diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 6b7980b1f7..e9fc524680 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -489,7 +489,15 @@ namespace MediaBrowser.Api.UserLibrary // Get everything var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList(); - var dtos = item.LocalTrailerIds + var trailerIds = new List(); + + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) + { + trailerIds = hasTrailers.LocalTrailerIds; + } + + var dtos = trailerIds .Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index f5cdaa9880..4f7889f975 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -37,10 +37,8 @@ namespace MediaBrowser.Controller.Entities Tags = new List(); ThemeSongIds = new List(); ThemeVideoIds = new List(); - LocalTrailerIds = new List(); LockedFields = new List(); Taglines = new List(); - RemoteTrailers = new List(); ImageSources = new List(); } @@ -92,12 +90,6 @@ namespace MediaBrowser.Controller.Entities /// The taglines. public List Taglines { get; set; } - /// - /// Gets or sets the trailer URL. - /// - /// The trailer URL. - public List RemoteTrailers { get; set; } - /// /// Return the id that should be used to key display prefs for this item. /// Default is based on the type for everything except actual generic folders. @@ -654,7 +646,6 @@ namespace MediaBrowser.Controller.Entities public List ThemeSongIds { get; set; } public List ThemeVideoIds { get; set; } - public List LocalTrailerIds { get; set; } [IgnoreDataMember] public virtual string OfficialRatingForComparison @@ -897,7 +888,11 @@ namespace MediaBrowser.Controller.Entities themeVideosChanged = await RefreshThemeVideos(cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false); - localTrailersChanged = await RefreshLocalTrailers(cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false); + var hasTrailers = this as IHasTrailers; + if (hasTrailers != null) + { + localTrailersChanged = await RefreshLocalTrailers(hasTrailers, cancellationToken, forceSave, forceRefresh, allowSlowProviders).ConfigureAwait(false); + } } cancellationToken.ThrowIfCancellationRequested(); @@ -917,18 +912,18 @@ namespace MediaBrowser.Controller.Entities return changed; } - private async Task RefreshLocalTrailers(CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true) + private async Task RefreshLocalTrailers(IHasTrailers item, CancellationToken cancellationToken, bool forceSave = false, bool forceRefresh = false, bool allowSlowProviders = true) { var newItems = LoadLocalTrailers().ToList(); var newItemIds = newItems.Select(i => i.Id).ToList(); - var itemsChanged = !LocalTrailerIds.SequenceEqual(newItemIds); + var itemsChanged = !item.LocalTrailerIds.SequenceEqual(newItemIds); var tasks = newItems.Select(i => i.RefreshMetadata(cancellationToken, forceSave, forceRefresh, allowSlowProviders, resetResolveArgs: false)); var results = await Task.WhenAll(tasks).ConfigureAwait(false); - LocalTrailerIds = newItemIds; + item.LocalTrailerIds = newItemIds; return itemsChanged || results.Contains(true); } diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs index d189f4e71b..2a64bd3a41 100644 --- a/MediaBrowser.Controller/Entities/Extensions.cs +++ b/MediaBrowser.Controller/Entities/Extensions.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities /// The URL. /// if set to true [is direct link]. /// url - public static void AddTrailerUrl(this BaseItem item, string url, bool isDirectLink) + public static void AddTrailerUrl(this IHasTrailers item, string url, bool isDirectLink) { if (string.IsNullOrWhiteSpace(url)) { diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index ea39cf50ad..e15b7e4c9d 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace MediaBrowser.Controller.Entities { - public class Game : BaseItem, IHasSoundtracks + public class Game : BaseItem, IHasSoundtracks, IHasTrailers { public List SoundtrackIds { get; set; } @@ -12,8 +12,18 @@ namespace MediaBrowser.Controller.Entities { MultiPartGameFiles = new List(); SoundtrackIds = new List(); + RemoteTrailers = new List(); + LocalTrailerIds = new List(); } + public List LocalTrailerIds { get; set; } + + /// + /// Gets or sets the remote trailers. + /// + /// The remote trailers. + public List RemoteTrailers { get; set; } + /// /// Gets the type of the media. /// diff --git a/MediaBrowser.Controller/Entities/IHasTrailers.cs b/MediaBrowser.Controller/Entities/IHasTrailers.cs new file mode 100644 index 0000000000..47779064b4 --- /dev/null +++ b/MediaBrowser.Controller/Entities/IHasTrailers.cs @@ -0,0 +1,21 @@ +using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Entities +{ + public interface IHasTrailers + { + /// + /// Gets or sets the remote trailers. + /// + /// The remote trailers. + List RemoteTrailers { get; set; } + + /// + /// Gets or sets the local trailer ids. + /// + /// The local trailer ids. + List LocalTrailerIds { get; set; } + } +} diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index e52ece502b..4a6221ee98 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -1,10 +1,26 @@ - +using System; +using MediaBrowser.Model.Entities; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities.Movies { /// /// Class BoxSet /// - public class BoxSet : Folder + public class BoxSet : Folder, IHasTrailers { + public BoxSet() + { + RemoteTrailers = new List(); + LocalTrailerIds = new List(); + } + + public List LocalTrailerIds { get; set; } + + /// + /// Gets or sets the remote trailers. + /// + /// The remote trailers. + public List RemoteTrailers { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 30babe2383..473ea4996d 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class Movie /// - public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget + public class Movie : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers { public List SpecialFeatureIds { get; set; } @@ -21,8 +21,14 @@ namespace MediaBrowser.Controller.Entities.Movies { SpecialFeatureIds = new List(); SoundtrackIds = new List(); + RemoteTrailers = new List(); + LocalTrailerIds = new List(); } + public List LocalTrailerIds { get; set; } + + public List RemoteTrailers { get; set; } + /// /// Gets or sets the budget. /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 02ea50c6b5..f3c7b088a7 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Entities.TV /// /// Class Series /// - public class Series : Folder, IHasSoundtracks + public class Series : Folder, IHasSoundtracks, IHasTrailers { public List SpecialFeatureIds { get; set; } public List SoundtrackIds { get; set; } @@ -24,8 +24,14 @@ namespace MediaBrowser.Controller.Entities.TV SpecialFeatureIds = new List(); SoundtrackIds = new List(); + RemoteTrailers = new List(); + LocalTrailerIds = new List(); } + public List LocalTrailerIds { get; set; } + + public List RemoteTrailers { get; set; } + /// /// Gets or sets the status. /// diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 7c14c9865d..77efe8e8c1 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class Trailer /// - public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget + public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers { public List SoundtrackIds { get; set; } @@ -17,8 +17,13 @@ namespace MediaBrowser.Controller.Entities RemoteTrailers = new List(); Taglines = new List(); SoundtrackIds = new List(); + LocalTrailerIds = new List(); } + public List LocalTrailerIds { get; set; } + + public List RemoteTrailers { get; set; } + /// /// Gets or sets the budget. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index e5fe6a04f7..64d5c52260 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -93,6 +93,7 @@ + diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 44138a5989..617e4fd819 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -68,7 +68,12 @@ namespace MediaBrowser.Controller.Providers item.Genres.Clear(); item.People.Clear(); item.Tags.Clear(); - item.RemoteTrailers.Clear(); + + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) + { + hasTrailers.RemoteTrailers.Clear(); + } //Fetch(item, metadataFile, settings, Encoding.GetEncoding("ISO-8859-1"), cancellationToken); Fetch(item, metadataFile, settings, Encoding.UTF8, cancellationToken); @@ -484,9 +489,13 @@ namespace MediaBrowser.Controller.Providers { var val = reader.ReadElementContentAsString(); - if (!string.IsNullOrWhiteSpace(val)) + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) { - item.AddTrailerUrl(val, false); + if (!string.IsNullOrWhiteSpace(val)) + { + hasTrailers.AddTrailerUrl(val, false); + } } break; } @@ -495,7 +504,11 @@ namespace MediaBrowser.Controller.Providers { using (var subtree = reader.ReadSubtree()) { - FetchDataFromTrailersNode(subtree, item); + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) + { + FetchDataFromTrailersNode(subtree, hasTrailers); + } } break; } @@ -940,7 +953,7 @@ namespace MediaBrowser.Controller.Providers } } - private void FetchDataFromTrailersNode(XmlReader reader, T item) + private void FetchDataFromTrailersNode(XmlReader reader, IHasTrailers item) { reader.MoveToContent(); diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index b812c93247..51a2362c05 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -874,14 +874,18 @@ namespace MediaBrowser.Providers.Movies if (movieData.trailers != null && movieData.trailers.youtube != null && movieData.trailers.youtube.Count > 0) { - movie.RemoteTrailers = movieData.trailers.youtube.Select(i => new MediaUrl + var hasTrailers = movie as IHasTrailers; + if (hasTrailers != null) { - Url = string.Format("http://www.youtube.com/watch?v={0}", i.source), - IsDirectLink = false, - Name = i.name, - VideoSize = string.Equals("hd", i.size, StringComparison.OrdinalIgnoreCase) ? VideoSize.HighDefinition : VideoSize.StandardDefinition + hasTrailers.RemoteTrailers = movieData.trailers.youtube.Select(i => new MediaUrl + { + Url = string.Format("http://www.youtube.com/watch?v={0}", i.source), + IsDirectLink = false, + Name = i.name, + VideoSize = string.Equals("hd", i.size, StringComparison.OrdinalIgnoreCase) ? VideoSize.HighDefinition : VideoSize.StandardDefinition - }).ToList(); + }).ToList(); + } } } diff --git a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs index 4c032c8e78..186941988c 100644 --- a/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.Providers/Savers/XmlSaverHelpers.cs @@ -268,16 +268,20 @@ namespace MediaBrowser.Providers.Savers } } - if (item.RemoteTrailers.Count > 0) + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) { - builder.Append(""); - - foreach (var trailer in item.RemoteTrailers) + if (hasTrailers.RemoteTrailers.Count > 0) { - builder.Append("" + SecurityElement.Escape(trailer.Url) + ""); - } + builder.Append(""); + + foreach (var trailer in hasTrailers.RemoteTrailers) + { + builder.Append("" + SecurityElement.Escape(trailer.Url) + ""); + } - builder.Append(""); + builder.Append(""); + } } var hasBudget = item as IHasBudget; diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index b43449858e..90ca64058d 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -808,11 +808,17 @@ namespace MediaBrowser.Server.Implementations.Dto } } - var localTrailerCount = item.LocalTrailerIds.Count; + var hasTrailers = item as IHasTrailers; + if (hasTrailers != null) + { + dto.LocalTrailerCount = hasTrailers.LocalTrailerIds.Count; + } - if (localTrailerCount > 0) + if (fields.Contains(ItemFields.RemoteTrailers)) { - dto.LocalTrailerCount = localTrailerCount; + dto.RemoteTrailers = hasTrailers != null ? + hasTrailers.RemoteTrailers : + new List(); } dto.Name = item.Name; @@ -925,11 +931,6 @@ namespace MediaBrowser.Server.Implementations.Dto dto.Taglines = item.Taglines; } - if (fields.Contains(ItemFields.RemoteTrailers)) - { - dto.RemoteTrailers = item.RemoteTrailers; - } - dto.Type = item.GetClientTypeName(); dto.CommunityRating = item.CommunityRating; dto.VoteCount = item.VoteCount; -- cgit v1.2.3 From 245e92c9cc6f97e139e04548c94184c65712d3f0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 2 Dec 2013 16:46:22 -0500 Subject: updated nuget --- .../Entities/Audio/MusicArtist.cs | 4 +-- .../Entities/Audio/MusicGenre.cs | 4 +-- MediaBrowser.Controller/Entities/GameGenre.cs | 4 +-- MediaBrowser.Controller/Entities/Genre.cs | 4 +-- MediaBrowser.Controller/Entities/IItemByName.cs | 25 ++++++++++------ MediaBrowser.Controller/Entities/Person.cs | 8 +++--- MediaBrowser.Controller/Entities/Studio.cs | 4 +-- MediaBrowser.Controller/Entities/Year.cs | 4 +-- MediaBrowser.Controller/LiveTv/Channel.cs | 4 +-- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 10 ++++++- .../LiveTv/ImageResponseInfo.cs | 19 +++++++++++++ MediaBrowser.Controller/LiveTv/ProgramInfo.cs | 12 ++++++++ MediaBrowser.Controller/LiveTv/RecordingInfo.cs | 29 +++++++++++++++++++ MediaBrowser.Controller/LiveTv/SeriesTimerInfo.cs | 6 ++++ .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Model/Dto/ItemByNameCounts.cs | 5 +++- MediaBrowser.Model/LiveTv/ProgramInfoDto.cs | 24 ++++------------ MediaBrowser.Model/LiveTv/RecordingInfoDto.cs | 33 ++++++++++++++++++++-- .../Dto/DtoService.cs | 8 ++---- .../Library/Validators/ArtistsValidator.cs | 2 +- .../Library/Validators/GameGenresValidator.cs | 2 +- .../Library/Validators/GenresValidator.cs | 2 +- .../Library/Validators/MusicGenresValidator.cs | 2 +- .../Library/Validators/PeoplePostScanTask.cs | 2 +- .../Library/Validators/StudiosValidator.cs | 2 +- .../LiveTv/ChannelImageProvider.cs | 2 +- .../LiveTv/LiveTvManager.cs | 25 ++++++---------- .../Sorting/AlbumCountComparer.cs | 2 +- .../Sorting/EpisodeCountComparer.cs | 2 +- .../Sorting/MovieCountComparer.cs | 2 +- .../Sorting/MusicVideoCountComparer.cs | 2 +- .../Sorting/SeriesCountComparer.cs | 2 +- .../Sorting/SongCountComparer.cs | 2 +- .../Sorting/TrailerCountComparer.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 37 files changed, 180 insertions(+), 91 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/ImageResponseInfo.cs (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 8ebfe17e41..d5572b9a5e 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities.Audio public class MusicArtist : Folder, IItemByName, IHasMusicGenres, IHasDualAccess { [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } public bool IsAccessedByName { get; set; } @@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Entities.Audio public MusicArtist() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } /// diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index ec2995fb2f..b54e14f2da 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities.Audio { public MusicGenre() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } /// @@ -25,6 +25,6 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 0c877782e6..ffe62ba03f 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities { public GameGenre() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } /// @@ -22,6 +22,6 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 6c49501826..0fa49639bf 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities { public Genre() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } /// @@ -25,6 +25,6 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index 1cb375374d..1e83c7466e 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -1,6 +1,7 @@ using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -9,7 +10,7 @@ namespace MediaBrowser.Controller.Entities /// public interface IItemByName { - Dictionary UserItemCounts { get; set; } + List UserItemCountList { get; set; } } public interface IHasDualAccess : IItemByName @@ -17,23 +18,29 @@ namespace MediaBrowser.Controller.Entities bool IsAccessedByName { get; } } - public static class IItemByNameExtensions + public static class ItemByNameExtensions { - public static ItemByNameCounts GetItemByNameCounts(this IItemByName item, User user) + public static ItemByNameCounts GetItemByNameCounts(this IItemByName item, Guid userId) { - if (user == null) + if (userId == Guid.Empty) { - throw new ArgumentNullException("user"); + throw new ArgumentNullException("userId"); } - ItemByNameCounts counts; + return item.UserItemCountList.FirstOrDefault(i => i.UserId == userId); + } + + public static void SetItemByNameCounts(this IItemByName item, Guid userId, ItemByNameCounts counts) + { + var current = item.UserItemCountList.FirstOrDefault(i => i.UserId == userId); - if (item.UserItemCounts.TryGetValue(user.Id, out counts)) + if (current != null) { - return counts; + item.UserItemCountList.Remove(current); } - return null; + counts.UserId = userId; + item.UserItemCountList.Add(counts); } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 17b9d77413..243861da76 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,7 +1,7 @@ -using System.Runtime.Serialization; -using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Dto; using System; using System.Collections.Generic; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -12,11 +12,11 @@ namespace MediaBrowser.Controller.Entities { public Person() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } /// /// Gets the user data key. diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index bbe96a88b9..7bc17549f3 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Entities { public Studio() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } /// @@ -25,6 +25,6 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index d0f4577183..cd50a1c60c 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -12,11 +12,11 @@ namespace MediaBrowser.Controller.Entities { public Year() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } /// /// Gets the user data key. diff --git a/MediaBrowser.Controller/LiveTv/Channel.cs b/MediaBrowser.Controller/LiveTv/Channel.cs index 94d76971c3..8097cea1de 100644 --- a/MediaBrowser.Controller/LiveTv/Channel.cs +++ b/MediaBrowser.Controller/LiveTv/Channel.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.LiveTv { public Channel() { - UserItemCounts = new Dictionary(); + UserItemCountList = new List(); } /// @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.LiveTv } [IgnoreDataMember] - public Dictionary UserItemCounts { get; set; } + public List UserItemCountList { get; set; } /// /// Gets or sets the number. diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 1627ad400f..a6c60d468d 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -69,8 +69,16 @@ namespace MediaBrowser.Controller.LiveTv /// The channel identifier. /// The cancellation token. /// Task{Stream}. - Task GetChannelImageAsync(string channelId, CancellationToken cancellationToken); + Task GetChannelImageAsync(string channelId, CancellationToken cancellationToken); + /// + /// Gets the program image asynchronous. + /// + /// The program identifier. + /// The cancellation token. + /// Task{ImageResponseInfo}. + Task GetProgramImageAsync(string programId, CancellationToken cancellationToken); + /// /// Gets the recordings asynchronous. /// diff --git a/MediaBrowser.Controller/LiveTv/ImageResponseInfo.cs b/MediaBrowser.Controller/LiveTv/ImageResponseInfo.cs new file mode 100644 index 0000000000..d454a1ef8d --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/ImageResponseInfo.cs @@ -0,0 +1,19 @@ +using System.IO; + +namespace MediaBrowser.Controller.LiveTv +{ + public class ImageResponseInfo + { + /// + /// Gets or sets the stream. + /// + /// The stream. + public Stream Stream { get; set; } + + /// + /// Gets or sets the type of the MIME. + /// + /// The type of the MIME. + public string MimeType { get; set; } + } +} diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs index 58a15be3e5..cf5cdb94c9 100644 --- a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs @@ -77,6 +77,18 @@ namespace MediaBrowser.Controller.LiveTv /// /// The community rating. public float? CommunityRating { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is repeat. + /// + /// true if this instance is repeat; otherwise, false. + public bool IsRepeat { get; set; } + + /// + /// Gets or sets the episode title. + /// + /// The episode title. + public string EpisodeTitle { get; set; } public ProgramInfo() { diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs index 88d093f645..65e977d75e 100644 --- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs +++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs @@ -1,5 +1,6 @@ using MediaBrowser.Model.LiveTv; using System; +using System.Collections.Generic; namespace MediaBrowser.Controller.LiveTv { @@ -25,6 +26,12 @@ namespace MediaBrowser.Controller.LiveTv /// public string Name { get; set; } + /// + /// Gets or sets the path. + /// + /// The path. + public string Path { get; set; } + /// /// Description of the recording. /// @@ -51,5 +58,27 @@ namespace MediaBrowser.Controller.LiveTv /// /// The status. public RecordingStatus Status { get; set; } + + /// + /// Genre of the program. + /// + public List Genres { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is repeat. + /// + /// true if this instance is repeat; otherwise, false. + public bool IsRepeat { get; set; } + + /// + /// Gets or sets the episode title. + /// + /// The episode title. + public string EpisodeTitle { get; set; } + + public RecordingInfo() + { + Genres = new List(); + } } } diff --git a/MediaBrowser.Controller/LiveTv/SeriesTimerInfo.cs b/MediaBrowser.Controller/LiveTv/SeriesTimerInfo.cs index 178fcff82e..44594882cd 100644 --- a/MediaBrowser.Controller/LiveTv/SeriesTimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/SeriesTimerInfo.cs @@ -71,6 +71,12 @@ namespace MediaBrowser.Controller.LiveTv /// The days. public List Days { get; set; } + /// + /// Gets or sets the priority. + /// + /// The priority. + public int Priority { get; set; } + public SeriesTimerInfo() { Days = new List(); diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 64d5c52260..2beb3588ed 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,6 +110,7 @@ + diff --git a/MediaBrowser.Model/Dto/ItemByNameCounts.cs b/MediaBrowser.Model/Dto/ItemByNameCounts.cs index ae801e1962..31b6d2da0e 100644 --- a/MediaBrowser.Model/Dto/ItemByNameCounts.cs +++ b/MediaBrowser.Model/Dto/ItemByNameCounts.cs @@ -1,4 +1,5 @@ - +using System; + namespace MediaBrowser.Model.Dto { /// @@ -6,6 +7,8 @@ namespace MediaBrowser.Model.Dto /// public class ItemByNameCounts { + public Guid UserId { get; set; } + /// /// Gets or sets the total count. /// diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs index 26cfd3cf00..6884d355d1 100644 --- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs @@ -90,29 +90,17 @@ namespace MediaBrowser.Model.LiveTv public DateTime? OriginalAirDate { get; set; } /// - /// Gets or sets the recording identifier. + /// Gets or sets a value indicating whether this instance is repeat. /// - /// The recording identifier. - public string RecordingId { get; set; } + /// true if this instance is repeat; otherwise, false. + public bool IsRepeat { get; set; } /// - /// Gets or sets the recording status. + /// Gets or sets the episode title. /// - /// The recording status. - public RecordingStatus? RecordingStatus { get; set; } + /// The episode title. + public string EpisodeTitle { get; set; } - /// - /// Gets or sets the timer identifier. - /// - /// The timer identifier. - public string TimerId { get; set; } - - /// - /// Gets or sets the timer status. - /// - /// The timer status. - public RecordingStatus? TimerStatus { get; set; } - public ProgramInfoDto() { Genres = new List(); diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index 926198b93f..9ad6233a67 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace MediaBrowser.Model.LiveTv { @@ -14,13 +15,13 @@ namespace MediaBrowser.Model.LiveTv /// /// The external identifier. public string ExternalId { get; set; } - + /// /// Gets or sets the program identifier. /// /// The program identifier. public string ProgramId { get; set; } - + /// /// ChannelId of the recording. /// @@ -36,6 +37,12 @@ namespace MediaBrowser.Model.LiveTv /// public string Name { get; set; } + /// + /// Gets or sets the path. + /// + /// The path. + public string Path { get; set; } + /// /// Description of the recording. /// @@ -56,5 +63,27 @@ namespace MediaBrowser.Model.LiveTv /// /// The status. public RecordingStatus Status { get; set; } + + /// + /// Genre of the program. + /// + public List Genres { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is repeat. + /// + /// true if this instance is repeat; otherwise, false. + public bool IsRepeat { get; set; } + + /// + /// Gets or sets the episode title. + /// + /// The episode title. + public string EpisodeTitle { get; set; } + + public RecordingInfoDto() + { + Genres = new List(); + } } } \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 90ca64058d..f6291cf36b 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -129,17 +129,13 @@ namespace MediaBrowser.Server.Implementations.Dto /// The user. private void AttachItemByNameCounts(BaseItemDto dto, IItemByName item, User user) { - ItemByNameCounts counts; - if (user == null) { //counts = item.ItemCounts; return; } - if (!item.UserItemCounts.TryGetValue(user.Id, out counts)) - { - counts = new ItemByNameCounts(); - } + + ItemByNameCounts counts = item.GetItemByNameCounts(user.Id) ?? new ItemByNameCounts(); dto.ChildCount = counts.TotalCount; diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs index 1984a24209..40ef5304c6 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs @@ -137,7 +137,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators if (userId.HasValue) { - artist.UserItemCounts[userId.Value] = counts; + artist.SetItemByNameCounts(userId.Value, counts); } } diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs index d21a123c07..c7af7a238f 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GameGenresValidator.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var itemCounts = CountHelpers.GetCounts(counts[libraryId]); - itemByName.UserItemCounts[libraryId] = itemCounts; + itemByName.SetItemByNameCounts(libraryId, itemCounts); } await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs index 0670e1a851..cb1253df07 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/GenresValidator.cs @@ -107,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var itemCounts = CountHelpers.GetCounts(counts[libraryId]); - itemByName.UserItemCounts[libraryId] = itemCounts; + itemByName.SetItemByNameCounts(libraryId, itemCounts); } await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs index 166f557cf0..57a6a612bc 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/MusicGenresValidator.cs @@ -107,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var itemCounts = CountHelpers.GetCounts(counts[libraryId]); - itemByName.UserItemCounts[libraryId] = itemCounts; + itemByName.SetItemByNameCounts(libraryId, itemCounts); } await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs b/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs index cfc7f4310d..0104b2b7ec 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/PeoplePostScanTask.cs @@ -94,7 +94,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var itemCounts = CountHelpers.GetCounts(counts[libraryId]); - itemByName.UserItemCounts[libraryId] = itemCounts; + itemByName.SetItemByNameCounts(libraryId, itemCounts); } } catch (Exception ex) diff --git a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs index 02c7a94b4b..0f4ff562ef 100644 --- a/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs +++ b/MediaBrowser.Server.Implementations/Library/Validators/StudiosValidator.cs @@ -106,7 +106,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators { var itemCounts = CountHelpers.GetCounts(counts[libraryId]); - itemByName.UserItemCounts[libraryId] = itemCounts; + itemByName.SetItemByNameCounts(libraryId, itemCounts); } await itemByName.RefreshMetadata(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs index e1a918fd2e..322948bade 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/ChannelImageProvider.cs @@ -75,7 +75,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv // Dummy up the original url var url = channel.ServiceName + channel.ChannelId; - await _providerManager.SaveImage(channel, response.Content, response.ContentType, ImageType.Primary, null, url, cancellationToken).ConfigureAwait(false); + await _providerManager.SaveImage(channel, response.Stream, response.MimeType, ImageType.Primary, null, url, cancellationToken).ConfigureAwait(false); } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 261c915cb2..704d1ea59c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -209,7 +209,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv OriginalAirDate = program.OriginalAirDate, Audio = program.Audio, CommunityRating = program.CommunityRating, - AspectRatio = program.AspectRatio + AspectRatio = program.AspectRatio, + IsRepeat = program.IsRepeat, + EpisodeTitle = program.EpisodeTitle }; } @@ -297,21 +299,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv var returnArray = programs.ToArray(); - var recordings = await GetRecordings(new RecordingQuery - { - - - }, cancellationToken).ConfigureAwait(false); - - foreach (var program in returnArray) - { - var recording = recordings.Items - .FirstOrDefault(i => string.Equals(i.ProgramId, program.Id)); - - program.RecordingId = recording == null ? null : recording.Id; - program.RecordingStatus = recording == null ? (RecordingStatus?)null : recording.Status; - } - return new QueryResult { Items = returnArray, @@ -400,7 +387,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv Id = id, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), - Status = info.Status + Status = info.Status, + Path = info.Path, + Genres = info.Genres, + IsRepeat = info.IsRepeat, + EpisodeTitle = info.EpisodeTitle }; if (!string.IsNullOrEmpty(info.ProgramId)) diff --git a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs index 8e24bc52d6..e35ba00f2e 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AlbumCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs index 7731e59d2b..b3fd8a023d 100644 --- a/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/EpisodeCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs index 51f39a02f2..605f4d1af4 100644 --- a/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/MovieCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs index 889658459c..6c9c5534d6 100644 --- a/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/MusicVideoCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs index 13d2932cbc..8567e400cd 100644 --- a/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/SeriesCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs index b12e1322a0..85b849a217 100644 --- a/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/SongCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs b/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs index b6f67410a0..a13875674d 100644 --- a/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/TrailerCountComparer.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.Sorting if (itemByName != null) { - var counts = itemByName.GetItemByNameCounts(User); + var counts = itemByName.GetItemByNameCounts(User.Id); if (counts != null) { diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 946ec617bd..c3998aed7a 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.256 + 3.0.257 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 04ac3559c0..aea3230fdb 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.256 + 3.0.257 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index d813a00ace..2a80896c06 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.256 + 3.0.257 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - + -- cgit v1.2.3 From c38fef110ef0d3c9900eef944bc7a616ab92d8d5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 3 Dec 2013 16:11:09 -0500 Subject: improved startup delay --- MediaBrowser.Controller/Entities/Folder.cs | 33 ++++++++-------------- MediaBrowser.Controller/Entities/IndexFolder.cs | 1 - .../Library/LibraryManager.cs | 14 +-------- 3 files changed, 12 insertions(+), 36 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 5c561dc0fc..e8b5831813 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Entities item.Id = item.Path.GetMBId(item.GetType()); } - if (_children.Any(i => i.Id == item.Id)) + if (ActualChildren.Any(i => i.Id == item.Id)) { throw new ArgumentException(string.Format("A child with the Id {0} already exists.", item.Id)); } @@ -108,14 +108,14 @@ namespace MediaBrowser.Controller.Entities await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); - await ItemRepository.SaveChildren(Id, _children.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); + await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); } protected void AddChildrenInternal(IEnumerable children) { lock (_childrenSyncLock) { - var newChildren = _children.ToList(); + var newChildren = ActualChildren.ToList(); newChildren.AddRange(children); _children = newChildren; } @@ -124,7 +124,7 @@ namespace MediaBrowser.Controller.Entities { lock (_childrenSyncLock) { - var newChildren = _children.ToList(); + var newChildren = ActualChildren.ToList(); newChildren.Add(child); _children = newChildren; } @@ -134,7 +134,7 @@ namespace MediaBrowser.Controller.Entities { lock (_childrenSyncLock) { - _children = _children.Except(children).ToList(); + _children = ActualChildren.Except(children).ToList(); } } @@ -519,7 +519,7 @@ namespace MediaBrowser.Controller.Entities /// /// The children /// - private IReadOnlyList _children = new List(); + private IReadOnlyList _children; /// /// The _children sync lock /// @@ -532,15 +532,10 @@ namespace MediaBrowser.Controller.Entities { get { - return _children; + return _children ?? (_children = LoadChildrenInternal()); } } - public void LoadSavedChildren() - { - _children = LoadChildrenInternal(); - } - /// /// thread-safe access to the actual children of this folder - without regard to user /// @@ -758,7 +753,7 @@ namespace MediaBrowser.Controller.Entities AddChildrenInternal(newItems); - await ItemRepository.SaveChildren(Id, _children.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); + await ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken).ConfigureAwait(false); //force the indexes to rebuild next time if (IndexCache != null) @@ -1007,8 +1002,7 @@ namespace MediaBrowser.Controller.Entities return result; } - var initialCount = _children.Count; - var list = new List(initialCount); + var list = new List(); AddChildrenToList(user, includeLinkedChildren, list, false, null); @@ -1070,7 +1064,6 @@ namespace MediaBrowser.Controller.Entities return hasLinkedChildren; } - private int _lastRecursiveCount; /// /// Gets allowed recursive children of an item /// @@ -1098,13 +1091,10 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("user"); } - var initialCount = _lastRecursiveCount == 0 ? _children.Count : _lastRecursiveCount; - var list = new List(initialCount); + var list = new List(); var hasLinkedChildren = AddChildrenToList(user, includeLinkedChildren, list, true, filter); - _lastRecursiveCount = list.Count; - return hasLinkedChildren ? list.DistinctBy(i => i.Id).ToList() : list; } @@ -1124,8 +1114,7 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. public IList GetRecursiveChildren(Func filter) { - var initialCount = _lastRecursiveCount == 0 ? _children.Count : _lastRecursiveCount; - var list = new List(initialCount); + var list = new List(); AddChildrenToList(list, true, filter); diff --git a/MediaBrowser.Controller/Entities/IndexFolder.cs b/MediaBrowser.Controller/Entities/IndexFolder.cs index 35c11ef5ca..57e4a35d3f 100644 --- a/MediaBrowser.Controller/Entities/IndexFolder.cs +++ b/MediaBrowser.Controller/Entities/IndexFolder.cs @@ -40,7 +40,6 @@ namespace MediaBrowser.Controller.Entities IndexName = indexName; Parent = parent; - LoadSavedChildren(); } /// diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 74c4f8b2a8..3b6a5ea25d 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1407,19 +1407,7 @@ namespace MediaBrowser.Server.Implementations.Library /// BaseItem. public BaseItem RetrieveItem(Guid id) { - var item = ItemRepository.RetrieveItem(id); - - if (item != null && item.IsFolder) - { - LoadSavedChildren(item as Folder); - } - - return item; - } - - private void LoadSavedChildren(Folder item) - { - item.LoadSavedChildren(); + return ItemRepository.RetrieveItem(id); } private readonly ConcurrentDictionary _fileLocks = new ConcurrentDictionary(); -- cgit v1.2.3 From 6247929a62790ececc76864acc75f7ac47ee18aa Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 3 Dec 2013 16:12:20 -0500 Subject: #643 - Support episodes directly in series folder --- MediaBrowser.Controller/Entities/TV/Episode.cs | 16 +--------------- MediaBrowser.Controller/Entities/TV/Series.cs | 10 ++++++++++ .../Library/Resolvers/TV/EpisodeResolver.cs | 9 ++++++--- 3 files changed, 17 insertions(+), 18 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 5eab1cae0c..40b999b02a 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -86,7 +86,7 @@ namespace MediaBrowser.Controller.Entities.TV { get { - return Season; + return FindParent(); } } @@ -178,20 +178,6 @@ namespace MediaBrowser.Controller.Entities.TV get { return _series ?? (_series = FindParent()); } } - /// - /// The _season - /// - private Season _season; - /// - /// This Episode's Season Instance - /// - /// The season. - [IgnoreDataMember] - public Season Season - { - get { return _season ?? (_season = FindParent()); } - } - /// /// This is the ending episode number for double episodes. /// diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index f3c7b088a7..b4a3fc811f 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -4,6 +4,7 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities.TV @@ -100,5 +101,14 @@ namespace MediaBrowser.Controller.Entities.TV return args; } + + [IgnoreDataMember] + public bool ContainsEpisodesWithoutSeasonFolders + { + get + { + return Children.OfType /// The post padding seconds. public int PostPaddingSeconds { get; set; } + + /// + /// Gets or sets the duration ms. + /// + /// The duration ms. + public int DurationMs { get; set; } } } diff --git a/MediaBrowser.Providers/TV/SeriesPostScanTask.cs b/MediaBrowser.Providers/TV/SeriesPostScanTask.cs index 055a6c101c..56b06f4906 100644 --- a/MediaBrowser.Providers/TV/SeriesPostScanTask.cs +++ b/MediaBrowser.Providers/TV/SeriesPostScanTask.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index f6291cf36b..f298c2d4d1 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1029,6 +1029,12 @@ namespace MediaBrowser.Server.Implementations.Dto { dto.IndexNumberEnd = episode.IndexNumberEnd; dto.SpecialSeasonNumber = episode.AirsAfterSeasonNumber ?? episode.AirsBeforeSeasonNumber; + + var seasonId = episode.SeasonId; + if (seasonId.HasValue) + { + dto.SeasonId = seasonId.Value.ToString("N"); + } } // Add SeriesInfo diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 704d1ea59c..4fd1f0e43b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -391,9 +391,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv Path = info.Path, Genres = info.Genres, IsRepeat = info.IsRepeat, - EpisodeTitle = info.EpisodeTitle + EpisodeTitle = info.EpisodeTitle, + ChannelType = info.ChannelType, + MediaType = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video, + CommunityRating = info.CommunityRating, + OfficialRating = info.OfficialRating }; + var duration = info.EndDate - info.StartDate; + dto.DurationMs = Convert.ToInt32(duration.TotalMilliseconds); + if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N"); @@ -510,6 +517,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv PostPaddingSeconds = info.PostPaddingSeconds }; + var duration = info.EndDate - info.StartDate; + dto.DurationMs = Convert.ToInt32(duration.TotalMilliseconds); + if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramIdId(service.Name, info.ProgramId).ToString("N"); @@ -563,5 +573,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv await service.CancelTimerAsync(timer.ExternalId, CancellationToken.None).ConfigureAwait(false); } + + public async Task GetRecording(string id, CancellationToken cancellationToken) + { + var results = await GetRecordings(new RecordingQuery(), cancellationToken).ConfigureAwait(false); + + return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.CurrentCulture)); + } + + public async Task GetTimer(string id, CancellationToken cancellationToken) + { + var results = await GetTimers(new TimerQuery(), cancellationToken).ConfigureAwait(false); + + return results.Items.FirstOrDefault(i => string.Equals(i.Id, id, StringComparison.CurrentCulture)); + } } } -- cgit v1.2.3 From 4e79eaf65e8edb895f9337a8b878ff9ef312b3f6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Dec 2013 09:52:38 -0500 Subject: add ApplicationPath to app paths interface to hide implementation --- .../BaseApplicationHost.cs | 15 ++++++--- .../BaseApplicationPaths.cs | 10 +++--- .../Serialization/JsonSerializer.cs | 4 +-- .../Configuration/IApplicationPaths.cs | 6 ++++ MediaBrowser.Controller/Entities/TV/Season.cs | 16 +++++++++ .../HttpServer/HttpResultFactory.cs | 15 ++++++++- .../HttpServer/SwaggerService.cs | 13 ++++++-- .../Providers/ImageSaver.cs | 39 ++++++++++++++++------ .../ServerApplicationPaths.cs | 13 ++++---- MediaBrowser.Server.Mono/Program.cs | 8 +++-- MediaBrowser.ServerApplication/ApplicationHost.cs | 1 + MediaBrowser.ServerApplication/MainStartup.cs | 4 ++- MediaBrowser.WebDashboard/Api/DashboardService.cs | 4 +-- 13 files changed, 110 insertions(+), 38 deletions(-) (limited to 'MediaBrowser.Server.Implementations') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index becf649f44..e8f4d51eb1 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Common.Implementations /// /// The type of the T application paths type. public abstract class BaseApplicationHost : IApplicationHost - where TApplicationPathsType : class, IApplicationPaths, new() + where TApplicationPathsType : class, IApplicationPaths { /// /// Occurs when [has pending restart changed]. @@ -83,7 +83,7 @@ namespace MediaBrowser.Common.Implementations /// /// The json serializer /// - public readonly IJsonSerializer JsonSerializer = new JsonSerializer(); + public IJsonSerializer JsonSerializer { get; private set; } /// /// The _XML serializer @@ -153,7 +153,7 @@ namespace MediaBrowser.Common.Implementations protected IInstallationManager InstallationManager { get; private set; } protected IFileSystem FileSystemManager { get; private set; } - + /// /// Gets or sets the zip client. /// @@ -181,6 +181,8 @@ namespace MediaBrowser.Common.Implementations /// Task. public virtual async Task Init() { + JsonSerializer = CreateJsonSerializer(); + IsFirstRun = !ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted; Logger = LogManager.GetLogger("App"); @@ -212,6 +214,11 @@ namespace MediaBrowser.Common.Implementations } + protected virtual IJsonSerializer CreateJsonSerializer() + { + return new JsonSerializer(); + } + private void SetHttpLimit() { try @@ -224,7 +231,7 @@ namespace MediaBrowser.Common.Implementations Logger.ErrorException("Error setting http limit", ex); } } - + /// /// Installs the iso mounters. /// diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs index bee5e5dc48..ba68d1f5ad 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs @@ -20,21 +20,23 @@ namespace MediaBrowser.Common.Implementations /// /// Initializes a new instance of the class. /// - /// if set to true [use debug paths]. - protected BaseApplicationPaths(bool useDebugPath) + protected BaseApplicationPaths(bool useDebugPath, string applicationPath) { _useDebugPath = useDebugPath; + ApplicationPath = applicationPath; } /// /// Initializes a new instance of the class. /// - /// The program data path. - protected BaseApplicationPaths(string programDataPath) + protected BaseApplicationPaths(string programDataPath, string applicationPath) { _programDataPath = programDataPath; + ApplicationPath = applicationPath; } + public string ApplicationPath { get; private set; } + /// /// The _program data path /// diff --git a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs index 3ff9560405..9c2412b227 100644 --- a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs +++ b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Common.Implementations.Serialization using (Stream stream = File.OpenRead(file)) { - return ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream); + return DeserializeFromStream(stream, type); } } @@ -101,7 +101,7 @@ namespace MediaBrowser.Common.Implementations.Serialization using (Stream stream = File.OpenRead(file)) { - return ServiceStack.Text.JsonSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } diff --git a/MediaBrowser.Common/Configuration/IApplicationPaths.cs b/MediaBrowser.Common/Configuration/IApplicationPaths.cs index d2446ce46d..d3bf033029 100644 --- a/MediaBrowser.Common/Configuration/IApplicationPaths.cs +++ b/MediaBrowser.Common/Configuration/IApplicationPaths.cs @@ -6,6 +6,12 @@ namespace MediaBrowser.Common.Configuration /// public interface IApplicationPaths { + /// + /// Gets the application path. + /// + /// The application path. + string ApplicationPath { get; } + /// /// Gets the path to the program data folder /// diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 0d9e5ec6d1..78e0b8bc4a 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -94,6 +94,22 @@ namespace MediaBrowser.Controller.Entities.TV get { return _series ?? (_series = FindParent()); } } + [IgnoreDataMember] + public string SeriesPath + { + get + { + var series = Series; + + if (series != null) + { + return series.Path; + } + + return System.IO.Path.GetDirectoryName(Path); + } + } + /// /// Our rating comes from our series /// diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index e6942fae6a..5a5a2dd040 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -99,6 +99,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer return result; } + private bool SupportsCompression + { + get + { + return true; + } + } + /// /// Gets the optimized result. /// @@ -116,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer throw new ArgumentNullException("result"); } - var optimizedResult = requestContext.ToOptimizedResult(result); + var optimizedResult = SupportsCompression ? requestContext.ToOptimizedResult(result) : result; if (responseHeaders != null) { @@ -458,6 +466,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } + if (!SupportsCompression) + { + return new HttpResult(content, contentType); + } + var contents = content.Compress(requestContext.CompressionType); return new CompressedResult(contents, requestContext.CompressionType, contentType); diff --git a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs index 20728a30ca..904b6799b4 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs @@ -1,6 +1,6 @@ -using MediaBrowser.Common.Net; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Net; using ServiceStack.ServiceHost; -using System.Diagnostics; using System.IO; namespace MediaBrowser.Server.Implementations.HttpServer @@ -20,6 +20,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer public class SwaggerService : IHasResultFactory, IRestfulService { + private readonly IApplicationPaths _appPaths; + + public SwaggerService(IApplicationPaths appPaths) + { + _appPaths = appPaths; + } + /// /// Gets the specified request. /// @@ -27,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// System.Object. public object Get(GetSwaggerResource request) { - var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath); var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui"); diff --git a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs index 85b17888e6..e2192535c8 100644 --- a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs +++ b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs @@ -6,6 +6,7 @@ using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; using System.Globalization; @@ -13,7 +14,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Logging; namespace MediaBrowser.Server.Implementations.Providers { @@ -89,6 +89,23 @@ namespace MediaBrowser.Server.Implementations.Providers if (locationType == LocationType.Remote || locationType == LocationType.Virtual) { saveLocally = false; + + var season = item as Season; + + // If season is virtual under a physical series, save locally if using compatible convention + if (season != null && _config.Configuration.ImageSavingConvention == ImageSavingConvention.Compatible) + { + var series = season.Series; + + if (series != null) + { + var seriesLocationType = series.LocationType; + if (seriesLocationType == LocationType.FileSystem || seriesLocationType == LocationType.Offline) + { + saveLocally = true; + } + } + } } if (type == ImageType.Backdrop && imageIndex == null) @@ -402,7 +419,7 @@ namespace MediaBrowser.Server.Implementations.Providers return path; } - private string GetBackdropSaveFilename(List images, string zeroIndexFilename, string numberedIndexPrefix, int index) + private string GetBackdropSaveFilename(IEnumerable images, string zeroIndexFilename, string numberedIndexPrefix, int index) { if (index == 0) { @@ -431,6 +448,8 @@ namespace MediaBrowser.Server.Implementations.Providers /// imageIndex private string[] GetCompatibleSavePaths(BaseItem item, ImageType type, int? imageIndex, string mimeType) { + var season = item as Season; + var extension = mimeType.Split('/').Last(); if (string.Equals(extension, "jpeg", StringComparison.OrdinalIgnoreCase)) @@ -449,9 +468,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (imageIndex.Value == 0) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" @@ -481,9 +500,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Primary) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" @@ -518,9 +537,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Banner) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" @@ -534,9 +553,9 @@ namespace MediaBrowser.Server.Implementations.Providers if (type == ImageType.Thumb) { - if (item is Season && item.IndexNumber.HasValue) + if (season != null && item.IndexNumber.HasValue) { - var seriesFolder = Path.GetDirectoryName(item.Path); + var seriesFolder = season.SeriesPath; var seasonMarker = item.IndexNumber.Value == 0 ? "-specials" diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs index fb3c5aec86..db538f8dd0 100644 --- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs +++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs @@ -13,16 +13,16 @@ namespace MediaBrowser.Server.Implementations /// /// Initializes a new instance of the class. /// - public ServerApplicationPaths() - : base(true) + public ServerApplicationPaths(string applicationPath) + : base(true, applicationPath) { } #else /// /// Initializes a new instance of the class. /// - public ServerApplicationPaths() - : base(false) + public ServerApplicationPaths(string applicationPath) + : base(false, applicationPath) { } #endif @@ -30,9 +30,8 @@ namespace MediaBrowser.Server.Implementations /// /// Initializes a new instance of the class. /// - /// The program data path. - public ServerApplicationPaths(string programDataPath) - : base(programDataPath) + public ServerApplicationPaths(string programDataPath, string applicationPath) + : base(programDataPath, applicationPath) { } diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 057a2456f5..d423017fc9 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -36,7 +36,9 @@ namespace MediaBrowser.Server.Mono { Application.Init (); - var appPaths = CreateApplicationPaths(); + var applicationPath = Assembly.GetEntryAssembly ().Location; + + var appPaths = CreateApplicationPaths(applicationPath); var logManager = new NlogManager(appPaths.LogDirectoryPath, "server"); logManager.ReloadLogger(LogSeverity.Info); @@ -65,9 +67,9 @@ namespace MediaBrowser.Server.Mono } } - private static ServerApplicationPaths CreateApplicationPaths() + private static ServerApplicationPaths CreateApplicationPaths(string applicationPath) { - return new ServerApplicationPaths(); + return new ServerApplicationPaths(applicationPath); } /// diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index d2d700839e..f512381528 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -27,6 +27,7 @@ using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Serialization; using MediaBrowser.Model.System; using MediaBrowser.Model.Updates; using MediaBrowser.Providers; diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index d3eed5c484..349cbbc619 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -158,7 +158,9 @@ namespace MediaBrowser.ServerApplication return new ServerApplicationPaths(programDataPath); } - return new ServerApplicationPaths(); + var applicationPath = Process.GetCurrentProcess().MainModule.FileName; + + return new ServerApplicationPaths(applicationPath); } /// diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs index fc89441aef..ee893c613e 100644 --- a/MediaBrowser.WebDashboard/Api/DashboardService.cs +++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs @@ -5,7 +5,6 @@ using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Dto; -using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Plugins; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Logging; @@ -13,7 +12,6 @@ using MediaBrowser.Model.Tasks; using ServiceStack.ServiceHost; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; @@ -151,7 +149,7 @@ namespace MediaBrowser.WebDashboard.Api return _serverConfigurationManager.Configuration.DashboardSourcePath; } - var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + var runningDirectory = Path.GetDirectoryName(_serverConfigurationManager.ApplicationPaths.ApplicationPath); return Path.Combine(runningDirectory, "dashboard-ui"); } -- cgit v1.2.3