aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-09-20 15:44:09 -0400
committerGitHub <noreply@github.com>2016-09-20 15:44:09 -0400
commitd61258f29033f53479104c45c32f15ba8d08e200 (patch)
treeec7a267273f841098688cd0ae8bda646dc80c005 /MediaBrowser.Server.Implementations
parent0ed7bd0350d001327f305724c979aef6e947bdf4 (diff)
parent61ee765de96eeffa28b0042d633166ba5d214850 (diff)
Merge pull request #2182 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/IO/FileRefresher.cs4
-rw-r--r--MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs15
-rw-r--r--MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs2
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs97
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs5
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs17
6 files changed, 129 insertions, 11 deletions
diff --git a/MediaBrowser.Server.Implementations/IO/FileRefresher.cs b/MediaBrowser.Server.Implementations/IO/FileRefresher.cs
index 8e28aa2a0..3df7a03d4 100644
--- a/MediaBrowser.Server.Implementations/IO/FileRefresher.cs
+++ b/MediaBrowser.Server.Implementations/IO/FileRefresher.cs
@@ -12,6 +12,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Logging;
using MediaBrowser.Server.Implementations.ScheduledTasks;
+using MoreLinq;
namespace MediaBrowser.Server.Implementations.IO
{
@@ -136,9 +137,10 @@ namespace MediaBrowser.Server.Implementations.IO
private async Task ProcessPathChanges(List<string> paths)
{
var itemsToRefresh = paths
+ .Distinct(StringComparer.OrdinalIgnoreCase)
.Select(GetAffectedBaseItem)
.Where(item => item != null)
- .Distinct()
+ .DistinctBy(i => i.Id)
.ToList();
foreach (var p in paths)
diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
index 8bb40a00e..6e0f9a3c4 100644
--- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
+++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
@@ -404,7 +404,20 @@ namespace MediaBrowser.Server.Implementations.IO
{
Logger.Debug("Changed detected of type " + e.ChangeType + " to " + e.FullPath);
- ReportFileSystemChanged(e.FullPath);
+ var path = e.FullPath;
+
+ // For deletes, use the parent path
+ if (e.ChangeType == WatcherChangeTypes.Deleted)
+ {
+ var parentPath = Path.GetDirectoryName(path);
+
+ if (!string.IsNullOrWhiteSpace(parentPath))
+ {
+ path = parentPath;
+ }
+ }
+
+ ReportFileSystemChanged(path);
}
catch (Exception ex)
{
diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
index 3f9475480..d4ebb8457 100644
--- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
+++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs
@@ -89,7 +89,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers
return false;
}
- if (IgnoreFiles.Any(i => filename.IndexOf("-" + i, StringComparison.OrdinalIgnoreCase) != -1))
+ if (IgnoreFiles.Any(i => filename.IndexOf(i, StringComparison.OrdinalIgnoreCase) != -1))
{
return false;
}
diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index b508110cf..2dd23857a 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -27,6 +27,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using CommonIO;
+using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Configuration;
@@ -1026,6 +1027,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
result.Item3.Release();
isResourceOpen = false;
+
+ SaveNfo(timer, recordPath, seriesPath);
};
var pathWithDuration = result.Item2.ApplyDuration(mediaStreamInfo.Path, duration);
@@ -1071,7 +1074,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
timer.Status = RecordingStatus.Completed;
_timerProvider.Delete(timer);
- OnSuccessfulRecording(timer, recordPath, seriesPath);
+ OnSuccessfulRecording(timer, recordPath);
}
else if (DateTime.UtcNow < timer.EndDate)
{
@@ -1139,7 +1142,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
return new DirectRecorder(_logger, _httpClient, _fileSystem);
}
- private async void OnSuccessfulRecording(TimerInfo timer, string path, string seriesPath)
+ private async void OnSuccessfulRecording(TimerInfo timer, string path)
{
if (timer.IsProgramSeries && GetConfiguration().EnableAutoOrganize)
{
@@ -1163,15 +1166,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
_logger.ErrorException("Error processing new recording", ex);
}
}
-
- SaveNfo(timer, path, seriesPath);
}
private void SaveNfo(TimerInfo timer, string recordingPath, string seriesPath)
{
- if (timer.IsProgramSeries)
+ try
+ {
+ if (timer.IsProgramSeries)
+ {
+ SaveSeriesNfo(timer, recordingPath, seriesPath);
+ }
+ else if (!timer.IsMovie || timer.IsSports)
+ {
+ SaveVideoNfo(timer, recordingPath);
+ }
+ }
+ catch (Exception ex)
{
- SaveSeriesNfo(timer, recordingPath, seriesPath);
+ _logger.ErrorException("Error saving nfo", ex);
}
}
@@ -1209,6 +1221,79 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
}
+ public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
+ private void SaveVideoNfo(TimerInfo timer, string recordingPath)
+ {
+ var nfoPath = Path.ChangeExtension(recordingPath, ".nfo");
+
+ if (File.Exists(nfoPath))
+ {
+ return;
+ }
+
+ using (var stream = _fileSystem.GetFileStream(nfoPath, FileMode.Create, FileAccess.Write, FileShare.Read))
+ {
+ var settings = new XmlWriterSettings
+ {
+ Indent = true,
+ Encoding = Encoding.UTF8,
+ CloseOutput = false
+ };
+
+ using (XmlWriter writer = XmlWriter.Create(stream, settings))
+ {
+ writer.WriteStartDocument(true);
+ writer.WriteStartElement("movie");
+
+ if (!string.IsNullOrWhiteSpace(timer.Name))
+ {
+ writer.WriteElementString("title", timer.Name);
+ }
+
+ writer.WriteElementString("dateadded", DateTime.UtcNow.ToLocalTime().ToString(DateAddedFormat));
+
+ if (timer.ProductionYear.HasValue)
+ {
+ writer.WriteElementString("year", timer.ProductionYear.Value.ToString(CultureInfo.InvariantCulture));
+ }
+ if (!string.IsNullOrEmpty(timer.OfficialRating))
+ {
+ writer.WriteElementString("mpaa", timer.OfficialRating);
+ }
+
+ var overview = (timer.Overview ?? string.Empty)
+ .StripHtml()
+ .Replace("&quot;", "'");
+
+ writer.WriteElementString("plot", overview);
+ writer.WriteElementString("lockdata", true.ToString().ToLower());
+
+ if (timer.CommunityRating.HasValue)
+ {
+ writer.WriteElementString("rating", timer.CommunityRating.Value.ToString(CultureInfo.InvariantCulture));
+ }
+
+ foreach (var genre in timer.Genres)
+ {
+ writer.WriteElementString("genre", genre);
+ }
+
+ if (!string.IsNullOrWhiteSpace(timer.ShortOverview))
+ {
+ writer.WriteElementString("outline", timer.ShortOverview);
+ }
+
+ if (!string.IsNullOrWhiteSpace(timer.HomePageUrl))
+ {
+ writer.WriteElementString("website", timer.HomePageUrl);
+ }
+
+ writer.WriteEndElement();
+ writer.WriteEndDocument();
+ }
+ }
+ }
+
private ProgramInfo GetProgramInfoFromCache(string channelId, string programId)
{
var epgData = GetEpgDataForChannel(channelId);
diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
index 236439bc5..67356da2f 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
@@ -46,6 +46,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
timerInfo.EpisodeTitle = programInfo.EpisodeTitle;
timerInfo.OriginalAirDate = programInfo.OriginalAirDate;
timerInfo.IsProgramSeries = programInfo.IsSeries;
+
+ timerInfo.HomePageUrl = programInfo.HomePageUrl;
+ timerInfo.CommunityRating = programInfo.CommunityRating;
+ timerInfo.ShortOverview = programInfo.ShortOverview;
+ timerInfo.OfficialRating = programInfo.OfficialRating;
}
public static string GetRecordingName(TimerInfo info)
diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
index c30263388..0bc84a2e5 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs
@@ -171,7 +171,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
var data = images[imageIndex].data ?? new List<ScheduleDirect.ImageData>();
data = data.OrderByDescending(GetSizeOrder).ToList();
- programEntry.primaryImage = GetProgramImage(ApiUrl, data, "Logo", true, 1280);
+ programEntry.primaryImage = GetProgramImage(ApiUrl, data, "Logo", true, 800);
//programEntry.thumbImage = GetProgramImage(ApiUrl, data, "Iconic", false);
//programEntry.bannerImage = GetProgramImage(ApiUrl, data, "Banner", false) ??
// GetProgramImage(ApiUrl, data, "Banner-L1", false) ??
@@ -536,7 +536,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
}
return false;
- }) ?? matches.FirstOrDefault();
+ });
+
+ if (match == null)
+ {
+ // Get the second lowest quality image, when possible
+ if (matches.Count > 1)
+ {
+ match = matches[matches.Count - 2];
+ }
+ else
+ {
+ match = matches.FirstOrDefault();
+ }
+ }
if (match == null)
{