aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-05 21:04:41 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-05 21:04:41 -0400
commit82ffaafc0305b8bdbbef60ec821168e15882bf16 (patch)
tree90547e89be36edcff2c68ef563a0e650ce2e31da
parent94becdd339b89b0ca1c7eb5d2163c33015b3de58 (diff)
add more to mbt endpoints
-rw-r--r--MediaBrowser.Api/DefaultTheme/Models.cs1
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs16
-rw-r--r--MediaBrowser.Controller/Entities/Folder.cs56
-rw-r--r--MediaBrowser.Mono.userprefs2
-rw-r--r--MediaBrowser.Server.Mono/Networking/NetworkManager.cs6
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs1
6 files changed, 63 insertions, 19 deletions
diff --git a/MediaBrowser.Api/DefaultTheme/Models.cs b/MediaBrowser.Api/DefaultTheme/Models.cs
index 12fde353b..6b0c39ae7 100644
--- a/MediaBrowser.Api/DefaultTheme/Models.cs
+++ b/MediaBrowser.Api/DefaultTheme/Models.cs
@@ -47,6 +47,7 @@ namespace MediaBrowser.Api.DefaultTheme
public class GamesView
{
public List<BaseItemDto> SpotlightItems { get; set; }
+ public List<ItemStub> MultiPlayerItems { get; set; }
}
public class HomeView
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 1772cc547..6491b2527 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -282,6 +282,14 @@ namespace MediaBrowser.Api.Playback
string.Format(" -vf \"scale={0}:-1{1}\"", request.Width.Value, assSubtitleParam);
}
+ // If a fixed height was requested
+ if (request.Height.HasValue)
+ {
+ return isH264Output ?
+ string.Format(" -vf \"scale={0}:trunc(oh/a/2)*2{1}\"", request.Height.Value, assSubtitleParam) :
+ string.Format(" -vf \"scale=-1{1}:{0}\"", request.Height.Value, assSubtitleParam);
+ }
+
// If a max width was requested
if (request.MaxWidth.HasValue && (!request.MaxHeight.HasValue || state.VideoStream == null))
{
@@ -290,6 +298,14 @@ namespace MediaBrowser.Api.Playback
string.Format(" -vf \"scale=min(iw\\,{0}):-1{1}\"", request.MaxWidth.Value, assSubtitleParam);
}
+ // If a max height was requested
+ if (request.MaxHeight.HasValue && (!request.MaxWidth.HasValue || state.VideoStream == null))
+ {
+ return isH264Output ?
+ string.Format(" -vf \"scale=min(ih\\,{0}):trunc(oh/a/2)*2{1}\"", request.MaxHeight.Value, assSubtitleParam) :
+ string.Format(" -vf \"scale=min(ih\\,{0}):-1{1}\"", request.MaxHeight.Value, assSubtitleParam);
+ }
+
if (state.VideoStream == null)
{
// No way to figure this out
diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs
index e1e7d8751..43b251d8f 100644
--- a/MediaBrowser.Controller/Entities/Folder.cs
+++ b/MediaBrowser.Controller/Entities/Folder.cs
@@ -24,6 +24,8 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class Folder : BaseItem
{
+ public static IUserManager UserManager { get; set; }
+
public Folder()
{
LinkedChildren = new List<LinkedChild>();
@@ -89,6 +91,11 @@ namespace MediaBrowser.Controller.Entities
item.Id = item.Path.GetMBId(item.GetType());
}
+ if (_children.Any(i => i.Id == item.Id))
+ {
+ throw new ArgumentException(string.Format("A child with the Id {0} already exists.", item.Id));
+ }
+
if (item.DateCreated == DateTime.MinValue)
{
item.DateCreated = DateTime.UtcNow;
@@ -718,17 +725,17 @@ namespace MediaBrowser.Controller.Entities
foreach (var item in itemsRemoved)
{
- if (IsRootPathAvailable(item.Path))
- {
- item.IsOffline = false;
- actualRemovals.Add(item);
- }
- else
+ if (IsPathOffline(item.Path))
{
item.IsOffline = true;
validChildren.Add(new Tuple<BaseItem, bool>(item, false));
}
+ else
+ {
+ item.IsOffline = false;
+ actualRemovals.Add(item);
+ }
}
if (actualRemovals.Count > 0)
@@ -855,29 +862,52 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
- /// Determines if a path's root is available or not
+ /// Determines whether the specified path is offline.
/// </summary>
- /// <param name="path"></param>
- /// <returns></returns>
- private bool IsRootPathAvailable(string path)
+ /// <param name="path">The path.</param>
+ /// <returns><c>true</c> if the specified path is offline; otherwise, <c>false</c>.</returns>
+ private bool IsPathOffline(string path)
{
if (File.Exists(path))
{
- return true;
+ return false;
}
+ var originalPath = path;
+
// Depending on whether the path is local or unc, it may return either null or '\' at the top
while (!string.IsNullOrEmpty(path) && path.Length > 1)
{
if (Directory.Exists(path))
{
- return true;
+ return false;
}
path = System.IO.Path.GetDirectoryName(path);
}
- return false;
+ if (ContainsPath(LibraryManager.GetDefaultVirtualFolders(), originalPath))
+ {
+ return true;
+ }
+
+ return UserManager.Users.Any(user => ContainsPath(LibraryManager.GetVirtualFolders(user), originalPath));
+ }
+
+ /// <summary>
+ /// Determines whether the specified folders contains path.
+ /// </summary>
+ /// <param name="folders">The folders.</param>
+ /// <param name="path">The path.</param>
+ /// <returns><c>true</c> if the specified folders contains path; otherwise, <c>false</c>.</returns>
+ private bool ContainsPath(IEnumerable<VirtualFolderInfo> folders, string path)
+ {
+ return folders.SelectMany(i => i.Locations).Any(i => ContainsPath(i, path));
+ }
+
+ private bool ContainsPath(string parent, string path)
+ {
+ return string.Equals(parent, path, StringComparison.OrdinalIgnoreCase) || path.IndexOf(parent.TrimEnd(System.IO.Path.DirectorySeparatorChar) + System.IO.Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase) != -1;
}
/// <summary>
diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs
index 3ab6829eb..a4119f627 100644
--- a/MediaBrowser.Mono.userprefs
+++ b/MediaBrowser.Mono.userprefs
@@ -4,7 +4,7 @@
<Files>
<File FileName="MediaBrowser.Server.Implementations\HttpServer\HttpServer.cs" Line="1" Column="1" />
<File FileName="MediaBrowser.Server.Mono\FFMpeg\FFMpegDownloader.cs" Line="1" Column="1" />
- <File FileName="MediaBrowser.Server.Mono\Networking\NetworkManager.cs" Line="39" Column="1" />
+ <File FileName="MediaBrowser.Server.Mono\Networking\NetworkManager.cs" Line="28" Column="9" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
diff --git a/MediaBrowser.Server.Mono/Networking/NetworkManager.cs b/MediaBrowser.Server.Mono/Networking/NetworkManager.cs
index e9f769a3d..174d061bf 100644
--- a/MediaBrowser.Server.Mono/Networking/NetworkManager.cs
+++ b/MediaBrowser.Server.Mono/Networking/NetworkManager.cs
@@ -23,12 +23,8 @@ namespace MediaBrowser.ServerApplication.Networking
}
/// <summary>
- /// Uses the DllImport : NetServerEnum with all its required parameters
- /// (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/netserverenum.asp
- /// for full details or method signature) to retrieve a list of domain SV_TYPE_WORKSTATION
- /// and SV_TYPE_SERVER PC's
+ /// Gets a list of network devices
/// </summary>
- /// <returns>Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER
/// PC's in the Domain</returns>
public IEnumerable<string> GetNetworkDevices()
{
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 50074947d..985a27d93 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -402,6 +402,7 @@ namespace MediaBrowser.ServerApplication
User.XmlSerializer = XmlSerializer;
User.UserManager = UserManager;
LocalizedStrings.ApplicationPaths = ApplicationPaths;
+ Folder.UserManager = UserManager;
}
/// <summary>