From c1b68356c4c7175f5d1241fca3ba61af1b407ce2 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 7 Jun 2016 01:42:26 -0400 Subject: [PATCH 1/3] use shared alpha picker --- .../Library/LibraryManager.cs | 4 ++++ .../LiveTv/Listings/XmlTvListingsProvider.cs | 19 ++++++++++++------- .../MediaBrowser.WebDashboard.csproj | 3 --- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 032f8dbb7..503fb1aa7 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -362,6 +362,10 @@ namespace MediaBrowser.Server.Implementations.Library return; } } + if (item is Photo) + { + return; + } //if (!(item is Folder)) //{ // return; diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 4d2fc8bfe..e0ef67dcd 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -71,31 +71,36 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings })); } - public async Task AddMetadata(ListingsProviderInfo info, List channels, CancellationToken cancellationToken) + public Task AddMetadata(ListingsProviderInfo info, List channels, CancellationToken cancellationToken) { // Add the channel image url var reader = new XmlTvReader(info.Path, GetLanguage(), null); var results = reader.GetChannels().ToList(); if (channels != null && channels.Count > 0) - { - channels.ForEach(c => { + { + channels.ForEach(c => + { var match = results.FirstOrDefault(r => r.Id == c.Id); if (match != null && match.Icon != null && !String.IsNullOrEmpty(match.Icon.Source)) { c.ImageUrl = match.Icon.Source; } }); - } + } + + return Task.FromResult(true); } - public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) + public Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) { - // Check that the path or url is valid. If not, throw a file not found exception - if (!File.Exists(info.Path)) + // Assume all urls are valid. check files for existence + if (!info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) && !File.Exists(info.Path)) { throw new FileNotFoundException("Could not find the XmlTv file specified:", info.Path); } + + return Task.FromResult(true); } public Task> GetLineups(ListingsProviderInfo info, string country, string location) diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index d6c1ad6bc..94b2adf2c 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -1122,9 +1122,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest From 7be8a519a35702ec24c9c69ef27766a354fd0960 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 7 Jun 2016 02:14:13 -0400 Subject: [PATCH 2/3] add xml tv download --- .../LiveTv/Listings/XmlTvListingsProvider.cs | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index e0ef67dcd..328dd9979 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -3,12 +3,14 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; using Emby.XmlTv.Classes; +using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; namespace MediaBrowser.Server.Implementations.LiveTv.Listings @@ -16,10 +18,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings public class XmlTvListingsProvider : IListingsProvider { private readonly IServerConfigurationManager _config; + private readonly IHttpClient _httpClient; - public XmlTvListingsProvider(IServerConfigurationManager config) + public XmlTvListingsProvider(IServerConfigurationManager config, IHttpClient httpClient) { _config = config; + _httpClient = httpClient; } public string Name @@ -37,13 +41,39 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings return _config.Configuration.PreferredMetadataLanguage; } - // TODO: Should this method be async? - public Task> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, string channelName, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) + private async Task GetXml(string path, CancellationToken cancellationToken) { - var reader = new XmlTvReader(info.Path, GetLanguage(), null); + if (!path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + return path; + } + + var cacheFilename = DateTime.UtcNow.DayOfYear.ToString(CultureInfo.InvariantCulture) + "_" + DateTime.UtcNow.Hour.ToString(CultureInfo.InvariantCulture) + ".xml"; + var cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename); + if (File.Exists(cacheFile)) + { + return cacheFile; + } + + var tempFile = await _httpClient.GetTempFile(new HttpRequestOptions + { + CancellationToken = cancellationToken, + Url = path + + }).ConfigureAwait(false); + File.Copy(tempFile, cacheFile, true); + + return cacheFile; + } + + // TODO: Should this method be async? + public async Task> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, string channelName, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) + { + var path = await GetXml(info.Path, cancellationToken).ConfigureAwait(false); + var reader = new XmlTvReader(path, GetLanguage(), null); var results = reader.GetProgrammes(channelNumber, startDateUtc, endDateUtc, cancellationToken); - return Task.FromResult(results.Select(p => new ProgramInfo() + return results.Select(p => new ProgramInfo() { ChannelId = p.ChannelId, EndDate = p.EndDate, @@ -68,7 +98,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source), OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null, CommunityRating = p.StarRating.HasValue ? p.StarRating.Value : (float?)null - })); + }); } public Task AddMetadata(ListingsProviderInfo info, List channels, CancellationToken cancellationToken) From 0ad015043532f498e382a5ea4ce4b77a7976b516 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 7 Jun 2016 12:21:46 -0400 Subject: [PATCH 3/3] update nuget --- .../Configuration/ServerConfiguration.cs | 6 ++- .../Music/MusicBrainzAlbumProvider.cs | 2 +- ...MediaBrowser.Server.Implementations.csproj | 2 +- .../packages.config | 2 +- .../ApplicationHost.cs | 37 +++++++++++++++---- 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 0ce69970f..1eb169bf9 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -67,7 +67,7 @@ namespace MediaBrowser.Model.Configuration /// /// true if [enable case sensitive item ids]; otherwise, false. public bool EnableCaseSensitiveItemIds { get; set; } - + /// /// Gets or sets the metadata path. /// @@ -155,7 +155,7 @@ namespace MediaBrowser.Model.Configuration /// /// The dashboard source path. public string DashboardSourcePath { get; set; } - + /// /// Gets or sets the image saving convention. /// @@ -201,12 +201,14 @@ namespace MediaBrowser.Model.Configuration public bool EnableFolderView { get; set; } public bool EnableGroupingIntoCollections { get; set; } public bool DisplaySpecialsWithinSeasons { get; set; } + public string[] LocalNetworkAddresses { get; set; } /// /// Initializes a new instance of the class. /// public ServerConfiguration() { + LocalNetworkAddresses = new string[] { }; Migrations = new string[] { }; EnableCustomPathSubFolders = true; diff --git a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs index 6e57b4022..d76c89dfb 100644 --- a/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/MusicBrainzAlbumProvider.cs @@ -25,7 +25,7 @@ namespace MediaBrowser.Providers.Music private readonly IApplicationHost _appHost; private readonly ILogger _logger; - public static string MusicBrainzBaseUrl = "https://www.musicbrainz.org"; + public static string MusicBrainzBaseUrl = "http://musicbrainz.fercasas.com:5000"; public MusicBrainzAlbumProvider(IHttpClient httpClient, IApplicationHost appHost, ILogger logger) { diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj index 5dc064035..52ffe3a4b 100644 --- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj +++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj @@ -46,7 +46,7 @@ ..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll - ..\packages\Emby.XmlTv.1.0.0.50\lib\net45\Emby.XmlTv.dll + ..\packages\Emby.XmlTv.1.0.0.51\lib\net45\Emby.XmlTv.dll True diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config index 516bf3271..badc3f2c1 100644 --- a/MediaBrowser.Server.Implementations/packages.config +++ b/MediaBrowser.Server.Implementations/packages.config @@ -1,7 +1,7 @@  - + diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 75e3bb7f5..23710479b 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -833,17 +833,40 @@ namespace MediaBrowser.Server.Startup.Common private IEnumerable GetUrlPrefixes() { - var prefixes = new List - { - "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" - }; + var hosts = ServerConfigurationManager.Configuration.LocalNetworkAddresses.ToList(); - if (!string.IsNullOrWhiteSpace(CertificatePath)) + if (hosts.Count == 0) { - prefixes.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); + hosts.Add("+"); } - return prefixes; + if (!hosts.Contains("+", StringComparer.OrdinalIgnoreCase)) + { + if (!hosts.Contains("localhost", StringComparer.OrdinalIgnoreCase)) + { + hosts.Add("localhost"); + } + + if (!hosts.Contains("127.0.0.1", StringComparer.OrdinalIgnoreCase)) + { + hosts.Add("127.0.0.1"); + } + } + + return hosts.SelectMany(i => + { + var prefixes = new List + { + "http://"+i+":" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + }; + + if (!string.IsNullOrWhiteSpace(CertificatePath)) + { + prefixes.Add("https://" + i + ":" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/"); + } + + return prefixes; + }); } ///