diff --git a/MediaBrowser.Api/Images/ImageService.cs b/MediaBrowser.Api/Images/ImageService.cs
index 081ba56124..3f5b9da2a1 100644
--- a/MediaBrowser.Api/Images/ImageService.cs
+++ b/MediaBrowser.Api/Images/ImageService.cs
@@ -1,4 +1,6 @@
-using MediaBrowser.Common.Configuration;
+using System.Drawing;
+using System.Text;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
@@ -717,6 +719,15 @@ namespace MediaBrowser.Api.Images
var bytes = Convert.FromBase64String(text);
+ // Validate first
+ using (var memoryStream = new MemoryStream(bytes))
+ {
+ using (var image = Image.FromStream(memoryStream))
+ {
+ Logger.Info("New image is {0}x{1}", image.Width, image.Height);
+ }
+ }
+
string filename;
switch (imageType)
diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs
index e956e214db..12b9d478ff 100644
--- a/MediaBrowser.Api/Library/LibraryHelpers.cs
+++ b/MediaBrowser.Api/Library/LibraryHelpers.cs
@@ -75,7 +75,7 @@ namespace MediaBrowser.Api.Library
throw new DirectoryNotFoundException("The media collection does not exist");
}
- if (Directory.Exists(newPath))
+ if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath))
{
throw new ArgumentException("There is already a media collection with the name " + newPath + ".");
}
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index d300fe19c3..2819a649aa 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -55,6 +55,7 @@
+
diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
index 3ac8eec894..22098a368e 100644
--- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
+++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs
@@ -133,6 +133,11 @@ namespace MediaBrowser.Api.UserLibrary
/// IEnumerable{IbnStub}.
private IEnumerable> FilterItems(GetItemsByName request, IEnumerable> items, User user)
{
+ if (!string.IsNullOrEmpty(request.NameStartsWithOrGreater))
+ {
+ items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.Name, StringComparison.OrdinalIgnoreCase) < 1);
+ }
+
var filters = request.GetFilters().ToList();
if (filters.Count == 0)
@@ -227,7 +232,7 @@ namespace MediaBrowser.Api.UserLibrary
items = items.Where(f => vals.Contains(f.MediaType ?? string.Empty, StringComparer.OrdinalIgnoreCase));
}
-
+
return items;
}
@@ -304,6 +309,9 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public Guid? UserId { get; set; }
+ [ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string NameStartsWithOrGreater { get; set; }
+
///
/// What to sort the results by
///
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index dc316cff18..c57778fd65 100644
--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs
+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs
@@ -127,6 +127,9 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "SeriesStatus", Description = "Optional filter by Series Status. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string SeriesStatus { get; set; }
+ [ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string NameStartsWithOrGreater { get; set; }
+
///
/// Gets or sets the air days.
///
@@ -162,7 +165,7 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "HasTrailer", Description = "Optional filter by items with trailers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public bool? HasTrailer { get; set; }
-
+
///
/// Gets the order by.
///
@@ -450,7 +453,12 @@ namespace MediaBrowser.Api.UserLibrary
var vals = request.IncludeItemTypes.Split(',');
items = items.Where(f => vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase));
}
-
+
+ if (!string.IsNullOrEmpty(request.NameStartsWithOrGreater))
+ {
+ items = items.Where(i => string.Compare(request.NameStartsWithOrGreater, i.SortName, StringComparison.OrdinalIgnoreCase) < 1);
+ }
+
// Filter by Series Status
if (!string.IsNullOrEmpty(request.SeriesStatus))
{
@@ -489,7 +497,7 @@ namespace MediaBrowser.Api.UserLibrary
items = items.Where(i => !string.IsNullOrEmpty(i.MediaType) && types.Contains(i.MediaType, StringComparer.OrdinalIgnoreCase));
}
-
+
var imageTypes = GetImageTypes(request).ToArray();
if (imageTypes.Length > 0)
{
diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs
index 43aef88f1a..0b9972d0a6 100644
--- a/MediaBrowser.Controller/Library/TVUtils.cs
+++ b/MediaBrowser.Controller/Library/TVUtils.cs
@@ -1,10 +1,9 @@
-using System.IO;
-using MediaBrowser.Controller.IO;
+using MediaBrowser.Controller.Resolvers;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
-using MediaBrowser.Controller.Resolvers;
namespace MediaBrowser.Controller.Library
{
@@ -16,7 +15,7 @@ namespace MediaBrowser.Controller.Library
///
/// The TVDB API key
///
- public static readonly string TVDBApiKey = "B89CE93890E9419B";
+ public static readonly string TvdbApiKey = "B89CE93890E9419B";
///
/// The banner URL
///
@@ -93,7 +92,7 @@ namespace MediaBrowser.Controller.Library
// Look for one of the season folder names
foreach (var name in SeasonFolderNames)
{
- int index = path.IndexOf(name, StringComparison.OrdinalIgnoreCase);
+ var index = path.IndexOf(name, StringComparison.OrdinalIgnoreCase);
if (index != -1)
{
@@ -115,7 +114,7 @@ namespace MediaBrowser.Controller.Library
int length = 0;
// Find out where the numbers start, and then keep going until they end
- for (int i = 0; i < path.Length; i++)
+ for (var i = 0; i < path.Length; i++)
{
if (char.IsNumber(path, i))
{
diff --git a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs
index 15a9b08f05..8f55d5b47c 100644
--- a/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs
+++ b/MediaBrowser.Controller/Providers/MediaInfo/FFProbeVideoInfoProvider.cs
@@ -286,7 +286,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
///
/// The dummy chapter duration
///
- private readonly long DummyChapterDuration = TimeSpan.FromMinutes(10).Ticks;
+ private readonly long _dummyChapterDuration = TimeSpan.FromMinutes(5).Ticks;
///
/// Adds the dummy chapters.
@@ -296,7 +296,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
var runtime = video.RunTimeTicks ?? 0;
- if (runtime < DummyChapterDuration)
+ if (runtime < _dummyChapterDuration)
{
return;
}
@@ -315,7 +315,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
});
index++;
- currentChapterTicks += DummyChapterDuration;
+ currentChapterTicks += _dummyChapterDuration;
}
video.Chapters = chapters;
diff --git a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs
index 72e3a3a6e8..8e335ba859 100644
--- a/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs
+++ b/MediaBrowser.Controller/Providers/Music/LastfmHelper.cs
@@ -2,6 +2,7 @@
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Model.Entities;
using System;
+using System.Linq;
namespace MediaBrowser.Controller.Providers.Music
{
@@ -30,7 +31,7 @@ namespace MediaBrowser.Controller.Providers.Music
artist.ProductionYear = yearFormed;
if (data.tags != null)
{
- AddGenres(artist, data.tags);
+ AddTags(artist, data.tags);
}
var entity = artist as Artist;
@@ -55,21 +56,15 @@ namespace MediaBrowser.Controller.Providers.Music
item.ProductionYear = release.Year;
if (data.toptags != null)
{
- AddGenres(item, data.toptags);
+ AddTags(item, data.toptags);
}
}
- private static void AddGenres(BaseItem item, LastfmTags tags)
+ private static void AddTags(BaseItem item, LastfmTags tags)
{
- item.Genres.Clear();
+ var itemTags = (from tag in tags.tag where !string.IsNullOrEmpty(tag.name) select tag.name).ToList();
- foreach (var tag in tags.tag)
- {
- if (!string.IsNullOrEmpty(tag.name))
- {
- item.AddGenre(tag.name);
- }
- }
+ item.Tags = itemTags;
}
}
}
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
index f4ba98f70f..2b4173ed90 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteEpisodeProvider.cs
@@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Providers.TV
seasonNumber = "0"; // Specials
}
- var url = string.Format(episodeQuery, TVUtils.TVDBApiKey, seriesId, seasonNumber, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
+ var url = string.Format(episodeQuery, TVUtils.TvdbApiKey, seriesId, seasonNumber, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
var doc = new XmlDocument();
try
@@ -205,7 +205,7 @@ namespace MediaBrowser.Controller.Providers.TV
//this is basicly just for anime.
if (!doc.HasChildNodes && Int32.Parse(seasonNumber) == 1)
{
- url = string.Format(absEpisodeQuery, TVUtils.TVDBApiKey, seriesId, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
+ url = string.Format(absEpisodeQuery, TVUtils.TvdbApiKey, seriesId, episodeNumber, ConfigurationManager.Configuration.PreferredMetadataLanguage);
try
{
@@ -250,7 +250,7 @@ namespace MediaBrowser.Controller.Providers.TV
if (episode.IndexNumber < 0)
episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber");
- episode.Name = episode.IndexNumber.Value.ToString("000") + " - " + doc.SafeGetString("//EpisodeName");
+ episode.Name = doc.SafeGetString("//EpisodeName");
episode.CommunityRating = doc.SafeGetSingle("//Rating", -1, 10);
var firstAired = doc.SafeGetString("//FirstAired");
DateTime airDate;
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
index 79ea75f8ec..70ac2d45ca 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteSeasonProvider.cs
@@ -158,7 +158,7 @@ namespace MediaBrowser.Controller.Providers.TV
if ((season.PrimaryImagePath == null) || (!season.HasImage(ImageType.Banner)) || (season.BackdropImagePaths == null))
{
var images = new XmlDocument();
- var url = string.Format("http://www.thetvdb.com/api/" + TVUtils.TVDBApiKey + "/series/{0}/banners.xml", seriesId);
+ var url = string.Format("http://www.thetvdb.com/api/" + TVUtils.TvdbApiKey + "/series/{0}/banners.xml", seriesId);
using (var imgs = await HttpClient.Get(new HttpRequestOptions
{
diff --git a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
index 9dd5aa4189..eb689ed2f7 100644
--- a/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
+++ b/MediaBrowser.Controller/Providers/TV/RemoteSeriesProvider.cs
@@ -197,7 +197,7 @@ namespace MediaBrowser.Controller.Providers.TV
if (!string.IsNullOrEmpty(seriesId))
{
- string url = string.Format(seriesGet, TVUtils.TVDBApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
+ string url = string.Format(seriesGet, TVUtils.TvdbApiKey, seriesId, ConfigurationManager.Configuration.PreferredMetadataLanguage);
var doc = new XmlDocument();
try
@@ -296,7 +296,7 @@ namespace MediaBrowser.Controller.Providers.TV
/// Task.
private async Task FetchActors(Series series, string seriesId, XmlDocument doc, CancellationToken cancellationToken)
{
- string urlActors = string.Format(getActors, TVUtils.TVDBApiKey, seriesId);
+ string urlActors = string.Format(getActors, TVUtils.TvdbApiKey, seriesId);
var docActors = new XmlDocument();
try
@@ -377,7 +377,7 @@ namespace MediaBrowser.Controller.Providers.TV
{
if ((!string.IsNullOrEmpty(seriesId)) && ((series.PrimaryImagePath == null) || (series.BackdropImagePaths == null)))
{
- string url = string.Format("http://www.thetvdb.com/api/" + TVUtils.TVDBApiKey + "/series/{0}/banners.xml", seriesId);
+ string url = string.Format("http://www.thetvdb.com/api/" + TVUtils.TvdbApiKey + "/series/{0}/banners.xml", seriesId);
var images = new XmlDocument();
try
diff --git a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
index a801aef4ee..1c279016d6 100644
--- a/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
+++ b/MediaBrowser.Server.Implementations/Library/CoreResolutionIgnoreRule.cs
@@ -66,7 +66,8 @@ namespace MediaBrowser.Server.Implementations.Library
return true;
}
- if (string.Equals(filename, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
+ // Ignore trailer folders but allow it at the collection level
+ if (string.Equals(filename, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase) && !(args.Parent is AggregateFolder) && !(args.Parent is UserRootFolder))
{
return true;
}
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index a35ac44ea3..4dd24d98f2 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -378,19 +378,16 @@ namespace MediaBrowser.ServerApplication
RegisterServerWithAdministratorAccess();
}
+ base.FindParts();
+
+ HttpServer.Init(GetExports(false));
+
+ ServerManager.AddWebSocketListeners(GetExports(false));
+
+ StartServer(true);
+
Parallel.Invoke(
- () => base.FindParts(),
-
- () =>
- {
- HttpServer.Init(GetExports(false));
-
- ServerManager.AddWebSocketListeners(GetExports(false));
-
- StartServer(true);
- },
-
() => LibraryManager.AddParts(GetExports(), GetExports(), GetExports(), GetExports(), GetExports()),
() => ProviderManager.AddMetadataProviders(GetExports().ToArray()),
diff --git a/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs b/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs
new file mode 100644
index 0000000000..62c1e17f90
--- /dev/null
+++ b/MediaBrowser.ServerApplication/EntryPoints/LibraryChangedNotifier.cs
@@ -0,0 +1,210 @@
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Plugins;
+using MediaBrowser.Controller.Session;
+using MediaBrowser.Model.Entities;
+using System.Linq;
+using System.Threading;
+
+namespace MediaBrowser.ServerApplication.EntryPoints
+{
+ public class LibraryChangedNotifier : IServerEntryPoint
+ {
+ ///
+ /// The _library manager
+ ///
+ private readonly ILibraryManager _libraryManager;
+
+ private readonly ISessionManager _sessionManager;
+ private readonly IServerManager _serverManager;
+
+ ///
+ /// The _library changed sync lock
+ ///
+ private readonly object _libraryChangedSyncLock = new object();
+
+ ///
+ /// Gets or sets the library update info.
+ ///
+ /// The library update info.
+ private LibraryUpdateInfo LibraryUpdateInfo { get; set; }
+
+ ///
+ /// Gets or sets the library update timer.
+ ///
+ /// The library update timer.
+ private Timer LibraryUpdateTimer { get; set; }
+
+ ///
+ /// The library update duration
+ ///
+ private const int LibraryUpdateDuration = 60000;
+
+ public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IServerManager serverManager)
+ {
+ _libraryManager = libraryManager;
+ _sessionManager = sessionManager;
+ _serverManager = serverManager;
+ }
+
+ public void Run()
+ {
+ _libraryManager.ItemAdded += libraryManager_ItemAdded;
+ _libraryManager.ItemUpdated += libraryManager_ItemUpdated;
+ _libraryManager.ItemRemoved += libraryManager_ItemRemoved;
+
+ }
+
+ ///
+ /// Handles the ItemAdded event of the libraryManager control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ void libraryManager_ItemAdded(object sender, ItemChangeEventArgs e)
+ {
+ lock (_libraryChangedSyncLock)
+ {
+ if (LibraryUpdateInfo == null)
+ {
+ LibraryUpdateInfo = new LibraryUpdateInfo();
+ }
+
+ if (LibraryUpdateTimer == null)
+ {
+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
+ Timeout.Infinite);
+ }
+ else
+ {
+ LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
+ }
+
+ if (e.Item.Parent != null)
+ {
+ LibraryUpdateInfo.FoldersAddedTo.Add(e.Item.Parent.Id);
+ }
+
+ LibraryUpdateInfo.ItemsAdded.Add(e.Item.Id);
+ }
+ }
+
+ ///
+ /// Handles the ItemUpdated event of the libraryManager control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ void libraryManager_ItemUpdated(object sender, ItemChangeEventArgs e)
+ {
+ lock (_libraryChangedSyncLock)
+ {
+ if (LibraryUpdateInfo == null)
+ {
+ LibraryUpdateInfo = new LibraryUpdateInfo();
+ }
+
+ if (LibraryUpdateTimer == null)
+ {
+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
+ Timeout.Infinite);
+ }
+ else
+ {
+ LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
+ }
+
+ LibraryUpdateInfo.ItemsUpdated.Add(e.Item.Id);
+ }
+ }
+
+ ///
+ /// Handles the ItemRemoved event of the libraryManager control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ void libraryManager_ItemRemoved(object sender, ItemChangeEventArgs e)
+ {
+ lock (_libraryChangedSyncLock)
+ {
+ if (LibraryUpdateInfo == null)
+ {
+ LibraryUpdateInfo = new LibraryUpdateInfo();
+ }
+
+ if (LibraryUpdateTimer == null)
+ {
+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
+ Timeout.Infinite);
+ }
+ else
+ {
+ LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
+ }
+
+ if (e.Item.Parent != null)
+ {
+ LibraryUpdateInfo.FoldersRemovedFrom.Add(e.Item.Parent.Id);
+ }
+
+ LibraryUpdateInfo.ItemsRemoved.Add(e.Item.Id);
+ }
+ }
+
+ ///
+ /// Libraries the update timer callback.
+ ///
+ /// The state.
+ private void LibraryUpdateTimerCallback(object state)
+ {
+ lock (_libraryChangedSyncLock)
+ {
+ // Remove dupes in case some were saved multiple times
+ LibraryUpdateInfo.FoldersAddedTo = LibraryUpdateInfo.FoldersAddedTo.Distinct().ToList();
+
+ LibraryUpdateInfo.FoldersRemovedFrom = LibraryUpdateInfo.FoldersRemovedFrom.Distinct().ToList();
+
+ LibraryUpdateInfo.ItemsUpdated = LibraryUpdateInfo.ItemsUpdated
+ .Where(i => !LibraryUpdateInfo.ItemsAdded.Contains(i))
+ .Distinct()
+ .ToList();
+
+ _serverManager.SendWebSocketMessage("LibraryChanged", LibraryUpdateInfo);
+
+ if (LibraryUpdateTimer != null)
+ {
+ LibraryUpdateTimer.Dispose();
+ LibraryUpdateTimer = null;
+ }
+
+ LibraryUpdateInfo = null;
+ }
+ }
+
+ ///
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///
+ public void Dispose()
+ {
+ Dispose(true);
+ }
+
+ ///
+ /// Releases unmanaged and - optionally - managed resources.
+ ///
+ /// true to release both managed and unmanaged resources; false to release only unmanaged resources.
+ protected virtual void Dispose(bool dispose)
+ {
+ if (dispose)
+ {
+ if (LibraryUpdateTimer != null)
+ {
+ LibraryUpdateTimer.Dispose();
+ LibraryUpdateTimer = null;
+ }
+
+ _libraryManager.ItemAdded -= libraryManager_ItemAdded;
+ _libraryManager.ItemUpdated -= libraryManager_ItemUpdated;
+ _libraryManager.ItemRemoved -= libraryManager_ItemRemoved;
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
index 5e0a477f3a..1a29d5029b 100644
--- a/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
+++ b/MediaBrowser.ServerApplication/EntryPoints/WebSocketEvents.cs
@@ -8,13 +8,10 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Updates;
-using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
using System;
-using System.Linq;
-using System.Threading;
namespace MediaBrowser.ServerApplication.EntryPoints
{
@@ -37,11 +34,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints
///
private readonly IUserManager _userManager;
- ///
- /// The _library manager
- ///
- private readonly ILibraryManager _libraryManager;
-
///
/// The _installation manager
///
@@ -57,40 +49,17 @@ namespace MediaBrowser.ServerApplication.EntryPoints
///
private readonly ITaskManager _taskManager;
- ///
- /// The _library changed sync lock
- ///
- private readonly object _libraryChangedSyncLock = new object();
-
- ///
- /// Gets or sets the library update info.
- ///
- /// The library update info.
- private LibraryUpdateInfo LibraryUpdateInfo { get; set; }
-
- ///
- /// Gets or sets the library update timer.
- ///
- /// The library update timer.
- private Timer LibraryUpdateTimer { get; set; }
-
- ///
- /// The library update duration
- ///
- private const int LibraryUpdateDuration = 60000;
-
///
/// Initializes a new instance of the class.
///
/// The server manager.
/// The logger.
/// The user manager.
- public WebSocketEvents(IServerManager serverManager, IServerApplicationHost appHost, ILogger logger, IUserManager userManager, ILibraryManager libraryManager, IInstallationManager installationManager, ITaskManager taskManager)
+ public WebSocketEvents(IServerManager serverManager, IServerApplicationHost appHost, ILogger logger, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager)
{
_serverManager = serverManager;
_logger = logger;
_userManager = userManager;
- _libraryManager = libraryManager;
_installationManager = installationManager;
_appHost = appHost;
_taskManager = taskManager;
@@ -103,10 +72,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints
_appHost.HasPendingRestartChanged += kernel_HasPendingRestartChanged;
- _libraryManager.ItemAdded += libraryManager_ItemAdded;
- _libraryManager.ItemUpdated += libraryManager_ItemUpdated;
- _libraryManager.ItemRemoved += libraryManager_ItemRemoved;
-
_installationManager.PluginUninstalled += InstallationManager_PluginUninstalled;
_installationManager.PackageInstalling += installationManager_PackageInstalling;
_installationManager.PackageInstallationCancelled += installationManager_PackageInstallationCancelled;
@@ -168,130 +133,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints
_serverManager.SendWebSocketMessage("PackageInstalling", e.Argument);
}
- ///
- /// Handles the ItemAdded event of the libraryManager control.
- ///
- /// The source of the event.
- /// The instance containing the event data.
- void libraryManager_ItemAdded(object sender, ItemChangeEventArgs e)
- {
- lock (_libraryChangedSyncLock)
- {
- if (LibraryUpdateInfo == null)
- {
- LibraryUpdateInfo = new LibraryUpdateInfo();
- }
-
- if (LibraryUpdateTimer == null)
- {
- LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
- Timeout.Infinite);
- }
- else
- {
- LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
- }
-
- if (e.Item.Parent != null)
- {
- LibraryUpdateInfo.FoldersAddedTo.Add(e.Item.Parent.Id);
- }
-
- LibraryUpdateInfo.ItemsAdded.Add(e.Item.Id);
- }
- }
-
- ///
- /// Handles the ItemUpdated event of the libraryManager control.
- ///
- /// The source of the event.
- /// The instance containing the event data.
- void libraryManager_ItemUpdated(object sender, ItemChangeEventArgs e)
- {
- lock (_libraryChangedSyncLock)
- {
- if (LibraryUpdateInfo == null)
- {
- LibraryUpdateInfo = new LibraryUpdateInfo();
- }
-
- if (LibraryUpdateTimer == null)
- {
- LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
- Timeout.Infinite);
- }
- else
- {
- LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
- }
-
- LibraryUpdateInfo.ItemsUpdated.Add(e.Item.Id);
- }
- }
-
- ///
- /// Handles the ItemRemoved event of the libraryManager control.
- ///
- /// The source of the event.
- /// The instance containing the event data.
- void libraryManager_ItemRemoved(object sender, ItemChangeEventArgs e)
- {
- lock (_libraryChangedSyncLock)
- {
- if (LibraryUpdateInfo == null)
- {
- LibraryUpdateInfo = new LibraryUpdateInfo();
- }
-
- if (LibraryUpdateTimer == null)
- {
- LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,
- Timeout.Infinite);
- }
- else
- {
- LibraryUpdateTimer.Change(LibraryUpdateDuration, Timeout.Infinite);
- }
-
- if (e.Item.Parent != null)
- {
- LibraryUpdateInfo.FoldersRemovedFrom.Add(e.Item.Parent.Id);
- }
-
- LibraryUpdateInfo.ItemsRemoved.Add(e.Item.Id);
- }
- }
-
- ///
- /// Libraries the update timer callback.
- ///
- /// The state.
- private void LibraryUpdateTimerCallback(object state)
- {
- lock (_libraryChangedSyncLock)
- {
- // Remove dupes in case some were saved multiple times
- LibraryUpdateInfo.FoldersAddedTo = LibraryUpdateInfo.FoldersAddedTo.Distinct().ToList();
-
- LibraryUpdateInfo.FoldersRemovedFrom = LibraryUpdateInfo.FoldersRemovedFrom.Distinct().ToList();
-
- LibraryUpdateInfo.ItemsUpdated = LibraryUpdateInfo.ItemsUpdated
- .Where(i => !LibraryUpdateInfo.ItemsAdded.Contains(i))
- .Distinct()
- .ToList();
-
- _serverManager.SendWebSocketMessage("LibraryChanged", LibraryUpdateInfo);
-
- if (LibraryUpdateTimer != null)
- {
- LibraryUpdateTimer.Dispose();
- LibraryUpdateTimer = null;
- }
-
- LibraryUpdateInfo = null;
- }
- }
-
///
/// Installations the manager_ plugin uninstalled.
///
@@ -350,16 +191,6 @@ namespace MediaBrowser.ServerApplication.EntryPoints
{
if (dispose)
{
- if (LibraryUpdateTimer != null)
- {
- LibraryUpdateTimer.Dispose();
- LibraryUpdateTimer = null;
- }
-
- _libraryManager.ItemAdded -= libraryManager_ItemAdded;
- _libraryManager.ItemUpdated -= libraryManager_ItemUpdated;
- _libraryManager.ItemRemoved -= libraryManager_ItemRemoved;
-
_userManager.UserDeleted -= userManager_UserDeleted;
_userManager.UserUpdated -= userManager_UserUpdated;
diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
index 40dde03aaa..19b2d91ca2 100644
--- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
+++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj
@@ -192,6 +192,7 @@
+
diff --git a/MediaBrowser.WebDashboard/Api/DashboardService.cs b/MediaBrowser.WebDashboard/Api/DashboardService.cs
index 683ecda978..d4a4fb7083 100644
--- a/MediaBrowser.WebDashboard/Api/DashboardService.cs
+++ b/MediaBrowser.WebDashboard/Api/DashboardService.cs
@@ -385,7 +385,7 @@ namespace MediaBrowser.WebDashboard.Api
sb.Append("");
sb.Append("");
- sb.Append("");
+ //sb.Append("");
// http://developer.apple.com/library/ios/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
sb.Append("");
diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.js
index 1c5c6339aa..a46fe34874 100644
--- a/MediaBrowser.WebDashboard/ApiClient.js
+++ b/MediaBrowser.WebDashboard/ApiClient.js
@@ -922,7 +922,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
// Closure to capture the file information.
reader.onload = function (e) {
- var data = window.btoa(e.target.result);
+ // Split by a comma to remove the url: prefix
+ var data = e.target.result.split(',')[1];
var url = self.getUrl("Users/" + userId + "/Images/" + imageType);
@@ -941,7 +942,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
};
// Read in the image file as a data URL.
- reader.readAsBinaryString(file);
+ reader.readAsDataURL(file);
return deferred.promise();
};
@@ -979,7 +980,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
// Closure to capture the file information.
reader.onload = function (e) {
- var data = window.btoa(e.target.result);
+ // Split by a comma to remove the url: prefix
+ var data = e.target.result.split(',')[1];
var url = self.getUrl("Items/" + itemId + "/Images/" + imageType);
@@ -998,7 +1000,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
};
// Read in the image file as a data URL.
- reader.readAsBinaryString(file);
+ reader.readAsDataURL(file);
return deferred.promise();
};
diff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.config
index 18aa38dd61..8420a4504e 100644
--- a/MediaBrowser.WebDashboard/packages.config
+++ b/MediaBrowser.WebDashboard/packages.config
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file