aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs18
-rw-r--r--MediaBrowser.Server.Implementations/Providers/ImageSaver.cs37
-rw-r--r--MediaBrowser.Server.Implementations/Providers/ProviderManager.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Session/SessionManager.cs15
4 files changed, 63 insertions, 14 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
index 7387b91662..51d31cd338 100644
--- a/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
+++ b/MediaBrowser.Server.Implementations/Library/Validators/ArtistsValidator.cs
@@ -90,10 +90,22 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
MergeImages(musicArtist.Images, artist.Images);
// Merge backdrops
- var backdrops = musicArtist.BackdropImagePaths.ToList();
- backdrops.InsertRange(0, artist.BackdropImagePaths);
- artist.BackdropImagePaths = backdrops.Distinct(StringComparer.OrdinalIgnoreCase)
+ var additionalBackdrops = musicArtist
+ .BackdropImagePaths
+ .Except(artist.BackdropImagePaths)
.ToList();
+
+ var sources = additionalBackdrops
+ .Select(musicArtist.GetImageSourceInfo)
+ .ToList();
+
+ foreach (var path in additionalBackdrops)
+ {
+ artist.RemoveImageSourceForPath(path);
+ }
+
+ artist.BackdropImagePaths.AddRange(additionalBackdrops);
+ artist.ImageSources.AddRange(sources);
}
if (!artist.LockedFields.Contains(MetadataFields.Genres))
diff --git a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs
index 18e64e414f..711b3f77ce 100644
--- a/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs
+++ b/MediaBrowser.Server.Implementations/Providers/ImageSaver.cs
@@ -56,9 +56,11 @@ namespace MediaBrowser.Server.Implementations.Providers
/// <param name="mimeType">Type of the MIME.</param>
/// <param name="type">The type.</param>
/// <param name="imageIndex">Index of the image.</param>
+ /// <param name="sourceUrl">The source URL.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
- public async Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken)
+ /// <exception cref="System.ArgumentNullException">mimeType</exception>
+ public async Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, string sourceUrl, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(mimeType))
{
@@ -128,7 +130,7 @@ namespace MediaBrowser.Server.Implementations.Providers
}
// Set the path into the BaseItem
- SetImagePath(item, type, imageIndex, paths[0]);
+ SetImagePath(item, type, imageIndex, paths[0], sourceUrl);
// Delete the current path
if (!string.IsNullOrEmpty(currentPath) && !paths.Contains(currentPath, StringComparer.OrdinalIgnoreCase))
@@ -137,7 +139,18 @@ namespace MediaBrowser.Server.Implementations.Providers
try
{
- File.Delete(currentPath);
+ var currentFile = new FileInfo(currentPath);
+
+ // This will fail if the file is hidden
+ if (currentFile.Exists)
+ {
+ if ((currentFile.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
+ {
+ currentFile.Attributes &= ~FileAttributes.Hidden;
+ }
+
+ currentFile.Delete();
+ }
}
finally
{
@@ -244,12 +257,11 @@ namespace MediaBrowser.Server.Implementations.Providers
/// <param name="type">The type.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <param name="path">The path.</param>
- /// <exception cref="System.ArgumentNullException">
- /// imageIndex
+ /// <param name="sourceUrl">The source URL.</param>
+ /// <exception cref="System.ArgumentNullException">imageIndex
/// or
- /// imageIndex
- /// </exception>
- private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path)
+ /// imageIndex</exception>
+ private void SetImagePath(BaseItem item, ImageType type, int? imageIndex, string path, string sourceUrl)
{
switch (type)
{
@@ -282,6 +294,15 @@ namespace MediaBrowser.Server.Implementations.Providers
{
item.BackdropImagePaths.Add(path);
}
+
+ if (string.IsNullOrEmpty(sourceUrl))
+ {
+ item.RemoveImageSourceForPath(path);
+ }
+ else
+ {
+ item.AddImageSource(path, sourceUrl);
+ }
break;
default:
item.SetImage(type, path);
diff --git a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
index 8bd5012713..19230cecdb 100644
--- a/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
+++ b/MediaBrowser.Server.Implementations/Providers/ProviderManager.cs
@@ -325,7 +325,7 @@ namespace MediaBrowser.Server.Implementations.Providers
}).ConfigureAwait(false);
- await SaveImage(item, response.Content, response.ContentType, type, imageIndex, cancellationToken)
+ await SaveImage(item, response.Content, response.ContentType, type, imageIndex, url, cancellationToken)
.ConfigureAwait(false);
}
@@ -337,11 +337,12 @@ namespace MediaBrowser.Server.Implementations.Providers
/// <param name="mimeType">Type of the MIME.</param>
/// <param name="type">The type.</param>
/// <param name="imageIndex">Index of the image.</param>
+ /// <param name="sourceUrl">The source URL.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
- public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken)
+ public Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, string sourceUrl, CancellationToken cancellationToken)
{
- return new ImageSaver(ConfigurationManager, _directoryWatchers).SaveImage(item, source, mimeType, type, imageIndex, cancellationToken);
+ return new ImageSaver(ConfigurationManager, _directoryWatchers).SaveImage(item, source, mimeType, type, imageIndex, sourceUrl, cancellationToken);
}
}
}
diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
index 265cab1e71..473f2c67a7 100644
--- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs
+++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs
@@ -174,6 +174,11 @@ namespace MediaBrowser.Server.Implementations.Session
/// <param name="item">The item.</param>
private void RemoveNowPlayingItem(SessionInfo session, BaseItem item)
{
+ if (item == null)
+ {
+ throw new ArgumentNullException("item");
+ }
+
if (session.NowPlayingItem != null && session.NowPlayingItem.Id == item.Id)
{
session.NowPlayingItem = null;
@@ -319,6 +324,16 @@ namespace MediaBrowser.Server.Implementations.Session
throw new ArgumentNullException("info");
}
+ if (info.Item == null)
+ {
+ throw new ArgumentException("PlaybackStopInfo.Item cannot be null");
+ }
+
+ if (info.SessionId == Guid.Empty)
+ {
+ throw new ArgumentException("PlaybackStopInfo.SessionId cannot be Guid.Empty");
+ }
+
if (info.PositionTicks.HasValue && info.PositionTicks.Value < 0)
{
throw new ArgumentOutOfRangeException("positionTicks");