Browse Source

Merge pull request #1558 from MediaBrowser/dev

Dev
Luke 9 years ago
parent
commit
5a750be1e3

+ 4 - 4
MediaBrowser.Api/Library/LibraryStructureService.cs

@@ -201,10 +201,10 @@ namespace MediaBrowser.Api.Library
             var rootFolderPath = _appPaths.DefaultUserViewsPath;
             var rootFolderPath = _appPaths.DefaultUserViewsPath;
 
 
             var virtualFolderPath = Path.Combine(rootFolderPath, name);
             var virtualFolderPath = Path.Combine(rootFolderPath, name);
-
-            if (_fileSystem.DirectoryExists(virtualFolderPath))
+            while (_fileSystem.DirectoryExists(virtualFolderPath))
             {
             {
-                throw new ArgumentException("There is already a media library with the name " + name + ".");
+                name += "1";
+                virtualFolderPath = Path.Combine(rootFolderPath, name);
             }
             }
 
 
             if (request.Paths != null)
             if (request.Paths != null)
@@ -236,7 +236,7 @@ namespace MediaBrowser.Api.Library
                 {
                 {
                     foreach (var path in request.Paths)
                     foreach (var path in request.Paths)
                     {
                     {
-                        LibraryHelpers.AddMediaPath(_fileSystem, request.Name, path, _appPaths);
+                        LibraryHelpers.AddMediaPath(_fileSystem, name, path, _appPaths);
                     }
                     }
                 }
                 }
             }
             }

+ 7 - 0
MediaBrowser.Controller/Entities/BaseItem.cs

@@ -57,7 +57,9 @@ namespace MediaBrowser.Controller.Entities
         public static string ThemeSongFilename = "theme";
         public static string ThemeSongFilename = "theme";
         public static string ThemeVideosFolderName = "backdrops";
         public static string ThemeVideosFolderName = "backdrops";
 
 
+        [IgnoreDataMember]
         public string PreferredMetadataCountryCode { get; set; }
         public string PreferredMetadataCountryCode { get; set; }
+        [IgnoreDataMember]
         public string PreferredMetadataLanguage { get; set; }
         public string PreferredMetadataLanguage { get; set; }
 
 
         public List<ItemImageInfo> ImageInfos { get; set; }
         public List<ItemImageInfo> ImageInfos { get; set; }
@@ -88,6 +90,7 @@ namespace MediaBrowser.Controller.Entities
         /// Gets a value indicating whether this instance is in mixed folder.
         /// Gets a value indicating whether this instance is in mixed folder.
         /// </summary>
         /// </summary>
         /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
         /// <value><c>true</c> if this instance is in mixed folder; otherwise, <c>false</c>.</value>
+        [IgnoreDataMember]
         public bool IsInMixedFolder { get; set; }
         public bool IsInMixedFolder { get; set; }
 
 
         [IgnoreDataMember]
         [IgnoreDataMember]
@@ -342,6 +345,7 @@ namespace MediaBrowser.Controller.Entities
         [IgnoreDataMember]
         [IgnoreDataMember]
         public DateTime DateModified { get; set; }
         public DateTime DateModified { get; set; }
 
 
+        [IgnoreDataMember]
         public DateTime DateLastSaved { get; set; }
         public DateTime DateLastSaved { get; set; }
 
 
         [IgnoreDataMember]
         [IgnoreDataMember]
@@ -380,6 +384,7 @@ namespace MediaBrowser.Controller.Entities
         /// Gets or sets the locked fields.
         /// Gets or sets the locked fields.
         /// </summary>
         /// </summary>
         /// <value>The locked fields.</value>
         /// <value>The locked fields.</value>
+        [IgnoreDataMember]
         public List<MetadataFields> LockedFields { get; set; }
         public List<MetadataFields> LockedFields { get; set; }
 
 
         /// <summary>
         /// <summary>
@@ -620,6 +625,7 @@ namespace MediaBrowser.Controller.Entities
         /// Gets or sets the studios.
         /// Gets or sets the studios.
         /// </summary>
         /// </summary>
         /// <value>The studios.</value>
         /// <value>The studios.</value>
+        [IgnoreDataMember]
         public List<string> Studios { get; set; }
         public List<string> Studios { get; set; }
 
 
         /// <summary>
         /// <summary>
@@ -633,6 +639,7 @@ namespace MediaBrowser.Controller.Entities
         /// Gets or sets the tags.
         /// Gets or sets the tags.
         /// </summary>
         /// </summary>
         /// <value>The tags.</value>
         /// <value>The tags.</value>
+        [IgnoreDataMember]
         public List<string> Tags { get; set; }
         public List<string> Tags { get; set; }
 
 
         /// <summary>
         /// <summary>

+ 2 - 0
MediaBrowser.Controller/Entities/Book.cs

@@ -2,6 +2,7 @@
 using MediaBrowser.Model.Configuration;
 using MediaBrowser.Model.Configuration;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
+using System.Runtime.Serialization;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Users;
 using MediaBrowser.Model.Users;
 
 
@@ -9,6 +10,7 @@ namespace MediaBrowser.Controller.Entities
 {
 {
     public class Book : BaseItem, IHasTags, IHasLookupInfo<BookInfo>, IHasSeries
     public class Book : BaseItem, IHasTags, IHasLookupInfo<BookInfo>, IHasSeries
     {
     {
+        [IgnoreDataMember]
         public override string MediaType
         public override string MediaType
         {
         {
             get
             get

+ 0 - 1
MediaBrowser.Controller/Entities/Trailer.cs

@@ -14,7 +14,6 @@ namespace MediaBrowser.Controller.Entities
     /// <summary>
     /// <summary>
     /// Class Trailer
     /// Class Trailer
     /// </summary>
     /// </summary>
-    [Obsolete]
     public class Trailer : Video, IHasCriticRating, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTaglines, IHasMetascore, IHasLookupInfo<TrailerInfo>
     public class Trailer : Video, IHasCriticRating, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTaglines, IHasMetascore, IHasLookupInfo<TrailerInfo>
     {
     {
         public List<string> ProductionLocations { get; set; }
         public List<string> ProductionLocations { get; set; }

+ 1 - 1
MediaBrowser.Dlna/ContentDirectory/ControlHandler.cs

@@ -488,7 +488,7 @@ namespace MediaBrowser.Dlna.ContentDirectory
             var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
             var itemsResult = _libraryManager.GetItemsResult(new InternalItemsQuery(user)
             {
             {
                 Person = person.Name,
                 Person = person.Name,
-                IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(ChannelVideoItem).Name },
+                IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name, typeof(Trailer).Name, typeof(ChannelVideoItem).Name },
                 SortBy = new[] { ItemSortBy.SortName },
                 SortBy = new[] { ItemSortBy.SortName },
                 Limit = limit,
                 Limit = limit,
                 StartIndex = startIndex
                 StartIndex = startIndex

+ 18 - 23
MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs

@@ -21,6 +21,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Security;
 using MediaBrowser.Common.Security;
+using MediaBrowser.Model.Extensions;
 
 
 namespace MediaBrowser.Server.Implementations.HttpServer
 namespace MediaBrowser.Server.Implementations.HttpServer
 {
 {
@@ -342,16 +343,26 @@ namespace MediaBrowser.Server.Implementations.HttpServer
                 urlToLog = GetUrlToLog(urlString);
                 urlToLog = GetUrlToLog(urlString);
                 LoggerUtils.LogRequest(_logger, urlToLog, httpReq.HttpMethod, httpReq.UserAgent);
                 LoggerUtils.LogRequest(_logger, urlToLog, httpReq.HttpMethod, httpReq.UserAgent);
             }
             }
-            
+
             if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) ||
             if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase) ||
-                string.Equals(localPath, "/emby/", StringComparison.OrdinalIgnoreCase))
+                string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase) ||
+                localPath.IndexOf("mediabrowser/web", StringComparison.OrdinalIgnoreCase) != -1 ||
+                localPath.IndexOf("dashboard/", StringComparison.OrdinalIgnoreCase) != -1)
             {
             {
-                httpRes.RedirectToUrl(DefaultRedirectPath);
+                httpRes.StatusCode = 200;
+                httpRes.ContentType = "text/html";
+                var newUrl = urlString.Replace("mediabrowser", "emby", StringComparison.OrdinalIgnoreCase)
+                    .Replace("/dashboard/", "/web/", StringComparison.OrdinalIgnoreCase);
+
+                httpRes.Write("<!doctype html><html><head><title>Emby</title></head><body>Please update your Emby bookmark to <a href=\"" + newUrl + "\">" + newUrl + "</a></body></html>");
+
+                httpRes.Close();
                 return Task.FromResult(true);
                 return Task.FromResult(true);
             }
             }
-            if (string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase))
+
+            if (string.Equals(localPath, "/emby/", StringComparison.OrdinalIgnoreCase))
             {
             {
-                httpRes.RedirectToUrl("mediabrowser/" + DefaultRedirectPath);
+                httpRes.RedirectToUrl(DefaultRedirectPath);
                 return Task.FromResult(true);
                 return Task.FromResult(true);
             }
             }
             if (string.Equals(localPath, "/emby", StringComparison.OrdinalIgnoreCase))
             if (string.Equals(localPath, "/emby", StringComparison.OrdinalIgnoreCase))
@@ -385,7 +396,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
                 httpRes.RedirectToUrl("web/pin.html");
                 httpRes.RedirectToUrl("web/pin.html");
                 return Task.FromResult(true);
                 return Task.FromResult(true);
             }
             }
-            
+
             if (!string.IsNullOrWhiteSpace(GlobalResponse))
             if (!string.IsNullOrWhiteSpace(GlobalResponse))
             {
             {
                 httpRes.StatusCode = 503;
                 httpRes.StatusCode = 503;
@@ -461,6 +472,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
                     Priority = route.Priority,
                     Priority = route.Priority,
                     Summary = route.Summary
                     Summary = route.Summary
                 });
                 });
+
                 routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs)
                 routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs)
                 {
                 {
                     Notes = route.Notes,
                     Notes = route.Notes,
@@ -468,13 +480,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
                     Summary = route.Summary
                     Summary = route.Summary
                 });
                 });
 
 
-                // TODO: This is a hack for iOS. Remove it asap.
-                routes.Add(new RouteAttribute(DoubleNormalizeRoutePath(route.Path), route.Verbs)
-                {
-                    Notes = route.Notes,
-                    Priority = route.Priority,
-                    Summary = route.Summary
-                });
                 routes.Add(new RouteAttribute(DoubleNormalizeEmbyRoutePath(route.Path), route.Verbs)
                 routes.Add(new RouteAttribute(DoubleNormalizeEmbyRoutePath(route.Path), route.Verbs)
                 {
                 {
                     Notes = route.Notes,
                     Notes = route.Notes,
@@ -516,16 +521,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
             return "mediabrowser/" + path;
             return "mediabrowser/" + path;
         }
         }
 
 
-        private string DoubleNormalizeRoutePath(string path)
-        {
-            if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
-            {
-                return "/mediabrowser/mediabrowser" + path;
-            }
-
-            return "mediabrowser/mediabrowser/" + path;
-        }
-
         /// <summary>
         /// <summary>
         /// Releases the specified instance.
         /// Releases the specified instance.
         /// </summary>
         /// </summary>

+ 32 - 1
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -348,7 +348,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
             "Genres",
             "Genres",
             "ParentId",
             "ParentId",
             "Audio",
             "Audio",
-            "ExternalServiceId"
+            "ExternalServiceId",
+            "IsInMixedFolder",
+            "DateLastSaved",
+            "LockedFields",
+            "Studios",
+            "Tags"
         };
         };
 
 
         private readonly string[] _mediaStreamSaveColumns =
         private readonly string[] _mediaStreamSaveColumns =
@@ -1079,6 +1084,31 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 }
                 }
             }
             }
 
 
+            if (!reader.IsDBNull(44))
+            {
+                item.IsInMixedFolder = reader.GetBoolean(44);
+            }
+
+            if (!reader.IsDBNull(45))
+            {
+                item.DateLastSaved = reader.GetDateTime(45).ToUniversalTime();
+            }
+
+            if (!reader.IsDBNull(46))
+            {
+                item.LockedFields = reader.GetString(46).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (MetadataFields)Enum.Parse(typeof(MetadataFields), i, true)).ToList();
+            }
+
+            if (!reader.IsDBNull(47))
+            {
+                item.Studios = reader.GetString(47).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
+            }
+
+            if (!reader.IsDBNull(48))
+            {
+                item.Tags = reader.GetString(48).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
+            }
+
             return item;
             return item;
         }
         }
 
 
@@ -2013,6 +2043,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
             typeof(MusicGenre),
             typeof(MusicGenre),
             typeof(MusicVideo),
             typeof(MusicVideo),
             typeof(Movie),
             typeof(Movie),
+            typeof(Trailer),
             typeof(BoxSet),
             typeof(BoxSet),
             typeof(Episode),
             typeof(Episode),
             typeof(ChannelVideoItem),
             typeof(ChannelVideoItem),

+ 1 - 5
MediaBrowser.WebDashboard/Api/DashboardService.cs

@@ -25,7 +25,6 @@ namespace MediaBrowser.WebDashboard.Api
     /// <summary>
     /// <summary>
     /// Class GetDashboardConfigurationPages
     /// Class GetDashboardConfigurationPages
     /// </summary>
     /// </summary>
-    [Route("/dashboard/ConfigurationPages", "GET")]
     [Route("/web/ConfigurationPages", "GET")]
     [Route("/web/ConfigurationPages", "GET")]
     public class GetDashboardConfigurationPages : IReturn<List<ConfigurationPageInfo>>
     public class GetDashboardConfigurationPages : IReturn<List<ConfigurationPageInfo>>
     {
     {
@@ -39,7 +38,6 @@ namespace MediaBrowser.WebDashboard.Api
     /// <summary>
     /// <summary>
     /// Class GetDashboardConfigurationPage
     /// Class GetDashboardConfigurationPage
     /// </summary>
     /// </summary>
-    [Route("/dashboard/ConfigurationPage", "GET")]
     [Route("/web/ConfigurationPage", "GET")]
     [Route("/web/ConfigurationPage", "GET")]
     public class GetDashboardConfigurationPage
     public class GetDashboardConfigurationPage
     {
     {
@@ -51,7 +49,6 @@ namespace MediaBrowser.WebDashboard.Api
     }
     }
 
 
     [Route("/web/Package", "GET")]
     [Route("/web/Package", "GET")]
-    [Route("/dashboard/Package", "GET")]
     public class GetDashboardPackage
     public class GetDashboardPackage
     {
     {
         public string Mode { get; set; }
         public string Mode { get; set; }
@@ -66,7 +63,6 @@ namespace MediaBrowser.WebDashboard.Api
     /// Class GetDashboardResource
     /// Class GetDashboardResource
     /// </summary>
     /// </summary>
     [Route("/web/{ResourceName*}", "GET")]
     [Route("/web/{ResourceName*}", "GET")]
-    [Route("/dashboard/{ResourceName*}", "GET")]
     public class GetDashboardResource
     public class GetDashboardResource
     {
     {
         /// <summary>
         /// <summary>
@@ -142,7 +138,7 @@ namespace MediaBrowser.WebDashboard.Api
         {
         {
             var page = ServerEntryPoint.Instance.PluginConfigurationPages.First(p => p.Name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
             var page = ServerEntryPoint.Instance.PluginConfigurationPages.First(p => p.Name.Equals(request.Name, StringComparison.OrdinalIgnoreCase));
 
 
-            return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml(null, page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false));
+            return ResultFactory.GetStaticResult(Request, page.Plugin.Version.ToString().GetMD5(), null, null, MimeTypes.GetMimeType("page.html"), () => GetPackageCreator().ModifyHtml("dummy.html", page.GetHtmlStream(), null, _appHost.ApplicationVersion.ToString(), null, false));
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 20 - 3
MediaBrowser.WebDashboard/Api/PackageCreator.cs

@@ -261,11 +261,21 @@ namespace MediaBrowser.WebDashboard.Api
                     {
                     {
                         html = ModifyForCordova(html);
                         html = ModifyForCordova(html);
                     }
                     }
-                    else if (!string.IsNullOrWhiteSpace(path) && !string.Equals(path, "index.html", StringComparison.OrdinalIgnoreCase) && html.IndexOf("<html", StringComparison.OrdinalIgnoreCase) == -1)
+                    else if (!string.IsNullOrWhiteSpace(path) && !string.Equals(path, "index.html", StringComparison.OrdinalIgnoreCase))
                     {
                     {
-                        var indexFile = File.ReadAllText(GetDashboardResourcePath("index.html"));
+                        var index = html.IndexOf("<body", StringComparison.OrdinalIgnoreCase);
+                        if (index != -1)
+                        {
+                            html = html.Substring(index);
+                            index = html.IndexOf("</body>", StringComparison.OrdinalIgnoreCase);
+                            if (index != -1)
+                            {
+                                html = html.Substring(0, index+7);
+                            }
+                        }
+                        var mainFile = File.ReadAllText(GetDashboardResourcePath("index.html"));
 
 
-                        html = ReplaceFirst(indexFile, "<div class=\"mainAnimatedPage hide\"></div>", "<div class=\"mainAnimatedPage hide\">" + html + "</div>");
+                        html = ReplaceFirst(mainFile, "<div class=\"mainAnimatedPage hide\"></div>", "<div class=\"mainAnimatedPage hide\">" + html + "</div>");
                     }
                     }
 
 
                     if (!string.IsNullOrWhiteSpace(localizationCulture))
                     if (!string.IsNullOrWhiteSpace(localizationCulture))
@@ -305,6 +315,13 @@ namespace MediaBrowser.WebDashboard.Api
 
 
                 html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, appVersion));
                 html = html.Replace("<head>", "<head>" + GetMetaTags(mode) + GetCommonCss(mode, appVersion));
 
 
+                // Disable embedded scripts from plugins. We'll run them later once resources have loaded
+                if (html.IndexOf("<script", StringComparison.OrdinalIgnoreCase) != -1)
+                {
+                    html = html.Replace("<script", "<!--<script");
+                    html = html.Replace("</script>", "</script>-->");
+                }
+
                 html = html.Replace("</body>", GetCommonJavascript(mode, appVersion) + "</body>");
                 html = html.Replace("</body>", GetCommonJavascript(mode, appVersion) + "</body>");
 
 
                 var bytes = Encoding.UTF8.GetBytes(html);
                 var bytes = Encoding.UTF8.GetBytes(html);

+ 16 - 5
MediaBrowser.XbmcMetadata/Parsers/MovieNfoParser.cs

@@ -36,13 +36,24 @@ namespace MediaBrowser.XbmcMetadata.Parsers
             switch (reader.Name)
             switch (reader.Name)
             {
             {
                 case "id":
                 case "id":
-                    var id = reader.ReadElementContentAsString();
-                    if (!string.IsNullOrWhiteSpace(id))
                     {
                     {
-                        item.SetProviderId(MetadataProviders.Imdb, id);
-                    }
-                    break;
+                        string imdbId = reader.GetAttribute("IMDB");
+                        string tmdbId = reader.GetAttribute("TMDB");
 
 
+                        if (string.IsNullOrWhiteSpace(imdbId))
+                        {
+                            imdbId = reader.ReadElementContentAsString();
+                        }
+                        if (!string.IsNullOrWhiteSpace(imdbId))
+                        {
+                            item.SetProviderId(MetadataProviders.Imdb, imdbId);
+                        }
+                        if (!string.IsNullOrWhiteSpace(tmdbId))
+                        {
+                            item.SetProviderId(MetadataProviders.Tmdb, tmdbId);
+                        }
+                        break;
+                    }
                 case "set":
                 case "set":
                     {
                     {
                         var movie = item as Movie;
                         var movie = item as Movie;

+ 21 - 5
MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs

@@ -27,13 +27,29 @@ namespace MediaBrowser.XbmcMetadata.Parsers
             switch (reader.Name)
             switch (reader.Name)
             {
             {
                 case "id":
                 case "id":
-                    string id = reader.ReadElementContentAsString();
-                    if (!string.IsNullOrWhiteSpace(id))
                     {
                     {
-                        item.SetProviderId(MetadataProviders.Tvdb, id);
-                    }
-                    break;
+                        string imdbId = reader.GetAttribute("IMDB");
+                        string tmdbId = reader.GetAttribute("TMDB");
+                        string tvdbId = reader.GetAttribute("TVDB");
 
 
+                        if (string.IsNullOrWhiteSpace(tvdbId))
+                        {
+                            tvdbId = reader.ReadElementContentAsString();
+                        }
+                        if (!string.IsNullOrWhiteSpace(imdbId))
+                        {
+                            item.SetProviderId(MetadataProviders.Imdb, imdbId);
+                        }
+                        if (!string.IsNullOrWhiteSpace(tmdbId))
+                        {
+                            item.SetProviderId(MetadataProviders.Tmdb, tmdbId);
+                        }
+                        if (!string.IsNullOrWhiteSpace(tvdbId))
+                        {
+                            item.SetProviderId(MetadataProviders.Tvcom, tvdbId);
+                        }
+                        break;
+                    }
                 case "airs_dayofweek":
                 case "airs_dayofweek":
                     {
                     {
                         item.AirDays = TVUtils.GetAirDays(reader.ReadElementContentAsString());
                         item.AirDays = TVUtils.GetAirDays(reader.ReadElementContentAsString());