From d8d5dd487326dd3fccf4e9f30cd8f7e3783fcfda Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 12 Jan 2015 22:46:44 -0500 Subject: make channel access opt-in rather than opt out --- MediaBrowser.Controller/Entities/User.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MediaBrowser.Controller/Entities/User.cs') diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 626afcfdf..869c30ba8 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -177,7 +177,7 @@ namespace MediaBrowser.Controller.Entities // Exceptions will be thrown if these paths already exist if (Directory.Exists(newConfigDirectory)) { - Directory.Delete(newConfigDirectory, true); + FileSystem.DeleteDirectory(newConfigDirectory, true); } if (Directory.Exists(oldConfigurationDirectory)) -- cgit v1.2.3 From f5919990c9ef80bff28ec8a590acb2f72a806678 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 26 Jan 2015 17:47:16 -0500 Subject: fix failing scan --- .../Entities/Audio/MusicArtist.cs | 18 ++++++------- .../Entities/Audio/MusicGenre.cs | 9 ++++--- MediaBrowser.Controller/Entities/GameGenre.cs | 10 +++++--- MediaBrowser.Controller/Entities/Genre.cs | 11 +++++--- MediaBrowser.Controller/Entities/IItemByName.cs | 2 +- MediaBrowser.Controller/Entities/Person.cs | 13 ++++++---- MediaBrowser.Controller/Entities/Studio.cs | 11 +++++--- MediaBrowser.Controller/Entities/User.cs | 2 ++ MediaBrowser.Controller/Entities/Year.cs | 23 ++++++++++++++--- .../LiveTv/LiveTvAudioRecording.cs | 7 ++++- MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 5 +++- MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 8 +++++- .../LiveTv/LiveTvVideoRecording.cs | 6 ++++- MediaBrowser.Dlna/PlayTo/Device.cs | 30 ++++++++++++++-------- MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs | 23 ++++++++++++----- .../Music/ArtistMetadataService.cs | 4 ++- .../Dto/DtoService.cs | 12 ++++++--- .../Session/SessionManager.cs | 6 +++-- .../Sync/SyncJobProcessor.cs | 2 +- MediaBrowser.XbmcMetadata/EntryPoint.cs | 2 +- 20 files changed, 139 insertions(+), 65 deletions(-) (limited to 'MediaBrowser.Controller/Entities/User.cs') diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 4cc3f1892..038aa98aa 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -20,6 +20,7 @@ namespace MediaBrowser.Controller.Entities.Audio public bool IsAccessedByName { get; set; } public List ProductionLocations { get; set; } + [IgnoreDataMember] public override bool IsFolder { get @@ -78,6 +79,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -90,6 +92,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -177,19 +180,16 @@ namespace MediaBrowser.Controller.Entities.Audio public IEnumerable GetTaggedItems(IEnumerable inputItems) { - return inputItems.Where(ItemFilter); + return inputItems.Where(GetItemFilter()); } - public Func ItemFilter + public Func GetItemFilter() { - get + return i => { - return i => - { - var hasArtist = i as IHasArtist; - return hasArtist != null && hasArtist.HasArtist(Name); - }; - } + var hasArtist = i as IHasArtist; + return hasArtist != null && hasArtist.HasArtist(Name); + }; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index b2c2a1b48..9689d7cce 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -30,6 +30,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -42,6 +43,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -52,13 +54,12 @@ namespace MediaBrowser.Controller.Entities.Audio public IEnumerable GetTaggedItems(IEnumerable inputItems) { - return inputItems.Where(ItemFilter); + return inputItems.Where(GetItemFilter()); } - - public Func ItemFilter + public Func GetItemFilter() { - get { return i => (i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + return i => (i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index d69a6ca46..41ce0c12a 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -20,6 +21,7 @@ namespace MediaBrowser.Controller.Entities /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -32,6 +34,7 @@ namespace MediaBrowser.Controller.Entities /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -42,13 +45,12 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetTaggedItems(IEnumerable inputItems) { - return inputItems.Where(ItemFilter); + return inputItems.Where(GetItemFilter()); } - - public Func ItemFilter + public Func GetItemFilter() { - get { return i => (i is Game) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + return i => (i is Game) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index a33e6131f..f581c55e8 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities.Audio; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities.Audio; using System; using System.Collections.Generic; using System.Linq; @@ -24,6 +25,7 @@ namespace MediaBrowser.Controller.Entities /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -36,6 +38,7 @@ namespace MediaBrowser.Controller.Entities /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -46,12 +49,12 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetTaggedItems(IEnumerable inputItems) { - return inputItems.Where(ItemFilter); + return inputItems.Where(GetItemFilter()); } - public Func ItemFilter + public Func GetItemFilter() { - get { return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } } } diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index e303e9453..b48ad788f 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Entities /// IEnumerable{BaseItem}. IEnumerable GetTaggedItems(IEnumerable inputItems); - Func ItemFilter { get; } + Func GetItemFilter(); } public interface IHasDualAccess : IItemByName diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 19af6e6f0..25509b153 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Providers; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Providers; using System; using System.Collections.Generic; using System.Linq; @@ -15,7 +16,7 @@ namespace MediaBrowser.Controller.Entities /// /// The place of birth. public string PlaceOfBirth { get; set; } - + /// /// Gets the user data key. /// @@ -35,6 +36,7 @@ namespace MediaBrowser.Controller.Entities /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -47,6 +49,7 @@ namespace MediaBrowser.Controller.Entities /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -57,13 +60,13 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetTaggedItems(IEnumerable inputItems) { - return inputItems.Where(ItemFilter); + return inputItems.Where(GetItemFilter()); } - public Func ItemFilter + public Func GetItemFilter() { - get { return i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase)); } + return i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase)); } } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 53c635eba..76193d6c4 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -15,7 +16,7 @@ namespace MediaBrowser.Controller.Entities { Tags = new List(); } - + /// /// Gets the user data key. /// @@ -30,6 +31,7 @@ namespace MediaBrowser.Controller.Entities /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -42,6 +44,7 @@ namespace MediaBrowser.Controller.Entities /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -52,13 +55,13 @@ namespace MediaBrowser.Controller.Entities public IEnumerable GetTaggedItems(IEnumerable inputItems) { - return inputItems.Where(ItemFilter); + return inputItems.Where(GetItemFilter()); } - public Func ItemFilter + public Func GetItemFilter() { - get { return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase); } + return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase); } } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 869c30ba8..ac1ab14de 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -62,6 +62,7 @@ namespace MediaBrowser.Controller.Entities /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -74,6 +75,7 @@ namespace MediaBrowser.Controller.Entities /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index bbf473a9a..59a4bf16d 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -24,6 +25,7 @@ namespace MediaBrowser.Controller.Entities /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -36,6 +38,7 @@ namespace MediaBrowser.Controller.Entities /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -48,8 +51,8 @@ namespace MediaBrowser.Controller.Entities { int year; - var usCulture = new CultureInfo("en-US"); - + var usCulture = new CultureInfo("en-US"); + if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year)) { return inputItems; @@ -58,10 +61,22 @@ namespace MediaBrowser.Controller.Entities return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year); } + public int? GetYearValue() + { + int i; + + if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out i)) + { + return i; + } + + return null; + } - public Func ItemFilter + public Func GetItemFilter() { - get { throw new System.NotImplementedException(); } + var val = GetYearValue(); + return i => i.ProductionYear.HasValue && val.HasValue && i.ProductionYear.Value == val.Value; } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 5cfdb5dbf..8faaa895c 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities.Audio; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Users; @@ -32,6 +33,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -40,6 +42,7 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] public override string MediaType { get @@ -48,6 +51,7 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] public override LocationType LocationType { get @@ -71,6 +75,7 @@ namespace MediaBrowser.Controller.LiveTv return false; } + [IgnoreDataMember] public override bool SupportsLocalMetadata { get diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 72b497026..1948ce0d5 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; @@ -30,6 +31,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -88,6 +90,7 @@ namespace MediaBrowser.Controller.LiveTv return number.ToString("000-") + (Name ?? string.Empty); } + [IgnoreDataMember] public override string MediaType { get diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 6308a71dc..a66aaad6f 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.LiveTv; @@ -138,6 +139,7 @@ namespace MediaBrowser.Controller.LiveTv /// If the item is a folder, it returns the folder itself /// /// The containing folder path. + [IgnoreDataMember] public override string ContainingFolderPath { get @@ -150,6 +152,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get @@ -158,6 +161,7 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] public override string MediaType { get @@ -166,6 +170,7 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] public bool IsAiring { get @@ -176,6 +181,7 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] public bool HasAired { get diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 098400b50..34fe757a7 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using System.Runtime.Serialization; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System.Linq; @@ -28,6 +29,7 @@ namespace MediaBrowser.Controller.LiveTv public string ServiceName { get; set; } + [IgnoreDataMember] public override string MediaType { get @@ -36,6 +38,7 @@ namespace MediaBrowser.Controller.LiveTv } } + [IgnoreDataMember] public override LocationType LocationType { get @@ -53,6 +56,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets a value indicating whether this instance is owned item. /// /// true if this instance is owned item; otherwise, false. + [IgnoreDataMember] public override bool IsOwnedItem { get diff --git a/MediaBrowser.Dlna/PlayTo/Device.cs b/MediaBrowser.Dlna/PlayTo/Device.cs index c43efcd1d..00cb34be3 100644 --- a/MediaBrowser.Dlna/PlayTo/Device.cs +++ b/MediaBrowser.Dlna/PlayTo/Device.cs @@ -712,14 +712,10 @@ namespace MediaBrowser.Dlna.PlayTo if (avService == null) return; - var url = avService.ScpdUrl; - if (!url.Contains("/")) - url = "/dmr/" + url; - if (!url.StartsWith("/")) - url = "/" + url; + string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl); var httpClient = new SsdpHttpClient(_httpClient, _config); - var document = await httpClient.GetDataAsync(Properties.BaseUrl + url); + var document = await httpClient.GetDataAsync(url); AvCommands = TransportCommands.Create(document); } @@ -730,16 +726,28 @@ namespace MediaBrowser.Dlna.PlayTo if (avService == null) return; - string url = avService.ScpdUrl; + string url = NormalizeUrl(Properties.BaseUrl, avService.ScpdUrl); + + var httpClient = new SsdpHttpClient(_httpClient, _config); + var document = await httpClient.GetDataAsync(url); + + RendererCommands = TransportCommands.Create(document); + } + + private string NormalizeUrl(string baseUrl, string url) + { + // If it's already a complete url, don't stick anything onto the front of it + if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + return url; + } + if (!url.Contains("/")) url = "/dmr/" + url; if (!url.StartsWith("/")) url = "/" + url; - var httpClient = new SsdpHttpClient(_httpClient, _config); - var document = await httpClient.GetDataAsync(Properties.BaseUrl + url); - - RendererCommands = TransportCommands.Create(document); + return baseUrl + url; } private TransportCommands AvCommands diff --git a/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs b/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs index ccc7d46e6..f0689751c 100644 --- a/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs +++ b/MediaBrowser.Dlna/PlayTo/SsdpHttpClient.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Net; +using System; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Dlna.Common; using System.Globalization; @@ -29,11 +30,7 @@ namespace MediaBrowser.Dlna.PlayTo string postData, string header = null) { - var serviceUrl = service.ControlUrl; - if (!serviceUrl.StartsWith("/")) - serviceUrl = "/" + serviceUrl; - - var response = await PostSoapDataAsync(baseUrl + serviceUrl, "\"" + service.ServiceType + "#" + command + "\"", postData, header) + var response = await PostSoapDataAsync(NormalizeServiceUrl(baseUrl, service.ControlUrl), "\"" + service.ServiceType + "#" + command + "\"", postData, header) .ConfigureAwait(false); using (var stream = response.Content) @@ -45,6 +42,20 @@ namespace MediaBrowser.Dlna.PlayTo } } + private string NormalizeServiceUrl(string baseUrl, string serviceUrl) + { + // If it's already a complete url, don't stick anything onto the front of it + if (serviceUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + return serviceUrl; + } + + if (!serviceUrl.StartsWith("/")) + serviceUrl = "/" + serviceUrl; + + return baseUrl + serviceUrl; + } + private readonly CultureInfo _usCulture = new CultureInfo("en-US"); public async Task SubscribeAsync(string url, diff --git a/MediaBrowser.Providers/Music/ArtistMetadataService.cs b/MediaBrowser.Providers/Music/ArtistMetadataService.cs index 51c4d18a9..2497cc1ec 100644 --- a/MediaBrowser.Providers/Music/ArtistMetadataService.cs +++ b/MediaBrowser.Providers/Music/ArtistMetadataService.cs @@ -43,8 +43,10 @@ namespace MediaBrowser.Providers.Music { if (!item.IsLocked) { + var itemFilter = item.GetItemFilter(); + var taggedItems = item.IsAccessedByName ? - _libraryManager.RootFolder.GetRecursiveChildren(i => !i.IsFolder && item.ItemFilter(i)).ToList() : + _libraryManager.RootFolder.GetRecursiveChildren(i => !i.IsFolder && itemFilter(i)).ToList() : item.GetRecursiveChildren(i => i is IHasArtist && !i.IsFolder).ToList(); if (!item.LockedFields.Contains(MetadataFields.Genres)) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 5640f2745..06b5138f1 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -95,9 +95,11 @@ namespace MediaBrowser.Server.Implementations.Dto if (byName != null && !(item is LiveTvChannel)) { + var itemFilter = byName.GetItemFilter(); + var libraryItems = user != null ? - user.RootFolder.GetRecursiveChildren(user, byName.ItemFilter) : - _libraryManager.RootFolder.GetRecursiveChildren(byName.ItemFilter); + user.RootFolder.GetRecursiveChildren(user, itemFilter) : + _libraryManager.RootFolder.GetRecursiveChildren(itemFilter); SetItemByNameInfo(item, dto, libraryItems.ToList(), user); } @@ -118,9 +120,11 @@ namespace MediaBrowser.Server.Implementations.Dto if (byName != null && !(item is LiveTvChannel)) { + var itemFilter = byName.GetItemFilter(); + var libraryItems = user != null ? - user.RootFolder.GetRecursiveChildren(user, byName.ItemFilter) : - _libraryManager.RootFolder.GetRecursiveChildren(byName.ItemFilter); + user.RootFolder.GetRecursiveChildren(user, itemFilter) : + _libraryManager.RootFolder.GetRecursiveChildren(itemFilter); SetItemByNameInfo(item, dto, libraryItems.ToList(), user); diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 0613cda30..f1616b85e 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -899,9 +899,11 @@ namespace MediaBrowser.Server.Implementations.Session if (byName != null) { + var itemFilter = byName.GetItemFilter(); + var items = user == null ? - _libraryManager.RootFolder.GetRecursiveChildren(i => !i.IsFolder && byName.ItemFilter(i)) : - user.RootFolder.GetRecursiveChildren(user, i => !i.IsFolder && byName.ItemFilter(i)); + _libraryManager.RootFolder.GetRecursiveChildren(i => !i.IsFolder && itemFilter(i)) : + user.RootFolder.GetRecursiveChildren(user, i => !i.IsFolder && itemFilter(i)); items = items.OrderBy(i => i.SortName); diff --git a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs index fd4474b80..8cad50b91 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncJobProcessor.cs @@ -289,7 +289,7 @@ namespace MediaBrowser.Server.Implementations.Sync if (itemByName != null) { return user.RootFolder - .GetRecursiveChildren(user, itemByName.ItemFilter); + .GetRecursiveChildren(user, itemByName.GetItemFilter()); } if (item.IsFolder) diff --git a/MediaBrowser.XbmcMetadata/EntryPoint.cs b/MediaBrowser.XbmcMetadata/EntryPoint.cs index 4b89785ae..d07633268 100644 --- a/MediaBrowser.XbmcMetadata/EntryPoint.cs +++ b/MediaBrowser.XbmcMetadata/EntryPoint.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.XbmcMetadata return; } - var items = _libraryManager.RootFolder.GetRecursiveChildren(person.ItemFilter); + var items = _libraryManager.RootFolder.GetRecursiveChildren(person.GetItemFilter()); foreach (var item in items) { -- cgit v1.2.3 From b3127f19b546f3edce959dd70cafffb3d422a673 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 27 Jan 2015 01:50:40 -0500 Subject: updated tvdb search --- MediaBrowser.Api/UserService.cs | 2 +- MediaBrowser.Controller/Entities/BaseItem.cs | 14 ++- .../Entities/CollectionFolder.cs | 12 +-- MediaBrowser.Controller/Entities/Folder.cs | 9 +- MediaBrowser.Controller/Entities/IHasMetadata.cs | 5 + MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 1 + MediaBrowser.Controller/Entities/Trailer.cs | 2 +- MediaBrowser.Controller/Entities/User.cs | 10 +- MediaBrowser.Providers/Manager/MetadataService.cs | 4 +- MediaBrowser.Providers/Omdb/OmdbItemProvider.cs | 110 +++++++++++++++++++-- MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs | 13 ++- MediaBrowser.Providers/TV/TvdbSeriesProvider.cs | 39 ++++++-- .../Dto/DtoService.cs | 3 +- .../Localization/Server/server.json | 1 + .../MediaBrowser.WebDashboard.csproj | 5 - 15 files changed, 175 insertions(+), 55 deletions(-) (limited to 'MediaBrowser.Controller/Entities/User.cs') diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 37553e4a4..4f49dd37d 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -455,7 +455,7 @@ namespace MediaBrowser.Api var user = _userManager.GetUserById(id); - var task = user.Name.Equals(dtoUser.Name, StringComparison.Ordinal) ? + var task = string.Equals(user.Name, dtoUser.Name, StringComparison.Ordinal) ? _userManager.UpdateUser(user) : _userManager.RenameUser(user, dtoUser.Name); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index b819d14e5..67be6c2ce 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -894,12 +894,14 @@ namespace MediaBrowser.Controller.Entities /// System.String. public string GetUserDataKey() { - if (!string.IsNullOrWhiteSpace(_userDataKey)) + if (string.IsNullOrWhiteSpace(_userDataKey)) { - return _userDataKey; + var key = CreateUserDataKey(); + _userDataKey = key; + return key; } - return _userDataKey ?? (_userDataKey = CreateUserDataKey()); + return _userDataKey; } protected virtual string CreateUserDataKey() @@ -914,6 +916,12 @@ namespace MediaBrowser.Controller.Entities return current.IsInMixedFolder == newItem.IsInMixedFolder; } + public void AfterMetadataRefresh() + { + _sortName = null; + _userDataKey = null; + } + /// /// Gets the preferred metadata language. /// diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index f47a439a7..5452c63a4 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -121,12 +121,6 @@ namespace MediaBrowser.Controller.Entities return args; } - // Cache this since it will be used a lot - /// - /// The null task result - /// - private static readonly Task NullTaskResult = Task.FromResult(null); - /// /// Compare our current children (presumably just read from the repo) with the current state of the file system and adjust for any changes /// ***Currently does not contain logic to maintain items that are unavailable in the file system*** @@ -138,7 +132,7 @@ namespace MediaBrowser.Controller.Entities /// The refresh options. /// The directory service. /// Task. - protected override async Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) + protected override Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { var list = PhysicalLocationsList.ToList(); @@ -146,8 +140,10 @@ namespace MediaBrowser.Controller.Entities if (!list.SequenceEqual(PhysicalLocationsList)) { - await UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false); + return UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken); } + + return Task.FromResult(true); } /// diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 8c13c7e66..7a902c0c5 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -373,12 +373,7 @@ namespace MediaBrowser.Controller.Entities /// Task. public Task ValidateChildren(IProgress progress, CancellationToken cancellationToken, MetadataRefreshOptions metadataRefreshOptions, bool recursive = true) { - return ValidateChildrenWithCancellationSupport(progress, cancellationToken, recursive, true, metadataRefreshOptions, metadataRefreshOptions.DirectoryService); - } - - private Task ValidateChildrenWithCancellationSupport(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) - { - return ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService); + return ValidateChildrenInternal(progress, cancellationToken, recursive, true, metadataRefreshOptions, metadataRefreshOptions.DirectoryService); } private Dictionary GetActualChildrenDictionary() @@ -676,7 +671,7 @@ namespace MediaBrowser.Controller.Entities } }); - await child.ValidateChildrenWithCancellationSupport(innerProgress, cancellationToken, true, false, null, directoryService) + await child.ValidateChildrenInternal(innerProgress, cancellationToken, true, false, null, directoryService) .ConfigureAwait(false); } } diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 10ddaa474..3643c58b3 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -54,5 +54,10 @@ namespace MediaBrowser.Controller.Entities /// Gets the item identities. /// List Identities { get; set; } + + /// + /// Afters the metadata refresh. + /// + void AfterMetadataRefresh(); } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index dea97aed4..b8f8dcbe1 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -138,6 +138,7 @@ namespace MediaBrowser.Controller.Entities.Movies public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress progress, CancellationToken cancellationToken) { + var b = this; // Refresh bottom up, children first, then the boxset // By then hopefully the movies within will have Tmdb collection values var items = GetRecursiveChildren().ToList(); diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 72e3640f2..522e6edf6 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -1,12 +1,12 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Users; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using MediaBrowser.Model.Users; namespace MediaBrowser.Controller.Entities { diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index ac1ab14de..3c89a9609 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -229,16 +229,16 @@ namespace MediaBrowser.Controller.Entities /// System.String. private string GetConfigurationDirectoryPath(string username) { - if (string.IsNullOrEmpty(username)) - { - throw new ArgumentNullException("username"); - } - var parentPath = ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath; // Legacy if (!UsesIdForConfigurationPath) { + if (string.IsNullOrEmpty(username)) + { + throw new ArgumentNullException("username"); + } + var safeFolderName = FileSystem.GetValidFilename(username); return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName); diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index fc329d64c..baccfa65b 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -114,7 +114,7 @@ namespace MediaBrowser.Providers.Manager catch (Exception ex) { localImagesFailed = true; - Logger.ErrorException("Error validating images for {0}", ex, item.Path ?? item.Name); + Logger.ErrorException("Error validating images for {0}", ex, item.Path ?? item.Name ?? "Unknown name"); refreshResult.AddStatus(ProviderRefreshStatus.Failure, ex.Message); } @@ -182,6 +182,8 @@ namespace MediaBrowser.Providers.Manager { await SaveProviderResult(itemOfType, refreshResult, refreshOptions.DirectoryService).ConfigureAwait(false); } + + itemOfType.AfterMetadataRefresh(); } private void MergeIdentities(TItemType item, TIdType id) diff --git a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs index 1494eaee8..bc87c07c9 100644 --- a/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs @@ -14,6 +14,8 @@ using MediaBrowser.Providers.Movies; using MediaBrowser.Providers.TV; using System; using System.Collections.Generic; +using System.Globalization; +using System.Net; using System.Threading; using System.Threading.Tasks; @@ -35,19 +37,75 @@ namespace MediaBrowser.Providers.Omdb _libraryManager = libraryManager; } - public async Task> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) + public Task> GetSearchResults(SeriesInfo searchInfo, CancellationToken cancellationToken) { - return new List(); + return GetSearchResults(searchInfo, "series", cancellationToken); } - public async Task> GetSearchResults(TrailerInfo searchInfo, CancellationToken cancellationToken) + public Task> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken) { - return new List(); + return GetSearchResults(searchInfo, "movie", cancellationToken); } - public async Task> GetSearchResults(MovieInfo searchInfo, CancellationToken cancellationToken) + public async Task> GetSearchResults(ItemLookupInfo searchInfo, string type, CancellationToken cancellationToken) { - return new List(); + var list = new List(); + + var imdbId = searchInfo.GetProviderId(MetadataProviders.Imdb); + if (!string.IsNullOrWhiteSpace(imdbId)) + { + return list; + } + + var url = "http://www.omdbapi.com/?plot=short&r=json"; + + var name = searchInfo.Name; + var year = searchInfo.Year; + + if (year.HasValue) + { + url += "&y=" + year.Value.ToString(CultureInfo.InvariantCulture); + } + + url += "&t=" + WebUtility.UrlEncode(name); + url += "&type=" + type; + + using (var stream = await _httpClient.Get(new HttpRequestOptions + { + Url = url, + ResourcePool = OmdbProvider.ResourcePool, + CancellationToken = cancellationToken, + CacheMode = CacheMode.Unconditional, + CacheLength = TimeSpan.FromDays(7) + + }).ConfigureAwait(false)) + { + var result = _jsonSerializer.DeserializeFromStream(stream); + + if (string.Equals(result.Response, "true", StringComparison.OrdinalIgnoreCase)) + { + var item = new RemoteSearchResult(); + + item.SearchProviderName = Name; + item.Name = result.Title; + item.SetProviderId(MetadataProviders.Imdb, result.imdbID); + + int parsedYear; + if (int.TryParse(result.Year, NumberStyles.Any, CultureInfo.InvariantCulture, out parsedYear)) + { + item.ProductionYear = parsedYear; + } + + if (!string.IsNullOrWhiteSpace(result.Poster) && !string.Equals(result.Poster, "N/A", StringComparison.OrdinalIgnoreCase)) + { + item.ImageUrl = result.Poster; + } + + list.Add(item); + } + } + + return list; } public Task> GetMetadata(ChannelItemLookupInfo info, CancellationToken cancellationToken) @@ -60,9 +118,14 @@ namespace MediaBrowser.Providers.Omdb return GetMovieResult(info, cancellationToken); } - public async Task> GetSearchResults(ChannelItemLookupInfo searchInfo, CancellationToken cancellationToken) + public Task> GetSearchResults(ChannelItemLookupInfo searchInfo, CancellationToken cancellationToken) { - return new List(); + if (searchInfo.ContentType != ChannelMediaContentType.MovieExtra || searchInfo.ExtraType != ExtraType.Trailer) + { + return Task.FromResult>(new List()); + } + + return GetSearchResults(searchInfo, "movie", cancellationToken); } public string Name @@ -185,7 +248,36 @@ namespace MediaBrowser.Providers.Omdb public Task GetImageResponse(string url, CancellationToken cancellationToken) { - throw new NotImplementedException(); + return _httpClient.GetResponse(new HttpRequestOptions + { + CancellationToken = cancellationToken, + Url = url, + ResourcePool = OmdbProvider.ResourcePool + }); + } + + class SearchResult + { + public string Title { get; set; } + public string Year { get; set; } + public string Rated { get; set; } + public string Released { get; set; } + public string Runtime { get; set; } + public string Genre { get; set; } + public string Director { get; set; } + public string Writer { get; set; } + public string Actors { get; set; } + public string Plot { get; set; } + public string Language { get; set; } + public string Country { get; set; } + public string Awards { get; set; } + public string Poster { get; set; } + public string Metascore { get; set; } + public string imdbRating { get; set; } + public string imdbVotes { get; set; } + public string imdbID { get; set; } + public string Type { get; set; } + public string Response { get; set; } } } } diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs index 52c1ab7dd..cbd3f0af0 100644 --- a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs @@ -28,11 +28,13 @@ namespace MediaBrowser.Providers.TV internal static TvdbEpisodeProvider Current; private readonly IFileSystem _fileSystem; private readonly IServerConfigurationManager _config; + private readonly IHttpClient _httpClient; - public TvdbEpisodeProvider(IFileSystem fileSystem, IServerConfigurationManager config) + public TvdbEpisodeProvider(IFileSystem fileSystem, IServerConfigurationManager config, IHttpClient httpClient) { _fileSystem = fileSystem; _config = config; + _httpClient = httpClient; Current = this; } @@ -731,7 +733,12 @@ namespace MediaBrowser.Providers.TV public Task GetImageResponse(string url, CancellationToken cancellationToken) { - throw new NotImplementedException(); + return _httpClient.GetResponse(new HttpRequestOptions + { + CancellationToken = cancellationToken, + Url = url, + ResourcePool = TvdbSeriesProvider.Current.TvDbResourcePool + }); } public Task FindIdentity(EpisodeInfo info) @@ -743,7 +750,7 @@ namespace MediaBrowser.Providers.TV { return Task.FromResult(null); } - + var id = new EpisodeIdentity { Type = MetadataProviders.Tvdb.ToString(), diff --git a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs index 2be319233..0f7a9f7d8 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesProvider.cs @@ -304,8 +304,6 @@ namespace MediaBrowser.Providers.TV private async Task> FindSeriesInternal(string name, CancellationToken cancellationToken) { - // TODO: Support returning more data, including image url's for the identify function - var url = string.Format(RootUrl + SeriesQuery, WebUtility.UrlEncode(name)); var doc = new XmlDocument(); @@ -330,6 +328,11 @@ namespace MediaBrowser.Providers.TV { foreach (XmlNode node in nodes) { + var searchResult = new RemoteSearchResult + { + SearchProviderName = Name + }; + var titles = new List(); var nameNode = node.SelectSingleNode("./SeriesName"); @@ -345,19 +348,35 @@ namespace MediaBrowser.Providers.TV titles.AddRange(alias); } + var imdbIdNode = node.SelectSingleNode("./IMDB_ID"); + if (imdbIdNode != null) + { + var val = imdbIdNode.InnerText; + if (!string.IsNullOrWhiteSpace(val)) + { + searchResult.SetProviderId(MetadataProviders.Imdb, val); + } + } + + var bannerNode = node.SelectSingleNode("./banner"); + if (bannerNode != null) + { + var val = bannerNode.InnerText; + if (!string.IsNullOrWhiteSpace(val)) + { + searchResult.ImageUrl = TVUtils.BannerUrl + val; + } + } + if (titles.Any(t => string.Equals(t, comparableName, StringComparison.OrdinalIgnoreCase))) { - var id = node.SelectSingleNode("./seriesid"); + var id = node.SelectSingleNode("./seriesid") ?? + node.SelectSingleNode("./id"); + if (id != null) { - var searchResult = new RemoteSearchResult - { - Name = titles.FirstOrDefault(), - SearchProviderName = Name - }; - + searchResult.Name = titles.FirstOrDefault(); searchResult.SetProviderId(MetadataProviders.Tvdb, id.InnerText); - searchResults.Add(searchResult); } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 06b5138f1..0fa37435b 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -162,8 +162,7 @@ namespace MediaBrowser.Server.Implementations.Dto { SyncJobItemStatus.Converting, SyncJobItemStatus.Queued, - SyncJobItemStatus.Transferring, - SyncJobItemStatus.Synced + SyncJobItemStatus.Transferring } }); diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index d75a1bc3f..3e9c75220 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -56,6 +56,7 @@ "HeaderVideo": "Video", "HeaderPaths": "Paths", "CategorySync": "Sync", + "RegisterWithPayPal": "Register with PayPal", "HeaderSyncRequiresSupporterMembership": "Sync Requires a Supporter Membership", "HeaderEnjoyDayTrial": "Enjoy a 14 Day Free Trial", "LabelSyncTempPath": "Temporary file path:", diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 72f3a5757..0072ba257 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -2167,11 +2167,6 @@ PreserveNewest - - - PreserveNewest - - PreserveNewest -- cgit v1.2.3 From 782fe92cf766c09c84200e9e2228e555e6644add Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 27 Jan 2015 17:45:59 -0500 Subject: support artists tag value --- MediaBrowser.Api/SearchService.cs | 13 ++----- MediaBrowser.Api/VideosService.cs | 1 - .../Entities/AggregateFolder.cs | 2 +- .../Entities/Audio/MusicAlbum.cs | 6 ---- .../Entities/CollectionFolder.cs | 2 +- MediaBrowser.Controller/Entities/User.cs | 2 +- MediaBrowser.Controller/Library/ItemResolveArgs.cs | 18 ++-------- MediaBrowser.Model/Entities/MetadataProviders.cs | 3 +- MediaBrowser.Model/Sync/SyncJobCreationResult.cs | 9 ++++- MediaBrowser.Providers/Manager/ImageSaver.cs | 3 +- .../MediaInfo/FFProbeAudioInfo.cs | 40 +++++++++++++++++----- MediaBrowser.Providers/Music/MusicExternalIds.cs | 23 +++++++++++++ .../Library/LibraryManager.cs | 11 +++--- .../Library/Resolvers/SpecialFolderResolver.cs | 7 ++-- .../Sorting/AiredEpisodeOrderComparer.cs | 2 ++ .../Sync/SyncManager.cs | 9 ++++- 16 files changed, 94 insertions(+), 57 deletions(-) (limited to 'MediaBrowser.Controller/Entities/User.cs') diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs index 4dcf72407..ee48946d5 100644 --- a/MediaBrowser.Api/SearchService.cs +++ b/MediaBrowser.Api/SearchService.cs @@ -208,17 +208,10 @@ namespace MediaBrowser.Api if (album != null) { - var songs = album.GetRecursiveChildren(i => i is Audio) - .Cast private readonly IServerApplicationPaths _appPaths; - private readonly ILibraryManager _libraryManager; public IDirectoryService DirectoryService { get; private set; } @@ -25,11 +24,10 @@ namespace MediaBrowser.Controller.Library /// Initializes a new instance of the class. /// /// The app paths. - /// The library manager. - public ItemResolveArgs(IServerApplicationPaths appPaths, ILibraryManager libraryManager, IDirectoryService directoryService) + /// The directory service. + public ItemResolveArgs(IServerApplicationPaths appPaths, IDirectoryService directoryService) { _appPaths = appPaths; - _libraryManager = libraryManager; DirectoryService = directoryService; } @@ -136,18 +134,6 @@ namespace MediaBrowser.Controller.Library } } - /// - /// Gets a value indicating whether this instance is root. - /// - /// true if this instance is root; otherwise, false. - public bool IsRoot - { - get - { - return Parent == null; - } - } - /// /// Gets or sets the additional locations. /// diff --git a/MediaBrowser.Model/Entities/MetadataProviders.cs b/MediaBrowser.Model/Entities/MetadataProviders.cs index e86773789..7644b150a 100644 --- a/MediaBrowser.Model/Entities/MetadataProviders.cs +++ b/MediaBrowser.Model/Entities/MetadataProviders.cs @@ -40,6 +40,7 @@ namespace MediaBrowser.Model.Entities NesBoxRom = 14, TvRage = 15, AudioDbArtist = 16, - AudioDbAlbum = 17 + AudioDbAlbum = 17, + MusicBrainzTrack = 18 } } diff --git a/MediaBrowser.Model/Sync/SyncJobCreationResult.cs b/MediaBrowser.Model/Sync/SyncJobCreationResult.cs index 797318b2a..6723aa2cf 100644 --- a/MediaBrowser.Model/Sync/SyncJobCreationResult.cs +++ b/MediaBrowser.Model/Sync/SyncJobCreationResult.cs @@ -1,8 +1,15 @@ - +using System.Collections.Generic; + namespace MediaBrowser.Model.Sync { public class SyncJobCreationResult { public SyncJob Job { get; set; } + public List JobItems { get; set; } + + public SyncJobCreationResult() + { + JobItems = new List(); + } } } diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index c5c6880e1..a8e16e4ae 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -1,6 +1,5 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; -using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -9,6 +8,7 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.Net; using System; using System.Collections.Generic; using System.Globalization; @@ -16,7 +16,6 @@ using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Net; namespace MediaBrowser.Providers.Manager { diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs index b51af0d8a..ad2b6ed0f 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeAudioInfo.cs @@ -187,18 +187,27 @@ namespace MediaBrowser.Providers.MediaInfo audio.Album = FFProbeHelpers.GetDictionaryValue(tags, "album"); - var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist"); + var artists = FFProbeHelpers.GetDictionaryValue(tags, "artists"); - if (string.IsNullOrWhiteSpace(artist)) + if (!string.IsNullOrWhiteSpace(artists)) { - audio.Artists.Clear(); + audio.Artists = artists.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToList(); } else { - audio.Artists = SplitArtists(artist) - .Distinct(StringComparer.OrdinalIgnoreCase) - .ToList(); - + var artist = FFProbeHelpers.GetDictionaryValue(tags, "artist"); + if (string.IsNullOrWhiteSpace(artist)) + { + audio.Artists.Clear(); + } + else + { + audio.Artists = SplitArtists(artist) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToList(); + } } var albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "albumartist") ?? FFProbeHelpers.GetDictionaryValue(tags, "album artist") ?? FFProbeHelpers.GetDictionaryValue(tags, "album_artist"); @@ -250,10 +259,23 @@ namespace MediaBrowser.Providers.MediaInfo FetchStudios(audio, tags, "publisher"); } - audio.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id")); - audio.SetProviderId(MetadataProviders.MusicBrainzArtist, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id")); + // These support mulitple values, but for now we only store the first. + audio.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Artist Id"))); + audio.SetProviderId(MetadataProviders.MusicBrainzArtist, GetMultipleMusicBrainzId(FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Artist Id"))); + audio.SetProviderId(MetadataProviders.MusicBrainzAlbum, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Album Id")); audio.SetProviderId(MetadataProviders.MusicBrainzReleaseGroup, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Group Id")); + audio.SetProviderId(MetadataProviders.MusicBrainzTrack, FFProbeHelpers.GetDictionaryValue(tags, "MusicBrainz Release Track Id")); + } + + private string GetMultipleMusicBrainzId(string value) + { + if (string.IsNullOrWhiteSpace(value)) + { + return null; + } + + return value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); } private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' }; diff --git a/MediaBrowser.Providers/Music/MusicExternalIds.cs b/MediaBrowser.Providers/Music/MusicExternalIds.cs index a4eab1eee..bcafdc6f6 100644 --- a/MediaBrowser.Providers/Music/MusicExternalIds.cs +++ b/MediaBrowser.Providers/Music/MusicExternalIds.cs @@ -118,4 +118,27 @@ namespace MediaBrowser.Providers.Music return item is Audio || item is MusicAlbum; } } + + public class MusicBrainzTrackId : IExternalId + { + public string Name + { + get { return "MusicBrainz Track"; } + } + + public string Key + { + get { return MetadataProviders.MusicBrainzTrack.ToString(); } + } + + public string UrlFormatString + { + get { return "http://musicbrainz.org/track/{0}"; } + } + + public bool Supports(IHasProviderIds item) + { + return item is Audio; + } + } } diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 124bb396e..d7ea444a3 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -13,7 +13,6 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Resolvers; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Naming.Audio; @@ -579,7 +578,7 @@ namespace MediaBrowser.Server.Implementations.Library collectionType = GetContentTypeOverride(fullPath, true); } - var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, this, directoryService) + var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService) { Parent = parent, Path = fullPath, @@ -753,12 +752,14 @@ namespace MediaBrowser.Server.Implementations.Library Directory.CreateDirectory(userRootPath); - _userRootFolder = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder; + var tmpItem = GetItemById(GetNewItemId(userRootPath, typeof(UserRootFolder))) as UserRootFolder; - if (_userRootFolder == null) + if (tmpItem == null) { - _userRootFolder = (UserRootFolder)ResolvePath(new DirectoryInfo(userRootPath)); + tmpItem = (UserRootFolder)ResolvePath(new DirectoryInfo(userRootPath)); } + + _userRootFolder = tmpItem; } } } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs index 0a41a6c04..31b2d8b0f 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/SpecialFolderResolver.cs @@ -1,4 +1,5 @@ using MediaBrowser.Common.IO; +using MediaBrowser.Controller; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Resolvers; @@ -11,10 +12,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers class SpecialFolderResolver : FolderResolver { private readonly IFileSystem _fileSystem; + private readonly IServerApplicationPaths _appPaths; - public SpecialFolderResolver(IFileSystem fileSystem) + public SpecialFolderResolver(IFileSystem fileSystem, IServerApplicationPaths appPaths) { _fileSystem = fileSystem; + _appPaths = appPaths; } /// @@ -39,7 +42,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers { return new AggregateFolder(); } - if (args.IsRoot) + if (string.Equals(args.Path, _appPaths.DefaultUserViewsPath, StringComparison.OrdinalIgnoreCase)) { return new UserRootFolder(); //if we got here and still a root - must be user root } diff --git a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 8707f2e5b..c7bbca060 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -72,6 +72,8 @@ namespace MediaBrowser.Server.Implementations.Sorting private int CompareEpisodeToSpecial(Episode x, Episode y) { + // http://thetvdb.com/wiki/index.php?title=Special_Episodes + var xSeason = x.PhysicalSeasonNumber ?? -1; var ySeason = y.AirsAfterSeasonNumber ?? y.AirsBeforeSeasonNumber ?? -1; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index cdbb0d5e5..71bc0e46b 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -158,9 +158,16 @@ namespace MediaBrowser.Server.Implementations.Sync }, _logger); } + jobItemsResult = _repo.GetJobItems(new SyncJobItemQuery + { + Statuses = new List { SyncJobItemStatus.Queued, SyncJobItemStatus.Converting }, + JobId = jobId + }); + return new SyncJobCreationResult { - Job = GetJob(jobId) + Job = GetJob(jobId), + JobItems = jobItemsResult.Items.ToList() }; } -- cgit v1.2.3 From a6145e54d901095e5b67704e3103843b4b515681 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 29 Jan 2015 01:06:24 -0500 Subject: support in-home easy password --- MediaBrowser.Api/UserService.cs | 78 +++++++++++++++++++++- .../Networking/BaseNetworkManager.cs | 25 +++++-- MediaBrowser.Controller/Entities/User.cs | 2 +- MediaBrowser.Controller/Library/IUserManager.cs | 15 +++++ MediaBrowser.Model/Dto/UserDto.cs | 6 ++ .../Library/UserManager.cs | 54 ++++++++++----- .../Localization/JavaScript/javascript.json | 5 +- .../Localization/Server/server.json | 8 ++- 8 files changed, 165 insertions(+), 28 deletions(-) (limited to 'MediaBrowser.Controller/Entities/User.cs') diff --git a/MediaBrowser.Api/UserService.cs b/MediaBrowser.Api/UserService.cs index 4f49dd37d..2c497d172 100644 --- a/MediaBrowser.Api/UserService.cs +++ b/MediaBrowser.Api/UserService.cs @@ -11,7 +11,6 @@ using MediaBrowser.Model.Connect; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Users; using ServiceStack; -using ServiceStack.Text.Controller; using System; using System.Collections.Generic; using System.Linq; @@ -148,6 +147,32 @@ namespace MediaBrowser.Api public bool ResetPassword { get; set; } } + /// + /// Class UpdateUserEasyPassword + /// + [Route("/Users/{Id}/EasyPassword", "POST", Summary = "Updates a user's easy password")] + [Authenticated] + public class UpdateUserEasyPassword : IReturnVoid + { + /// + /// Gets or sets the id. + /// + /// The id. + public string Id { get; set; } + + /// + /// Gets or sets the new password. + /// + /// The new password. + public string NewPassword { get; set; } + + /// + /// Gets or sets a value indicating whether [reset password]. + /// + /// true if [reset password]; otherwise, false. + public bool ResetPassword { get; set; } + } + /// /// Class UpdateUser /// @@ -410,6 +435,8 @@ namespace MediaBrowser.Api public async Task PostAsync(UpdateUserPassword request) { + AssertCanUpdateUser(request.Id); + var user = _userManager.GetUserById(request.Id); if (user == null) @@ -434,6 +461,33 @@ namespace MediaBrowser.Api } } + public void Post(UpdateUserEasyPassword request) + { + var task = PostAsync(request); + Task.WaitAll(task); + } + + public async Task PostAsync(UpdateUserEasyPassword request) + { + AssertCanUpdateUser(request.Id); + + var user = _userManager.GetUserById(request.Id); + + if (user == null) + { + throw new ResourceNotFoundException("User not found"); + } + + if (request.ResetPassword) + { + await _userManager.ResetEasyPassword(user).ConfigureAwait(false); + } + else + { + await _userManager.ChangeEasyPassword(user, request.NewPassword).ConfigureAwait(false); + } + } + /// /// Posts the specified request. /// @@ -449,7 +503,9 @@ namespace MediaBrowser.Api { // We need to parse this manually because we told service stack not to with IRequiresRequestStream // https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs - var id = new Guid(GetPathValue(1)); + var id = GetPathValue(1); + + AssertCanUpdateUser(id); var dtoUser = request; @@ -499,11 +555,29 @@ namespace MediaBrowser.Api public void Post(UpdateUserConfiguration request) { + AssertCanUpdateUser(request.Id); + var task = _userManager.UpdateConfiguration(request.Id, request); Task.WaitAll(task); } + private void AssertCanUpdateUser(string userId) + { + var auth = AuthorizationContext.GetAuthorizationInfo(Request); + + // If they're going to update the record of another user, they must be an administrator + if (!string.Equals(userId, auth.UserId, StringComparison.OrdinalIgnoreCase)) + { + var authenticatedUser = _userManager.GetUserById(auth.UserId); + + if (!authenticatedUser.Policy.IsAdministrator) + { + throw new SecurityException("Unauthorized access."); + } + } + } + public void Post(UpdateUserPolicy request) { var task = UpdateUserPolicy(request); diff --git a/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs b/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs index 660ac09f9..6deda1293 100644 --- a/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs +++ b/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.Common.Implementations.Networking { NetworkChange.NetworkAddressChanged -= NetworkChange_NetworkAddressChanged; NetworkChange.NetworkAvailabilityChanged -= NetworkChange_NetworkAvailabilityChanged; - + NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged; NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged; } @@ -106,6 +106,11 @@ namespace MediaBrowser.Common.Implementations.Networking // Private address space: // http://en.wikipedia.org/wiki/Private_network + if (endpoint.StartsWith("172.", StringComparison.OrdinalIgnoreCase)) + { + return Is172AddressPrivate(endpoint); + } + return // If url was requested with computer name, we may see this @@ -114,11 +119,23 @@ namespace MediaBrowser.Common.Implementations.Networking endpoint.StartsWith("localhost", StringComparison.OrdinalIgnoreCase) || endpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) || endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) || - endpoint.StartsWith("192.", StringComparison.OrdinalIgnoreCase) || - endpoint.StartsWith("172.", StringComparison.OrdinalIgnoreCase) || + endpoint.StartsWith("192.168", StringComparison.OrdinalIgnoreCase) || endpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase); } + private bool Is172AddressPrivate(string endpoint) + { + for (var i = 16; i <= 31; i++) + { + if (endpoint.StartsWith("172." + i.ToString(CultureInfo.InvariantCulture) + ".", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + + return false; + } + public bool IsInLocalNetwork(string endpoint) { return IsInLocalNetworkInternal(endpoint, true); @@ -175,7 +192,7 @@ namespace MediaBrowser.Common.Implementations.Networking return false; } - + public IEnumerable GetIpAddresses(string hostName) { return Dns.GetHostAddresses(hostName); diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 1fca676a9..01a7486b3 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Entities /// /// The password. public string Password { get; set; } - public string LocalPassword { get; set; } + public string EasyPassword { get; set; } public string ConnectUserName { get; set; } public string ConnectUserId { get; set; } diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index f5846973e..5aa58aa57 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -117,6 +117,13 @@ namespace MediaBrowser.Controller.Library /// Task. Task ResetPassword(User user); + /// + /// Resets the easy password. + /// + /// The user. + /// Task. + Task ResetEasyPassword(User user); + /// /// Changes the password. /// @@ -125,6 +132,14 @@ namespace MediaBrowser.Controller.Library /// Task. Task ChangePassword(User user, string newPasswordSha1); + /// + /// Changes the easy password. + /// + /// The user. + /// The new password sha1. + /// Task. + Task ChangeEasyPassword(User user, string newPasswordSha1); + /// /// Gets the user dto. /// diff --git a/MediaBrowser.Model/Dto/UserDto.cs b/MediaBrowser.Model/Dto/UserDto.cs index 9b6d92030..3e2d869d6 100644 --- a/MediaBrowser.Model/Dto/UserDto.cs +++ b/MediaBrowser.Model/Dto/UserDto.cs @@ -66,6 +66,12 @@ namespace MediaBrowser.Model.Dto /// /// true if this instance has configured password; otherwise, false. public bool HasConfiguredPassword { get; set; } + + /// + /// Gets or sets a value indicating whether this instance has configured easy password. + /// + /// true if this instance has configured easy password; otherwise, false. + public bool HasConfiguredEasyPassword { get; set; } /// /// Gets or sets the last login date. diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 6b6f5b1b6..a001b25b6 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -275,9 +275,9 @@ namespace MediaBrowser.Server.Implementations.Library private string GetLocalPasswordHash(User user) { - return string.IsNullOrEmpty(user.LocalPassword) + return string.IsNullOrEmpty(user.EasyPassword) ? GetSha1String(string.Empty) - : user.LocalPassword; + : user.EasyPassword; } private bool IsPasswordEmpty(string passwordHash) @@ -355,18 +355,20 @@ namespace MediaBrowser.Server.Implementations.Library var passwordHash = GetPasswordHash(user); - var hasConfiguredDefaultPassword = !IsPasswordEmpty(passwordHash); + var hasConfiguredPassword = !IsPasswordEmpty(passwordHash); + var hasConfiguredEasyPassword = !IsPasswordEmpty(GetLocalPasswordHash(user)); var hasPassword = user.Configuration.EnableLocalPassword && !string.IsNullOrEmpty(remoteEndPoint) && _networkManager.IsInLocalNetwork(remoteEndPoint) ? - !IsPasswordEmpty(GetLocalPasswordHash(user)) : - hasConfiguredDefaultPassword; + hasConfiguredEasyPassword : + hasConfiguredPassword; var dto = new UserDto { Id = user.Id.ToString("N"), Name = user.Name, HasPassword = hasPassword, - HasConfiguredPassword = hasConfiguredDefaultPassword, + HasConfiguredPassword = hasConfiguredPassword, + HasConfiguredEasyPassword = hasConfiguredEasyPassword, LastActivityDate = user.LastActivityDate, LastLoginDate = user.LastLoginDate, Configuration = user.Configuration, @@ -613,18 +615,11 @@ namespace MediaBrowser.Server.Implementations.Library return ChangePassword(user, GetSha1String(string.Empty)); } - /// - /// Changes the password. - /// - /// The user. - /// The new password sha1. - /// Task. - /// - /// user - /// or - /// newPassword - /// - /// Passwords for guests cannot be changed. + public Task ResetEasyPassword(User user) + { + return ChangeEasyPassword(user, GetSha1String(string.Empty)); + } + public async Task ChangePassword(User user, string newPasswordSha1) { if (user == null) @@ -648,6 +643,29 @@ namespace MediaBrowser.Server.Implementations.Library EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); } + public async Task ChangeEasyPassword(User user, string newPasswordSha1) + { + if (user == null) + { + throw new ArgumentNullException("user"); + } + if (string.IsNullOrWhiteSpace(newPasswordSha1)) + { + throw new ArgumentNullException("newPasswordSha1"); + } + + if (user.ConnectLinkType.HasValue && user.ConnectLinkType.Value == UserLinkType.Guest) + { + throw new ArgumentException("Passwords for guests cannot be changed."); + } + + user.EasyPassword = newPasswordSha1; + + await UpdateUser(user).ConfigureAwait(false); + + EventHelper.FireEventIfNotNull(UserPasswordChanged, this, new GenericEventArgs(user), _logger); + } + /// /// Instantiates the new user. /// diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index ede08a49c..2dcd6eca5 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -14,9 +14,12 @@ "FileReadError": "An error occurred while reading the file.", "DeleteUser": "Delete User", "DeleteUserConfirmation": "Are you sure you wish to delete this user?", - "PasswordResetHeader": "Password Reset", + "PasswordResetHeader": "Reset Password", "PasswordResetComplete": "The password has been reset.", + "PinCodeResetComplete": "The pin code has been reset.", "PasswordResetConfirmation": "Are you sure you wish to reset the password?", + "PinCodeResetConfirmation": "Are you sure you wish to reset the pin code?", + "HeaderPinCodeReset": "Reset Pin Code", "PasswordSaved": "Password saved.", "PasswordMatchError": "Password and password confirmation must match.", "OptionRelease": "Official Release", diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 3e9c75220..93ef75dc3 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -56,6 +56,7 @@ "HeaderVideo": "Video", "HeaderPaths": "Paths", "CategorySync": "Sync", + "HeaderEasyPinCode": "Easy Pin Code", "RegisterWithPayPal": "Register with PayPal", "HeaderSyncRequiresSupporterMembership": "Sync Requires a Supporter Membership", "HeaderEnjoyDayTrial": "Enjoy a 14 Day Free Trial", @@ -1132,11 +1133,14 @@ "LabelDisplayFoldersView": "Display a folders view to show plain media folders", "ViewTypeLiveTvRecordingGroups": "Recordings", "ViewTypeLiveTvChannels": "Channels", - "LabelAllowLocalAccessWithoutPassword": "Allow local access without a password", - "LabelAllowLocalAccessWithoutPasswordHelp": "When enabled, a password will not be required when signing in from within your home network.", + "LabelEasyPinCode": "Easy pin code:", + "EasyPasswordHelp": "Your easy pin code is used for offline access with supported Media Browser apps, and can also be used for easy in-network sign in.", + "LabelInNetworkSignInWithEasyPassword": "Enable in-network sign in with my easy pin code", + "LabelInNetworkSignInWithEasyPasswordHelp": "If enabled, you'll be able to use your easy pin code to sign in to Media Browser apps from inside your home network. Your regular password will only be needed away from home. If the pin code is left blank, you won't need a password within your home network.", "HeaderPassword": "Password", "HeaderLocalAccess": "Local Access", "HeaderViewOrder": "View Order", + "ButtonResetEasyPassword": "Reset easy pin code", "LabelSelectUserViewOrder": "Choose the order your views will be displayed in within Media Browser apps", "LabelMetadataRefreshMode": "Metadata refresh mode:", "LabelImageRefreshMode": "Image refresh mode:", -- cgit v1.2.3