This commit is contained in:
Eric Reed 2013-05-17 11:53:13 -04:00
commit 584641a6f4
19 changed files with 285 additions and 221 deletions

View file

@ -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)

View file

@ -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 + ".");
}

View file

@ -55,6 +55,7 @@
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>

View file

@ -133,6 +133,11 @@ namespace MediaBrowser.Api.UserLibrary
/// <returns>IEnumerable{IbnStub}.</returns>
private IEnumerable<IbnStub<TItemType>> FilterItems(GetItemsByName request, IEnumerable<IbnStub<TItemType>> 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; }
/// <summary>
/// What to sort the results by
/// </summary>

View file

@ -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; }
/// <summary>
/// Gets or sets the air days.
/// </summary>
@ -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; }
/// <summary>
/// Gets the order by.
/// </summary>
@ -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)
{

View file

@ -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
/// <summary>
/// The TVDB API key
/// </summary>
public static readonly string TVDBApiKey = "B89CE93890E9419B";
public static readonly string TvdbApiKey = "B89CE93890E9419B";
/// <summary>
/// The banner URL
/// </summary>
@ -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))
{

View file

@ -286,7 +286,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// <summary>
/// The dummy chapter duration
/// </summary>
private readonly long DummyChapterDuration = TimeSpan.FromMinutes(10).Ticks;
private readonly long _dummyChapterDuration = TimeSpan.FromMinutes(5).Ticks;
/// <summary>
/// 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;

View file

@ -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;
}
}
}

View file

@ -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;

View file

@ -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
{

View file

@ -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
/// <returns>Task.</returns>
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

View file

@ -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;
}

View file

@ -378,19 +378,16 @@ namespace MediaBrowser.ServerApplication
RegisterServerWithAdministratorAccess();
}
base.FindParts();
HttpServer.Init(GetExports<IRestfulService>(false));
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
StartServer(true);
Parallel.Invoke(
() => base.FindParts(),
() =>
{
HttpServer.Init(GetExports<IRestfulService>(false));
ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
StartServer(true);
},
() => LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IItemResolver>(), GetExports<IIntroProvider>(), GetExports<IBaseItemComparer>()),
() => ProviderManager.AddMetadataProviders(GetExports<BaseMetadataProvider>().ToArray()),

View file

@ -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
{
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly ISessionManager _sessionManager;
private readonly IServerManager _serverManager;
/// <summary>
/// The _library changed sync lock
/// </summary>
private readonly object _libraryChangedSyncLock = new object();
/// <summary>
/// Gets or sets the library update info.
/// </summary>
/// <value>The library update info.</value>
private LibraryUpdateInfo LibraryUpdateInfo { get; set; }
/// <summary>
/// Gets or sets the library update timer.
/// </summary>
/// <value>The library update timer.</value>
private Timer LibraryUpdateTimer { get; set; }
/// <summary>
/// The library update duration
/// </summary>
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;
}
/// <summary>
/// Handles the ItemAdded event of the libraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
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);
}
}
/// <summary>
/// Handles the ItemUpdated event of the libraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
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);
}
}
/// <summary>
/// Handles the ItemRemoved event of the libraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
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);
}
}
/// <summary>
/// Libraries the update timer callback.
/// </summary>
/// <param name="state">The state.</param>
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;
}
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
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;
}
}
}
}

View file

@ -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
/// </summary>
private readonly IUserManager _userManager;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
/// <summary>
/// The _installation manager
/// </summary>
@ -57,40 +49,17 @@ namespace MediaBrowser.ServerApplication.EntryPoints
/// </summary>
private readonly ITaskManager _taskManager;
/// <summary>
/// The _library changed sync lock
/// </summary>
private readonly object _libraryChangedSyncLock = new object();
/// <summary>
/// Gets or sets the library update info.
/// </summary>
/// <value>The library update info.</value>
private LibraryUpdateInfo LibraryUpdateInfo { get; set; }
/// <summary>
/// Gets or sets the library update timer.
/// </summary>
/// <value>The library update timer.</value>
private Timer LibraryUpdateTimer { get; set; }
/// <summary>
/// The library update duration
/// </summary>
private const int LibraryUpdateDuration = 60000;
/// <summary>
/// Initializes a new instance of the <see cref="WebSocketEvents" /> class.
/// </summary>
/// <param name="serverManager">The server manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="userManager">The user manager.</param>
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);
}
/// <summary>
/// Handles the ItemAdded event of the libraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
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);
}
}
/// <summary>
/// Handles the ItemUpdated event of the libraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
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);
}
}
/// <summary>
/// Handles the ItemRemoved event of the libraryManager control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="ItemChangeEventArgs"/> instance containing the event data.</param>
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);
}
}
/// <summary>
/// Libraries the update timer callback.
/// </summary>
/// <param name="state">The state.</param>
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;
}
}
/// <summary>
/// Installations the manager_ plugin uninstalled.
/// </summary>
@ -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;

View file

@ -192,6 +192,7 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="EntryPoints\LibraryChangedNotifier.cs" />
<Compile Include="EntryPoints\LoadRegistrations.cs" />
<Compile Include="EntryPoints\RefreshUsersMetadata.cs" />
<Compile Include="EntryPoints\StartupWizard.cs" />

View file

@ -385,7 +385,7 @@ namespace MediaBrowser.WebDashboard.Api
sb.Append("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">");
sb.Append("<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">");
sb.Append("<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\">");
//sb.Append("<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\">");
// http://developer.apple.com/library/ios/#DOCUMENTATION/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
sb.Append("<link rel=\"apple-touch-icon\" href=\"css/images/touchicon.png\" />");

View file

@ -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();
};

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.114" targetFramework="net45" />
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.115" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.45" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.45" targetFramework="net45" />
</packages>