mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-11 01:24:36 -04:00
commit
c5ff30f66e
@ -1,7 +1,10 @@
|
|||||||
using MediaBrowser.Api.Playback;
|
using MediaBrowser.Api.Playback;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Plugins;
|
using MediaBrowser.Controller.Plugins;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Session;
|
using MediaBrowser.Model.Session;
|
||||||
using System;
|
using System;
|
||||||
@ -33,7 +36,7 @@ namespace MediaBrowser.Api
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The application paths
|
/// The application paths
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
private readonly ISessionManager _sessionManager;
|
private readonly ISessionManager _sessionManager;
|
||||||
|
|
||||||
@ -43,13 +46,13 @@ namespace MediaBrowser.Api
|
|||||||
/// Initializes a new instance of the <see cref="ApiEntryPoint" /> class.
|
/// Initializes a new instance of the <see cref="ApiEntryPoint" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
/// <param name="appPaths">The application paths.</param>
|
|
||||||
/// <param name="sessionManager">The session manager.</param>
|
/// <param name="sessionManager">The session manager.</param>
|
||||||
public ApiEntryPoint(ILogger logger, IServerApplicationPaths appPaths, ISessionManager sessionManager)
|
/// <param name="config">The configuration.</param>
|
||||||
|
public ApiEntryPoint(ILogger logger, ISessionManager sessionManager, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
_appPaths = appPaths;
|
|
||||||
_sessionManager = sessionManager;
|
_sessionManager = sessionManager;
|
||||||
|
_config = config;
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
@ -73,12 +76,19 @@ namespace MediaBrowser.Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EncodingOptions GetEncodingOptions()
|
||||||
|
{
|
||||||
|
return _config.GetConfiguration<EncodingOptions>("encoding");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deletes the encoded media cache.
|
/// Deletes the encoded media cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void DeleteEncodedMediaCache()
|
private void DeleteEncodedMediaCache()
|
||||||
{
|
{
|
||||||
foreach (var file in Directory.EnumerateFiles(_appPaths.TranscodingTempPath, "*", SearchOption.AllDirectories)
|
var path = Path.Combine(_config.ApplicationPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower());
|
||||||
|
|
||||||
|
foreach (var file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories)
|
||||||
.ToList())
|
.ToList())
|
||||||
{
|
{
|
||||||
File.Delete(file);
|
File.Delete(file);
|
||||||
@ -185,7 +195,9 @@ namespace MediaBrowser.Api
|
|||||||
CompletionPercentage = percentComplete,
|
CompletionPercentage = percentComplete,
|
||||||
Width = state.OutputWidth,
|
Width = state.OutputWidth,
|
||||||
Height = state.OutputHeight,
|
Height = state.OutputHeight,
|
||||||
AudioChannels = state.OutputAudioChannels
|
AudioChannels = state.OutputAudioChannels,
|
||||||
|
IsAudioDirect = string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase),
|
||||||
|
IsVideoDirect = string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ namespace MediaBrowser.Api
|
|||||||
|
|
||||||
public void Post(AutoSetMetadataOptions request)
|
public void Post(AutoSetMetadataOptions request)
|
||||||
{
|
{
|
||||||
_configurationManager.DisableMetadataService("Media Browser Legacy Xml");
|
_configurationManager.DisableMetadataService("Media Browser Xml");
|
||||||
_configurationManager.SaveConfiguration();
|
_configurationManager.SaveConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Controller.Dlna;
|
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using ServiceStack.Text.Controller;
|
using ServiceStack.Text.Controller;
|
||||||
using ServiceStack.Web;
|
using ServiceStack.Web;
|
||||||
@ -77,14 +76,11 @@ namespace MediaBrowser.Api.Dlna
|
|||||||
private readonly IContentDirectory _contentDirectory;
|
private readonly IContentDirectory _contentDirectory;
|
||||||
private readonly IConnectionManager _connectionManager;
|
private readonly IConnectionManager _connectionManager;
|
||||||
|
|
||||||
private readonly IConfigurationManager _config;
|
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager)
|
||||||
|
|
||||||
public DlnaServerService(IDlnaManager dlnaManager, IContentDirectory contentDirectory, IConnectionManager connectionManager, IConfigurationManager config)
|
|
||||||
{
|
{
|
||||||
_dlnaManager = dlnaManager;
|
_dlnaManager = dlnaManager;
|
||||||
_contentDirectory = contentDirectory;
|
_contentDirectory = contentDirectory;
|
||||||
_connectionManager = connectionManager;
|
_connectionManager = connectionManager;
|
||||||
_config = config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetDescriptionXml request)
|
public object Get(GetDescriptionXml request)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -28,17 +28,7 @@ namespace MediaBrowser.Api
|
|||||||
options.ImageTypeLimit = request.ImageTypeLimit.Value;
|
options.ImageTypeLimit = request.ImageTypeLimit.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(request.EnableImageTypes))
|
if (!string.IsNullOrWhiteSpace(request.EnableImageTypes))
|
||||||
{
|
|
||||||
if (options.EnableImages)
|
|
||||||
{
|
|
||||||
// Get everything
|
|
||||||
options.ImageTypes = Enum.GetNames(typeof(ImageType))
|
|
||||||
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList();
|
options.ImageTypes = (request.EnableImageTypes ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToList();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Images
|
namespace MediaBrowser.Api.Images
|
||||||
{
|
{
|
||||||
@ -668,26 +669,26 @@ namespace MediaBrowser.Api.Images
|
|||||||
{
|
{
|
||||||
if (format == ImageFormat.Bmp)
|
if (format == ImageFormat.Bmp)
|
||||||
{
|
{
|
||||||
return Common.Net.MimeTypes.GetMimeType("i.bmp");
|
return MimeTypes.GetMimeType("i.bmp");
|
||||||
}
|
}
|
||||||
if (format == ImageFormat.Gif)
|
if (format == ImageFormat.Gif)
|
||||||
{
|
{
|
||||||
return Common.Net.MimeTypes.GetMimeType("i.gif");
|
return MimeTypes.GetMimeType("i.gif");
|
||||||
}
|
}
|
||||||
if (format == ImageFormat.Jpg)
|
if (format == ImageFormat.Jpg)
|
||||||
{
|
{
|
||||||
return Common.Net.MimeTypes.GetMimeType("i.jpg");
|
return MimeTypes.GetMimeType("i.jpg");
|
||||||
}
|
}
|
||||||
if (format == ImageFormat.Png)
|
if (format == ImageFormat.Png)
|
||||||
{
|
{
|
||||||
return Common.Net.MimeTypes.GetMimeType("i.png");
|
return MimeTypes.GetMimeType("i.png");
|
||||||
}
|
}
|
||||||
if (format == ImageFormat.Webp)
|
if (format == ImageFormat.Webp)
|
||||||
{
|
{
|
||||||
return Common.Net.MimeTypes.GetMimeType("i.webp");
|
return MimeTypes.GetMimeType("i.webp");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Common.Net.MimeTypes.GetMimeType(path);
|
return MimeTypes.GetMimeType(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.LiveTv;
|
||||||
|
using MediaBrowser.Controller.Localization;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -20,14 +25,165 @@ namespace MediaBrowser.Api
|
|||||||
public string ItemId { get; set; }
|
public string ItemId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("/Items/{ItemId}/MetadataEditor", "GET", Summary = "Gets metadata editor info for an item")]
|
||||||
|
public class GetMetadataEditorInfo : IReturn<MetadataEditorInfo>
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "ItemId", Description = "The id of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
|
public string ItemId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("/Items/{ItemId}/ContentType", "POST", Summary = "Updates an item's content type")]
|
||||||
|
public class UpdateItemContentType : IReturnVoid
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "ItemId", Description = "The id of the item", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||||
|
public string ItemId { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "ContentType", Description = "The content type of the item", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||||
|
public string ContentType { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[Authenticated]
|
[Authenticated]
|
||||||
public class ItemUpdateService : BaseApiService
|
public class ItemUpdateService : BaseApiService
|
||||||
{
|
{
|
||||||
private readonly ILibraryManager _libraryManager;
|
private readonly ILibraryManager _libraryManager;
|
||||||
|
private readonly IProviderManager _providerManager;
|
||||||
|
private readonly ILocalizationManager _localizationManager;
|
||||||
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
public ItemUpdateService(ILibraryManager libraryManager)
|
public ItemUpdateService(ILibraryManager libraryManager, IProviderManager providerManager, ILocalizationManager localizationManager, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
_libraryManager = libraryManager;
|
_libraryManager = libraryManager;
|
||||||
|
_providerManager = providerManager;
|
||||||
|
_localizationManager = localizationManager;
|
||||||
|
_config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Get(GetMetadataEditorInfo request)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(request.ItemId);
|
||||||
|
|
||||||
|
var info = new MetadataEditorInfo
|
||||||
|
{
|
||||||
|
ParentalRatingOptions = _localizationManager.GetParentalRatings().ToList(),
|
||||||
|
ExternalIdInfos = _providerManager.GetExternalIdInfos(item).ToList(),
|
||||||
|
Countries = _localizationManager.GetCountries().ToList(),
|
||||||
|
Cultures = _localizationManager.GetCultures().ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
var locationType = item.LocationType;
|
||||||
|
if (locationType == LocationType.FileSystem ||
|
||||||
|
locationType == LocationType.Offline)
|
||||||
|
{
|
||||||
|
if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
|
||||||
|
{
|
||||||
|
var collectionType = _libraryManager.GetInheritedContentType(item);
|
||||||
|
if (string.IsNullOrWhiteSpace(collectionType))
|
||||||
|
{
|
||||||
|
info.ContentTypeOptions = GetContentTypeOptions(true);
|
||||||
|
info.ContentType = _libraryManager.GetContentType(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ToOptimizedResult(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Post(UpdateItemContentType request)
|
||||||
|
{
|
||||||
|
var item = _libraryManager.GetItemById(request.ItemId);
|
||||||
|
var path = item.ContainingFolderPath;
|
||||||
|
|
||||||
|
var types = _config.Configuration.ContentTypes
|
||||||
|
.Where(i => !string.Equals(i.Name, path, StringComparison.OrdinalIgnoreCase))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(request.ContentType))
|
||||||
|
{
|
||||||
|
types.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = path,
|
||||||
|
Value = request.ContentType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_config.Configuration.ContentTypes = types.ToArray();
|
||||||
|
_config.SaveConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<NameValuePair> GetContentTypeOptions(bool isForItem)
|
||||||
|
{
|
||||||
|
var list = new List<NameValuePair>();
|
||||||
|
|
||||||
|
if (isForItem)
|
||||||
|
{
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeInherit",
|
||||||
|
Value = ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeMovies",
|
||||||
|
Value = "movies"
|
||||||
|
});
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeMusic",
|
||||||
|
Value = "music"
|
||||||
|
});
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeTvShows",
|
||||||
|
Value = "tvshows"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isForItem)
|
||||||
|
{
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeBooks",
|
||||||
|
Value = "books"
|
||||||
|
});
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeGames",
|
||||||
|
Value = "games"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeHomeVideos",
|
||||||
|
Value = "homevideos"
|
||||||
|
});
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeMusicVideos",
|
||||||
|
Value = "musicvideos"
|
||||||
|
});
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypePhotos",
|
||||||
|
Value = "photos"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!isForItem)
|
||||||
|
{
|
||||||
|
list.Add(new NameValuePair
|
||||||
|
{
|
||||||
|
Name = "FolderTypeMixed",
|
||||||
|
Value = ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var val in list)
|
||||||
|
{
|
||||||
|
val.Name = _localizationManager.GetLocalizedString(val.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post(UpdateItem request)
|
public void Post(UpdateItem request)
|
||||||
|
@ -272,16 +272,13 @@ namespace MediaBrowser.Api.Library
|
|||||||
items = items.Where(i => i.IsHidden == val).ToList();
|
items = items.Where(i => i.IsHidden == val).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var result = new ItemsResult
|
var result = new ItemsResult
|
||||||
{
|
{
|
||||||
TotalRecordCount = items.Count,
|
TotalRecordCount = items.Count,
|
||||||
|
|
||||||
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields)).ToArray()
|
Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions)).ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
@ -347,10 +344,7 @@ namespace MediaBrowser.Api.Library
|
|||||||
|
|
||||||
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
var user = request.UserId.HasValue ? _userManager.GetUserById(request.UserId.Value) : null;
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
BaseItem parent = item.Parent;
|
BaseItem parent = item.Parent;
|
||||||
|
|
||||||
@ -361,7 +355,7 @@ namespace MediaBrowser.Api.Library
|
|||||||
parent = TranslateParentItem(parent, user);
|
parent = TranslateParentItem(parent, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
baseItemDtos.Add(_dtoService.GetBaseItemDto(parent, fields, user));
|
baseItemDtos.Add(_dtoService.GetBaseItemDto(parent, dtoOptions, user));
|
||||||
|
|
||||||
parent = parent.Parent;
|
parent = parent.Parent;
|
||||||
}
|
}
|
||||||
@ -473,20 +467,20 @@ namespace MediaBrowser.Api.Library
|
|||||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||||
var user = _userManager.GetUserById(auth.UserId);
|
var user = _userManager.GetUserById(auth.UserId);
|
||||||
|
|
||||||
if (item is Playlist)
|
if (item is Playlist || item is BoxSet)
|
||||||
{
|
{
|
||||||
// For now this is allowed if user can see the playlist
|
// For now this is allowed if user can see the playlist
|
||||||
}
|
}
|
||||||
else if (item is ILiveTvRecording)
|
else if (item is ILiveTvRecording)
|
||||||
{
|
{
|
||||||
if (!user.Configuration.EnableLiveTvManagement)
|
if (!user.Policy.EnableLiveTvManagement)
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException();
|
throw new UnauthorizedAccessException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!user.Configuration.EnableContentDeletion)
|
if (!user.Policy.EnableContentDeletion)
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException();
|
throw new UnauthorizedAccessException();
|
||||||
}
|
}
|
||||||
@ -583,11 +577,6 @@ namespace MediaBrowser.Api.Library
|
|||||||
item = item.Parent;
|
item = item.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get everything
|
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var themeSongIds = GetThemeSongIds(item);
|
var themeSongIds = GetThemeSongIds(item);
|
||||||
|
|
||||||
if (themeSongIds.Count == 0 && request.InheritFromParent)
|
if (themeSongIds.Count == 0 && request.InheritFromParent)
|
||||||
@ -608,9 +597,11 @@ namespace MediaBrowser.Api.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
var dtos = themeSongIds.Select(_libraryManager.GetItemById)
|
var dtos = themeSongIds.Select(_libraryManager.GetItemById)
|
||||||
.OrderBy(i => i.SortName)
|
.OrderBy(i => i.SortName)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
|
||||||
|
|
||||||
var items = dtos.ToArray();
|
var items = dtos.ToArray();
|
||||||
|
|
||||||
@ -651,11 +642,6 @@ namespace MediaBrowser.Api.Library
|
|||||||
item = item.Parent;
|
item = item.Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get everything
|
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var themeVideoIds = GetThemeVideoIds(item);
|
var themeVideoIds = GetThemeVideoIds(item);
|
||||||
|
|
||||||
if (themeVideoIds.Count == 0 && request.InheritFromParent)
|
if (themeVideoIds.Count == 0 && request.InheritFromParent)
|
||||||
@ -681,9 +667,11 @@ namespace MediaBrowser.Api.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
var dtos = themeVideoIds.Select(_libraryManager.GetItemById)
|
var dtos = themeVideoIds.Select(_libraryManager.GetItemById)
|
||||||
.OrderBy(i => i.SortName)
|
.OrderBy(i => i.SortName)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
|
||||||
|
|
||||||
var items = dtos.ToArray();
|
var items = dtos.ToArray();
|
||||||
|
|
||||||
@ -754,10 +742,7 @@ namespace MediaBrowser.Api.Library
|
|||||||
: (Folder)_libraryManager.RootFolder)
|
: (Folder)_libraryManager.RootFolder)
|
||||||
: _libraryManager.GetItemById(id);
|
: _libraryManager.GetItemById(id);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var dtos = GetSoundtrackSongIds(item, inheritFromParent)
|
var dtos = GetSoundtrackSongIds(item, inheritFromParent)
|
||||||
.Select(_libraryManager.GetItemById)
|
.Select(_libraryManager.GetItemById)
|
||||||
@ -765,7 +750,7 @@ namespace MediaBrowser.Api.Library
|
|||||||
.SelectMany(i => i.RecursiveChildren)
|
.SelectMany(i => i.RecursiveChildren)
|
||||||
.OfType<Audio>()
|
.OfType<Audio>()
|
||||||
.OrderBy(i => i.SortName)
|
.OrderBy(i => i.SortName)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
|
||||||
|
|
||||||
var items = dtos.ToArray();
|
var items = dtos.ToArray();
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
throw new UnauthorizedAccessException("Anonymous live tv management is not allowed.");
|
throw new UnauthorizedAccessException("Anonymous live tv management is not allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.Configuration.EnableLiveTvManagement)
|
if (!user.Policy.EnableLiveTvManagement)
|
||||||
{
|
{
|
||||||
throw new UnauthorizedAccessException("The current user does not have permission to manage live tv.");
|
throw new UnauthorizedAccessException("The current user does not have permission to manage live tv.");
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Collections;
|
using MediaBrowser.Model.Collections;
|
||||||
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
@ -70,7 +71,9 @@ namespace MediaBrowser.Api.Movies
|
|||||||
|
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
var dto = _dtoService.GetBaseItemDto(item, new List<ItemFields>());
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
|
var dto = _dtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
|
|
||||||
return ToOptimizedResult(new CollectionCreationResult
|
return ToOptimizedResult(new CollectionCreationResult
|
||||||
{
|
{
|
||||||
|
@ -157,7 +157,11 @@ namespace MediaBrowser.Api.Movies
|
|||||||
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
|
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString(), StringComparer.OrdinalIgnoreCase)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var result = GetRecommendationCategories(user, listEligibleForCategories, listEligibleForSuggestion, request.CategoryLimit, request.ItemLimit, request.GetItemFields().ToList());
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
|
dtoOptions.Fields = request.GetItemFields().ToList();
|
||||||
|
|
||||||
|
var result = GetRecommendationCategories(user, listEligibleForCategories, listEligibleForSuggestion, request.CategoryLimit, request.ItemLimit, dtoOptions);
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
@ -232,7 +236,7 @@ namespace MediaBrowser.Api.Movies
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, List<BaseItem> allMoviesForCategories, List<BaseItem> allMovies, int categoryLimit, int itemLimit, List<ItemFields> fields)
|
private IEnumerable<RecommendationDto> GetRecommendationCategories(User user, List<BaseItem> allMoviesForCategories, List<BaseItem> allMovies, int categoryLimit, int itemLimit, DtoOptions dtoOptions)
|
||||||
{
|
{
|
||||||
var categories = new List<RecommendationDto>();
|
var categories = new List<RecommendationDto>();
|
||||||
|
|
||||||
@ -282,11 +286,11 @@ namespace MediaBrowser.Api.Movies
|
|||||||
.OrderBy(i => Guid.NewGuid())
|
.OrderBy(i => Guid.NewGuid())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var similarToRecentlyPlayed = GetSimilarTo(user, allMovies, recentlyPlayedMovies.Take(7).OrderBy(i => Guid.NewGuid()), itemLimit, fields, RecommendationType.SimilarToRecentlyPlayed).GetEnumerator();
|
var similarToRecentlyPlayed = GetSimilarTo(user, allMovies, recentlyPlayedMovies.Take(7).OrderBy(i => Guid.NewGuid()), itemLimit, dtoOptions, RecommendationType.SimilarToRecentlyPlayed).GetEnumerator();
|
||||||
var similarToLiked = GetSimilarTo(user, allMovies, likedMovies, itemLimit, fields, RecommendationType.SimilarToLikedItem).GetEnumerator();
|
var similarToLiked = GetSimilarTo(user, allMovies, likedMovies, itemLimit, dtoOptions, RecommendationType.SimilarToLikedItem).GetEnumerator();
|
||||||
|
|
||||||
var hasDirectorFromRecentlyPlayed = GetWithDirector(user, allMovies, recentDirectors, itemLimit, fields, RecommendationType.HasDirectorFromRecentlyPlayed).GetEnumerator();
|
var hasDirectorFromRecentlyPlayed = GetWithDirector(user, allMovies, recentDirectors, itemLimit, dtoOptions, RecommendationType.HasDirectorFromRecentlyPlayed).GetEnumerator();
|
||||||
var hasActorFromRecentlyPlayed = GetWithActor(user, allMovies, recentActors, itemLimit, fields, RecommendationType.HasActorFromRecentlyPlayed).GetEnumerator();
|
var hasActorFromRecentlyPlayed = GetWithActor(user, allMovies, recentActors, itemLimit, dtoOptions, RecommendationType.HasActorFromRecentlyPlayed).GetEnumerator();
|
||||||
|
|
||||||
var categoryTypes = new List<IEnumerator<RecommendationDto>>
|
var categoryTypes = new List<IEnumerator<RecommendationDto>>
|
||||||
{
|
{
|
||||||
@ -329,7 +333,7 @@ namespace MediaBrowser.Api.Movies
|
|||||||
return categories.OrderBy(i => i.RecommendationType).ThenBy(i => Guid.NewGuid());
|
return categories.OrderBy(i => i.RecommendationType).ThenBy(i => Guid.NewGuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<RecommendationDto> GetWithDirector(User user, List<BaseItem> allMovies, IEnumerable<string> directors, int itemLimit, List<ItemFields> fields, RecommendationType type)
|
private IEnumerable<RecommendationDto> GetWithDirector(User user, List<BaseItem> allMovies, IEnumerable<string> directors, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
|
||||||
{
|
{
|
||||||
var userId = user.Id;
|
var userId = user.Id;
|
||||||
|
|
||||||
@ -347,13 +351,13 @@ namespace MediaBrowser.Api.Movies
|
|||||||
BaselineItemName = director,
|
BaselineItemName = director,
|
||||||
CategoryId = director.GetMD5().ToString("N"),
|
CategoryId = director.GetMD5().ToString("N"),
|
||||||
RecommendationType = type,
|
RecommendationType = type,
|
||||||
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray()
|
Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<RecommendationDto> GetWithActor(User user, List<BaseItem> allMovies, IEnumerable<string> names, int itemLimit, List<ItemFields> fields, RecommendationType type)
|
private IEnumerable<RecommendationDto> GetWithActor(User user, List<BaseItem> allMovies, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
|
||||||
{
|
{
|
||||||
var userId = user.Id;
|
var userId = user.Id;
|
||||||
|
|
||||||
@ -371,13 +375,13 @@ namespace MediaBrowser.Api.Movies
|
|||||||
BaselineItemName = name,
|
BaselineItemName = name,
|
||||||
CategoryId = name.GetMD5().ToString("N"),
|
CategoryId = name.GetMD5().ToString("N"),
|
||||||
RecommendationType = type,
|
RecommendationType = type,
|
||||||
Items = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray()
|
Items = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> allMovies, IEnumerable<BaseItem> baselineItems, int itemLimit, List<ItemFields> fields, RecommendationType type)
|
private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> allMovies, IEnumerable<BaseItem> baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
|
||||||
{
|
{
|
||||||
var userId = user.Id;
|
var userId = user.Id;
|
||||||
|
|
||||||
@ -395,7 +399,7 @@ namespace MediaBrowser.Api.Movies
|
|||||||
BaselineItemName = item.Name,
|
BaselineItemName = item.Name,
|
||||||
CategoryId = item.Id.ToString("N"),
|
CategoryId = item.Id.ToString("N"),
|
||||||
RecommendationType = type,
|
RecommendationType = type,
|
||||||
Items = similar.Select(i => _dtoService.GetBaseItemDto(i, fields, user)).ToArray()
|
Items = similar.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user)).ToArray()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ namespace MediaBrowser.Api
|
|||||||
Level = request.Level,
|
Level = request.Level,
|
||||||
Name = request.Name,
|
Name = request.Name,
|
||||||
Url = request.Url,
|
Url = request.Url,
|
||||||
UserIds = _userManager.Users.Where(i => i.Configuration.IsAdministrator).Select(i => i.Id.ToString("N")).ToList()
|
UserIds = _userManager.Users.Where(i => i.Policy.IsAdministrator).Select(i => i.Id.ToString("N")).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
await _notificationManager.SendNotification(notification, CancellationToken.None).ConfigureAwait(false);
|
await _notificationManager.SendNotification(notification, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
@ -118,7 +119,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
private string GetOutputFilePath(StreamState state)
|
private string GetOutputFilePath(StreamState state)
|
||||||
{
|
{
|
||||||
var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath;
|
var folder = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower());
|
||||||
|
|
||||||
var outputFileExtension = GetOutputFileExtension(state);
|
var outputFileExtension = GetOutputFileExtension(state);
|
||||||
|
|
||||||
@ -202,6 +203,10 @@ namespace MediaBrowser.Api.Playback
|
|||||||
{
|
{
|
||||||
args += " -map -0:s";
|
args += " -map -0:s";
|
||||||
}
|
}
|
||||||
|
else if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
|
||||||
|
{
|
||||||
|
args += " -map 1:0 -sn";
|
||||||
|
}
|
||||||
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@ -245,7 +250,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
|
|
||||||
protected EncodingQuality GetQualitySetting()
|
protected EncodingQuality GetQualitySetting()
|
||||||
{
|
{
|
||||||
var quality = ServerConfigurationManager.Configuration.MediaEncodingQuality;
|
var quality = ApiEntryPoint.Instance.GetEncodingOptions().EncodingQuality;
|
||||||
|
|
||||||
if (quality == EncodingQuality.Auto)
|
if (quality == EncodingQuality.Auto)
|
||||||
{
|
{
|
||||||
@ -302,6 +307,21 @@ namespace MediaBrowser.Api.Playback
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected string H264Encoder
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var lib = ApiEntryPoint.Instance.GetEncodingOptions().H264Encoder;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(lib))
|
||||||
|
{
|
||||||
|
return lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "libx264";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the video bitrate to specify on the command line
|
/// Gets the video bitrate to specify on the command line
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -318,7 +338,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
|
|
||||||
var qualitySetting = GetQualitySetting();
|
var qualitySetting = GetQualitySetting();
|
||||||
|
|
||||||
if (string.Equals(videoCodec, "libx264", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(videoCodec, H264Encoder, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
switch (qualitySetting)
|
switch (qualitySetting)
|
||||||
{
|
{
|
||||||
@ -442,7 +462,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
{
|
{
|
||||||
if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5)
|
if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5)
|
||||||
{
|
{
|
||||||
volParam = ",volume=" + ServerConfigurationManager.Configuration.DownMixAudioBoost.ToString(UsCulture);
|
volParam = ",volume=" + ApiEntryPoint.Instance.GetEncodingOptions().DownMixAudioBoost.ToString(UsCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,9 +671,18 @@ namespace MediaBrowser.Api.Playback
|
|||||||
videoSizeParam = string.Format(",scale={0}:{1}", state.VideoStream.Width.Value.ToString(UsCulture), state.VideoStream.Height.Value.ToString(UsCulture));
|
videoSizeParam = string.Format(",scale={0}:{1}", state.VideoStream.Width.Value.ToString(UsCulture), state.VideoStream.Height.Value.ToString(UsCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Format(" -filter_complex \"[0:{0}]format=yuva444p{3},lut=u=128:v=128:y=gammaval(.3)[sub] ; [0:{1}] [sub] overlay{2}\"",
|
var mapPrefix = state.SubtitleStream.IsExternal ?
|
||||||
state.SubtitleStream.Index,
|
1 :
|
||||||
state.VideoStream.Index,
|
0;
|
||||||
|
|
||||||
|
var subtitleStreamIndex = state.SubtitleStream.IsExternal
|
||||||
|
? 0
|
||||||
|
: state.SubtitleStream.Index;
|
||||||
|
|
||||||
|
return string.Format(" -filter_complex \"[{0}:{1}]format=yuva444p{4},lut=u=128:v=128:y=gammaval(.3)[sub] ; [0:{2}] [sub] overlay{3}\"",
|
||||||
|
mapPrefix.ToString(UsCulture),
|
||||||
|
subtitleStreamIndex.ToString(UsCulture),
|
||||||
|
state.VideoStream.Index.ToString(UsCulture),
|
||||||
outputSizeParam,
|
outputSizeParam,
|
||||||
videoSizeParam);
|
videoSizeParam);
|
||||||
}
|
}
|
||||||
@ -700,7 +729,8 @@ namespace MediaBrowser.Api.Playback
|
|||||||
return Math.Min(request.MaxAudioChannels.Value, audioStream.Channels.Value);
|
return Math.Min(request.MaxAudioChannels.Value, audioStream.Channels.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.MaxAudioChannels.Value;
|
// If we don't have any media info then limit it to 5 to prevent encoding errors due to asking for too many channels
|
||||||
|
return Math.Min(request.MaxAudioChannels.Value, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.AudioChannels;
|
return request.AudioChannels;
|
||||||
@ -761,7 +791,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
{
|
{
|
||||||
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return "libx264";
|
return H264Encoder;
|
||||||
}
|
}
|
||||||
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
|
if (string.Equals(codec, "vpx", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
@ -797,6 +827,21 @@ namespace MediaBrowser.Api.Playback
|
|||||||
/// <param name="state">The state.</param>
|
/// <param name="state">The state.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
protected string GetInputArgument(string transcodingJobId, StreamState state)
|
protected string GetInputArgument(string transcodingJobId, StreamState state)
|
||||||
|
{
|
||||||
|
var arg = "-i " + GetInputPathArgument(transcodingJobId, state);
|
||||||
|
|
||||||
|
if (state.SubtitleStream != null)
|
||||||
|
{
|
||||||
|
if (state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
|
||||||
|
{
|
||||||
|
arg += " -i \"" + state.SubtitleStream.Path + "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetInputPathArgument(string transcodingJobId, StreamState state)
|
||||||
{
|
{
|
||||||
if (state.InputProtocol == MediaProtocol.File &&
|
if (state.InputProtocol == MediaProtocol.File &&
|
||||||
state.RunTimeTicks.HasValue &&
|
state.RunTimeTicks.HasValue &&
|
||||||
@ -910,7 +955,7 @@ namespace MediaBrowser.Api.Playback
|
|||||||
var transcodingId = Guid.NewGuid().ToString("N");
|
var transcodingId = Guid.NewGuid().ToString("N");
|
||||||
var commandLineArgs = GetCommandLineArguments(outputPath, transcodingId, state, true);
|
var commandLineArgs = GetCommandLineArguments(outputPath, transcodingId, state, true);
|
||||||
|
|
||||||
if (ServerConfigurationManager.Configuration.EnableDebugEncodingLogging)
|
if (ApiEntryPoint.Instance.GetEncodingOptions().EnableDebugLogging)
|
||||||
{
|
{
|
||||||
commandLineArgs = "-loglevel debug " + commandLineArgs;
|
commandLineArgs = "-loglevel debug " + commandLineArgs;
|
||||||
}
|
}
|
||||||
@ -1562,9 +1607,6 @@ namespace MediaBrowser.Api.Playback
|
|||||||
mediaStreams = new List<MediaStream>();
|
mediaStreams = new List<MediaStream>();
|
||||||
|
|
||||||
state.DeInterlace = true;
|
state.DeInterlace = true;
|
||||||
state.OutputAudioSync = "1000";
|
|
||||||
state.InputVideoSync = "-1";
|
|
||||||
state.InputAudioSync = "1";
|
|
||||||
|
|
||||||
// Just to prevent this from being null and causing other methods to fail
|
// Just to prevent this from being null and causing other methods to fail
|
||||||
state.MediaPath = string.Empty;
|
state.MediaPath = string.Empty;
|
||||||
@ -1696,6 +1738,13 @@ namespace MediaBrowser.Api.Playback
|
|||||||
state.InputFileSize = mediaSource.Size;
|
state.InputFileSize = mediaSource.Size;
|
||||||
state.ReadInputAtNativeFramerate = mediaSource.ReadAtNativeFramerate;
|
state.ReadInputAtNativeFramerate = mediaSource.ReadAtNativeFramerate;
|
||||||
|
|
||||||
|
if (state.ReadInputAtNativeFramerate)
|
||||||
|
{
|
||||||
|
state.OutputAudioSync = "1000";
|
||||||
|
state.InputVideoSync = "-1";
|
||||||
|
state.InputAudioSync = "1";
|
||||||
|
}
|
||||||
|
|
||||||
AttachMediaStreamInfo(state, mediaSource.MediaStreams, videoRequest, requestedUrl);
|
AttachMediaStreamInfo(state, mediaSource.MediaStreams, videoRequest, requestedUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.Extensions;
|
||||||
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
@ -6,7 +7,6 @@ using MediaBrowser.Controller.Dlna;
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
using MediaBrowser.Model.Configuration;
|
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -14,6 +14,7 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback.Hls
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
@ -119,11 +120,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
if (isLive)
|
if (isLive)
|
||||||
{
|
{
|
||||||
//var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
return ResultFactory.GetResult(GetLivePlaylistText(playlist, state.SegmentLength), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||||
|
|
||||||
//file = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, file);
|
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, playlist, FileShare.ReadWrite);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var audioBitrate = state.OutputAudioBitrate ?? 0;
|
var audioBitrate = state.OutputAudioBitrate ?? 0;
|
||||||
@ -144,6 +141,22 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetLivePlaylistText(string path, int segmentLength)
|
||||||
|
{
|
||||||
|
using (var stream = FileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
using (var reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
var text = reader.ReadToEnd();
|
||||||
|
|
||||||
|
var newDuration = "#EXT-X-TARGETDURATION:" + segmentLength.ToString(UsCulture) + Environment.NewLine + "#EXT-X-ALLOW-CACHE:NO";
|
||||||
|
|
||||||
|
// ffmpeg pads the reported length by a full second
|
||||||
|
return text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength + 1).ToString(UsCulture), newDuration, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private string GetMasterPlaylistFileText(string firstPlaylist, int bitrate, bool includeBaselineStream, int baselineStreamBitrate)
|
private string GetMasterPlaylistFileText(string firstPlaylist, int bitrate, bool includeBaselineStream, int baselineStreamBitrate)
|
||||||
{
|
{
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
@ -227,7 +240,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
"hls/" + Path.GetFileNameWithoutExtension(outputPath));
|
"hls/" + Path.GetFileNameWithoutExtension(outputPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = string.Format("{0} {1} -i {2} -map_metadata -1 -threads {3} {4} {5} -sc_threshold 0 {6} -hls_time {7} -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
|
var args = string.Format("{0} {1} {2} -map_metadata -1 -threads {3} {4} {5} -sc_threshold 0 {6} -hls_time {7} -start_number {8} -hls_list_size {9}{10} -y \"{11}\"",
|
||||||
itsOffset,
|
itsOffset,
|
||||||
inputModifier,
|
inputModifier,
|
||||||
GetInputArgument(transcodingJobId, state),
|
GetInputArgument(transcodingJobId, state),
|
||||||
|
@ -20,6 +20,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback.Hls
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
@ -387,7 +388,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
playlistText = GetMasterPlaylistFileText(state, videoBitrate + audioBitrate);
|
playlistText = GetMasterPlaylistFileText(state, videoBitrate + audioBitrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetMasterPlaylistFileText(StreamState state, int totalBitrate)
|
private string GetMasterPlaylistFileText(StreamState state, int totalBitrate)
|
||||||
@ -603,7 +604,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
var playlistText = builder.ToString();
|
var playlistText = builder.ToString();
|
||||||
|
|
||||||
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetAudioArguments(StreamState state)
|
protected override string GetAudioArguments(StreamState state)
|
||||||
@ -640,10 +641,19 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var codec = state.OutputVideoCodec;
|
var codec = state.OutputVideoCodec;
|
||||||
|
|
||||||
// See if we can save come cpu cycles by avoiding encoding
|
var args = "-codec:v:0 " + codec;
|
||||||
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
|
|
||||||
|
if (state.EnableMpegtsM2TsMode)
|
||||||
{
|
{
|
||||||
return state.VideoStream != null && IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
|
args += " -mpegts_m2ts_mode 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// See if we can save come cpu cycles by avoiding encoding
|
||||||
|
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return state.VideoStream != null && IsH264(state.VideoStream) ?
|
||||||
|
args + " -bsf:v h264_mp4toannexb" :
|
||||||
|
args;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||||
@ -651,7 +661,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||||
|
|
||||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, "libx264", true) + keyFrameArg;
|
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||||
|
|
||||||
// Add resolution params, if specified
|
// Add resolution params, if specified
|
||||||
if (!hasGraphicalSubs)
|
if (!hasGraphicalSubs)
|
||||||
@ -677,7 +687,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
// If isEncoding is true we're actually starting ffmpeg
|
// If isEncoding is true we're actually starting ffmpeg
|
||||||
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0";
|
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0";
|
||||||
|
|
||||||
var args = string.Format("{0} -i {1} -map_metadata -1 -threads {2} {3} {4} -copyts -flags -global_header {5} -hls_time {6} -start_number {7} -hls_list_size {8} -y \"{9}\"",
|
var args = string.Format("{0} {1} -map_metadata -1 -threads {2} {3} {4} -copyts -flags -global_header {5} -hls_time {6} -start_number {7} -hls_list_size {8} -y \"{9}\"",
|
||||||
inputModifier,
|
inputModifier,
|
||||||
GetInputArgument(transcodingJobId, state),
|
GetInputArgument(transcodingJobId, state),
|
||||||
threads,
|
threads,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -65,7 +66,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower(), file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
@ -84,7 +85,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower(), file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ using System.Security;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback.Hls
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
@ -97,7 +98,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
playlistText = GetManifestText(state);
|
playlistText = GetManifestText(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.mpd"), new Dictionary<string, string>());
|
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.mpd"), new Dictionary<string, string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetManifestText(StreamState state)
|
private string GetManifestText(StreamState state)
|
||||||
@ -583,10 +584,19 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var codec = state.OutputVideoCodec;
|
var codec = state.OutputVideoCodec;
|
||||||
|
|
||||||
|
var args = "-codec:v:0 " + codec;
|
||||||
|
|
||||||
|
if (state.EnableMpegtsM2TsMode)
|
||||||
|
{
|
||||||
|
args += " -mpegts_m2ts_mode 1";
|
||||||
|
}
|
||||||
|
|
||||||
// See if we can save come cpu cycles by avoiding encoding
|
// See if we can save come cpu cycles by avoiding encoding
|
||||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
|
return state.VideoStream != null && IsH264(state.VideoStream) ?
|
||||||
|
args + " -bsf:v h264_mp4toannexb" :
|
||||||
|
args;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||||
@ -594,7 +604,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||||
|
|
||||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, "libx264", true) + keyFrameArg;
|
args+= " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||||
|
|
||||||
args += " -r 24 -g 24";
|
args += " -r 24 -g 24";
|
||||||
|
|
||||||
@ -627,7 +637,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
var segmentFilename = Path.GetFileNameWithoutExtension(outputPath) + "%03d" + GetSegmentFileExtension(state);
|
var segmentFilename = Path.GetFileNameWithoutExtension(outputPath) + "%03d" + GetSegmentFileExtension(state);
|
||||||
|
|
||||||
var args = string.Format("{0} -i {1} -map_metadata -1 -threads {2} {3} {4} -copyts {5} -f ssegment -segment_time {6} -segment_list_size {8} -segment_list \"{9}\" {10}",
|
var args = string.Format("{0} {1} -map_metadata -1 -threads {2} {3} {4} -copyts {5} -f ssegment -segment_time {6} -segment_list_size {8} -segment_list \"{9}\" {10}",
|
||||||
inputModifier,
|
inputModifier,
|
||||||
GetInputArgument(transcodingJobId, state),
|
GetInputArgument(transcodingJobId, state),
|
||||||
threads,
|
threads,
|
||||||
|
@ -5,12 +5,11 @@ using MediaBrowser.Controller.Dlna;
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback.Hls
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
@ -72,7 +71,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, file);
|
file = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, EncodingContext.Streaming.ToString().ToLower(), file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file);
|
return ResultFactory.GetStaticFileResult(Request, file);
|
||||||
}
|
}
|
||||||
@ -136,10 +135,19 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
var codec = state.OutputVideoCodec;
|
var codec = state.OutputVideoCodec;
|
||||||
|
|
||||||
|
var args = "-codec:v:0 " + codec;
|
||||||
|
|
||||||
|
if (state.EnableMpegtsM2TsMode)
|
||||||
|
{
|
||||||
|
args += " -mpegts_m2ts_mode 1";
|
||||||
|
}
|
||||||
|
|
||||||
// See if we can save come cpu cycles by avoiding encoding
|
// See if we can save come cpu cycles by avoiding encoding
|
||||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return state.VideoStream != null && IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
|
return state.VideoStream != null && IsH264(state.VideoStream) ?
|
||||||
|
args + " -bsf:v h264_mp4toannexb" :
|
||||||
|
args;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||||
@ -147,7 +155,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||||
|
|
||||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, "libx264", true) + keyFrameArg;
|
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||||
|
|
||||||
// Add resolution params, if specified
|
// Add resolution params, if specified
|
||||||
if (!hasGraphicalSubs)
|
if (!hasGraphicalSubs)
|
||||||
|
@ -82,7 +82,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
|
|
||||||
var inputModifier = GetInputModifier(state);
|
var inputModifier = GetInputModifier(state);
|
||||||
|
|
||||||
return string.Format("{0} -i {1} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1 -y \"{5}\"",
|
return string.Format("{0} {1} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1 -y \"{5}\"",
|
||||||
inputModifier,
|
inputModifier,
|
||||||
GetInputArgument(transcodingJobId, state),
|
GetInputArgument(transcodingJobId, state),
|
||||||
threads,
|
threads,
|
||||||
|
@ -103,7 +103,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
|
|
||||||
var inputModifier = GetInputModifier(state);
|
var inputModifier = GetInputModifier(state);
|
||||||
|
|
||||||
return string.Format("{0} -i {1}{2} {3} {4} -map_metadata -1 -threads {5} {6}{7} -y \"{8}\"",
|
return string.Format("{0} {1}{2} {3} {4} -map_metadata -1 -threads {5} {6}{7} -y \"{8}\"",
|
||||||
inputModifier,
|
inputModifier,
|
||||||
GetInputArgument(transcodingJobId, state),
|
GetInputArgument(transcodingJobId, state),
|
||||||
keyFrame,
|
keyFrame,
|
||||||
@ -124,7 +124,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
private string GetVideoArguments(StreamState state, string codec)
|
private string GetVideoArguments(StreamState state, string codec)
|
||||||
{
|
{
|
||||||
var args = "-vcodec " + codec;
|
var args = "-codec:v:0 " + codec;
|
||||||
|
|
||||||
if (state.EnableMpegtsM2TsMode)
|
if (state.EnableMpegtsM2TsMode)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,9 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
// See if we can save come cpu cycles by avoiding encoding
|
// See if we can save come cpu cycles by avoiding encoding
|
||||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return state.VideoStream != null && IsH264(state.VideoStream) ? args + " -bsf:v h264_mp4toannexb" : args;
|
return state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) ?
|
||||||
|
args + " -bsf:v h264_mp4toannexb" :
|
||||||
|
args;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||||
@ -182,13 +184,13 @@ namespace MediaBrowser.Api.Playback.Progressive
|
|||||||
// Get the output codec name
|
// Get the output codec name
|
||||||
var codec = state.OutputAudioCodec;
|
var codec = state.OutputAudioCodec;
|
||||||
|
|
||||||
|
var args = "-codec:a:0 " + codec;
|
||||||
|
|
||||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return "-acodec copy";
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
var args = "-acodec " + codec;
|
|
||||||
|
|
||||||
// Add the number of audio channels
|
// Add the number of audio channels
|
||||||
var channels = state.OutputAudioChannels;
|
var channels = state.OutputAudioChannels;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback
|
namespace MediaBrowser.Api.Playback
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Common.ScheduledTasks;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Tasks;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Session;
|
using MediaBrowser.Model.Session;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Devices;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Controller.Security;
|
using MediaBrowser.Controller.Security;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
@ -299,6 +300,7 @@ namespace MediaBrowser.Api.Session
|
|||||||
private readonly IUserManager _userManager;
|
private readonly IUserManager _userManager;
|
||||||
private readonly IAuthorizationContext _authContext;
|
private readonly IAuthorizationContext _authContext;
|
||||||
private readonly IAuthenticationRepository _authRepo;
|
private readonly IAuthenticationRepository _authRepo;
|
||||||
|
private readonly IDeviceManager _deviceManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SessionsService" /> class.
|
/// Initializes a new instance of the <see cref="SessionsService" /> class.
|
||||||
@ -307,12 +309,13 @@ namespace MediaBrowser.Api.Session
|
|||||||
/// <param name="userManager">The user manager.</param>
|
/// <param name="userManager">The user manager.</param>
|
||||||
/// <param name="authContext">The authentication context.</param>
|
/// <param name="authContext">The authentication context.</param>
|
||||||
/// <param name="authRepo">The authentication repo.</param>
|
/// <param name="authRepo">The authentication repo.</param>
|
||||||
public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo)
|
public SessionsService(ISessionManager sessionManager, IUserManager userManager, IAuthorizationContext authContext, IAuthenticationRepository authRepo, IDeviceManager deviceManager)
|
||||||
{
|
{
|
||||||
_sessionManager = sessionManager;
|
_sessionManager = sessionManager;
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_authContext = authContext;
|
_authContext = authContext;
|
||||||
_authRepo = authRepo;
|
_authRepo = authRepo;
|
||||||
|
_deviceManager = deviceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(RevokeKey request)
|
public void Delete(RevokeKey request)
|
||||||
@ -373,15 +376,30 @@ namespace MediaBrowser.Api.Session
|
|||||||
|
|
||||||
var user = _userManager.GetUserById(request.ControllableByUserId.Value);
|
var user = _userManager.GetUserById(request.ControllableByUserId.Value);
|
||||||
|
|
||||||
if (!user.Configuration.EnableRemoteControlOfOtherUsers)
|
if (!user.Policy.EnableRemoteControlOfOtherUsers)
|
||||||
{
|
{
|
||||||
result = result.Where(i => i.ContainsUser(request.ControllableByUserId.Value));
|
result = result.Where(i => i.ContainsUser(request.ControllableByUserId.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user.Configuration.EnableSharedDeviceControl)
|
if (!user.Policy.EnableSharedDeviceControl)
|
||||||
{
|
{
|
||||||
result = result.Where(i => !i.UserId.HasValue);
|
result = result.Where(i => !i.UserId.HasValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = result.Where(i =>
|
||||||
|
{
|
||||||
|
var deviceId = i.DeviceId;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(deviceId))
|
||||||
|
{
|
||||||
|
if (!_deviceManager.CanAccessDevice(user.Id.ToString("N"), deviceId))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList());
|
return ToOptimizedResult(result.Select(_sessionManager.GetSessionInfoDto).ToList());
|
||||||
|
@ -15,6 +15,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Subtitles
|
namespace MediaBrowser.Api.Subtitles
|
||||||
{
|
{
|
||||||
@ -175,7 +176,7 @@ namespace MediaBrowser.Api.Subtitles
|
|||||||
|
|
||||||
builder.AppendLine("#EXT-X-ENDLIST");
|
builder.AppendLine("#EXT-X-ENDLIST");
|
||||||
|
|
||||||
return ResultFactory.GetResult(builder.ToString(), Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
return ResultFactory.GetResult(builder.ToString(), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetSubtitle request)
|
public object Get(GetSubtitle request)
|
||||||
@ -199,7 +200,7 @@ namespace MediaBrowser.Api.Subtitles
|
|||||||
|
|
||||||
var stream = GetSubtitles(request).Result;
|
var stream = GetSubtitles(request).Result;
|
||||||
|
|
||||||
return ResultFactory.GetResult(stream, Common.Net.MimeTypes.GetMimeType("file." + request.Format));
|
return ResultFactory.GetResult(stream, MimeTypes.GetMimeType("file." + request.Format));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Stream> GetSubtitles(GetSubtitle request)
|
private async Task<Stream> GetSubtitles(GetSubtitle request)
|
||||||
@ -240,7 +241,7 @@ namespace MediaBrowser.Api.Subtitles
|
|||||||
{
|
{
|
||||||
var result = _subtitleManager.GetRemoteSubtitles(request.Id, CancellationToken.None).Result;
|
var result = _subtitleManager.GetRemoteSubtitles(request.Id, CancellationToken.None).Result;
|
||||||
|
|
||||||
return ResultFactory.GetResult(result.Stream, Common.Net.MimeTypes.GetMimeType("file." + result.Format));
|
return ResultFactory.GetResult(result.Stream, MimeTypes.GetMimeType("file." + result.Format));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post(DownloadRemoteSubtitles request)
|
public void Post(DownloadRemoteSubtitles request)
|
||||||
|
@ -5,6 +5,7 @@ using MediaBrowser.Controller.Sync;
|
|||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using MediaBrowser.Model.Sync;
|
using MediaBrowser.Model.Sync;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -27,6 +28,11 @@ namespace MediaBrowser.Api.Sync
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("/Sync/Jobs/{Id}", "POST", Summary = "Updates a sync job.")]
|
||||||
|
public class UpdateSyncJob : SyncJob, IReturnVoid
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[Route("/Sync/JobItems", "GET", Summary = "Gets sync job items.")]
|
[Route("/Sync/JobItems", "GET", Summary = "Gets sync job items.")]
|
||||||
public class GetSyncJobItems : SyncJobItemQuery, IReturn<QueryResult<SyncJobItem>>
|
public class GetSyncJobItems : SyncJobItemQuery, IReturn<QueryResult<SyncJobItem>>
|
||||||
{
|
{
|
||||||
@ -55,8 +61,14 @@ namespace MediaBrowser.Api.Sync
|
|||||||
[ApiMember(Name = "UserId", Description = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "UserId", Description = "UserId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string UserId { get; set; }
|
public string UserId { get; set; }
|
||||||
|
|
||||||
[ApiMember(Name = "ItemIds", Description = "ItemIds", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "ItemIds", Description = "ItemIds", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
public string ItemIds { get; set; }
|
public string ItemIds { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "ParentId", Description = "ParentId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
|
public string ParentId { get; set; }
|
||||||
|
|
||||||
|
[ApiMember(Name = "Category", Description = "Category", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
|
public SyncCategory? Category { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Route("/Sync/JobItems/{Id}/Transferred", "POST", Summary = "Reports that a sync job item has successfully been transferred.")]
|
[Route("/Sync/JobItems/{Id}/Transferred", "POST", Summary = "Reports that a sync job item has successfully been transferred.")]
|
||||||
@ -73,6 +85,23 @@ namespace MediaBrowser.Api.Sync
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("/Sync/OfflineActions", "POST", Summary = "Reports an action that occurred while offline.")]
|
||||||
|
public class ReportOfflineActions : List<UserAction>, IReturnVoid
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("/Sync/Items/Ready", "GET", Summary = "Gets ready to download sync items.")]
|
||||||
|
public class GetReadySyncItems : IReturn<List<SyncedItem>>
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "TargetId", Description = "TargetId", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||||
|
public string TargetId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Route("/Sync/Data", "POST", Summary = "Syncs data between device and server")]
|
||||||
|
public class SyncData : SyncDataRequest, IReturn<SyncDataResponse>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
[Authenticated]
|
[Authenticated]
|
||||||
public class SyncService : BaseApiService
|
public class SyncService : BaseApiService
|
||||||
{
|
{
|
||||||
@ -94,9 +123,9 @@ namespace MediaBrowser.Api.Sync
|
|||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetSyncJobs request)
|
public async Task<object> Get(GetSyncJobs request)
|
||||||
{
|
{
|
||||||
var result = _syncManager.GetJobs(request);
|
var result = await _syncManager.GetJobs(request).ConfigureAwait(false);
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
@ -155,21 +184,64 @@ namespace MediaBrowser.Api.Sync
|
|||||||
result.Targets = _syncManager.GetSyncTargets(request.UserId)
|
result.Targets = _syncManager.GetSyncTargets(request.UserId)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var dtos = request.ItemIds.Split(',')
|
if (request.Category.HasValue)
|
||||||
.Select(_libraryManager.GetItemById)
|
{
|
||||||
.Where(i => i != null)
|
result.Options = SyncHelper.GetSyncOptions(request.Category.Value);
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dtoOptions = new DtoOptions
|
||||||
{
|
{
|
||||||
Fields = new List<ItemFields>
|
Fields = new List<ItemFields>
|
||||||
{
|
{
|
||||||
ItemFields.SyncInfo
|
ItemFields.SyncInfo
|
||||||
}
|
}
|
||||||
}))
|
};
|
||||||
.ToList();
|
|
||||||
|
|
||||||
result.Options = SyncHelper.GetSyncOptions(dtos);
|
var dtos = request.ItemIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(_libraryManager.GetItemById)
|
||||||
|
.Where(i => i != null)
|
||||||
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
result.Options = SyncHelper.GetSyncOptions(dtos);
|
||||||
|
}
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
return ToOptimizedResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Post(ReportOfflineActions request)
|
||||||
|
{
|
||||||
|
var task = PostAsync(request);
|
||||||
|
|
||||||
|
Task.WaitAll(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task PostAsync(ReportOfflineActions request)
|
||||||
|
{
|
||||||
|
foreach (var action in request)
|
||||||
|
{
|
||||||
|
await _syncManager.ReportOfflineAction(action).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Get(GetReadySyncItems request)
|
||||||
|
{
|
||||||
|
return ToOptimizedResult(_syncManager.GetReadySyncItems(request.TargetId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<object> Post(SyncData request)
|
||||||
|
{
|
||||||
|
var response = await _syncManager.SyncData(request).ConfigureAwait(false);
|
||||||
|
|
||||||
|
return ToOptimizedResult(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Post(UpdateSyncJob request)
|
||||||
|
{
|
||||||
|
var task = _syncManager.UpdateJob(request);
|
||||||
|
|
||||||
|
Task.WaitAll(task);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Controller.Activity;
|
||||||
using MediaBrowser.Controller.Activity;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Activity;
|
using MediaBrowser.Model.Activity;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.System;
|
using MediaBrowser.Model.System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -83,17 +83,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = GetArtist(request.Name, LibraryManager);
|
var item = GetArtist(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -69,17 +69,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = GetGameGenre(request.Name, LibraryManager);
|
var item = GetGameGenre(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -74,17 +74,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = GetGenre(request.Name, LibraryManager);
|
var item = GetGenre(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -69,17 +69,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = GetMusicGenre(request.Name, LibraryManager);
|
var item = GetMusicGenre(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -86,17 +86,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = GetPerson(request.Name, LibraryManager);
|
var item = GetPerson(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -73,17 +73,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = GetStudio(request.Name, LibraryManager);
|
var item = GetStudio(request.Name, LibraryManager);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -407,9 +407,6 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var user = _userManager.GetUserById(request.UserId);
|
var user = _userManager.GetUserById(request.UserId);
|
||||||
|
|
||||||
// Get everything
|
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
||||||
|
|
||||||
var query = new UserViewQuery
|
var query = new UserViewQuery
|
||||||
{
|
{
|
||||||
UserId = request.UserId
|
UserId = request.UserId
|
||||||
@ -423,7 +420,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
|
|
||||||
var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);
|
var folders = await _userViewManager.GetUserViews(query, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
|
var dtos = folders.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var result = new QueryResult<BaseItemDto>
|
var result = new QueryResult<BaseItemDto>
|
||||||
@ -443,14 +442,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
user.RootFolder :
|
user.RootFolder :
|
||||||
_libraryManager.GetItemById(request.Id);
|
_libraryManager.GetItemById(request.Id);
|
||||||
|
|
||||||
// Get everything
|
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
||||||
|
|
||||||
var series = item as Series;
|
var series = item as Series;
|
||||||
|
|
||||||
// Get them from the child tree
|
// Get them from the child tree
|
||||||
if (series != null)
|
if (series != null)
|
||||||
{
|
{
|
||||||
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
|
// Avoid implicitly captured closure
|
||||||
|
var currentUser = user;
|
||||||
|
|
||||||
var dtos = series
|
var dtos = series
|
||||||
.GetRecursiveChildren()
|
.GetRecursiveChildren()
|
||||||
.Where(i => i is Episode && i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
|
.Where(i => i is Episode && i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == 0)
|
||||||
@ -468,7 +469,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
return DateTime.MinValue;
|
return DateTime.MinValue;
|
||||||
})
|
})
|
||||||
.ThenBy(i => i.SortName)
|
.ThenBy(i => i.SortName)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, currentUser));
|
||||||
|
|
||||||
return dtos.ToList();
|
return dtos.ToList();
|
||||||
}
|
}
|
||||||
@ -478,10 +479,12 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
// Get them from the db
|
// Get them from the db
|
||||||
if (movie != null)
|
if (movie != null)
|
||||||
{
|
{
|
||||||
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
var dtos = movie.SpecialFeatureIds
|
var dtos = movie.SpecialFeatureIds
|
||||||
.Select(_libraryManager.GetItemById)
|
.Select(_libraryManager.GetItemById)
|
||||||
.OrderBy(i => i.SortName)
|
.OrderBy(i => i.SortName)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
|
||||||
|
|
||||||
return dtos.ToList();
|
return dtos.ToList();
|
||||||
}
|
}
|
||||||
@ -507,9 +510,6 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
|
|
||||||
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id);
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id);
|
||||||
|
|
||||||
// Get everything
|
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
||||||
|
|
||||||
var trailerIds = new List<Guid>();
|
var trailerIds = new List<Guid>();
|
||||||
|
|
||||||
var hasTrailers = item as IHasTrailers;
|
var hasTrailers = item as IHasTrailers;
|
||||||
@ -518,10 +518,12 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
trailerIds = hasTrailers.GetTrailerIds();
|
trailerIds = hasTrailers.GetTrailerIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dtoOptions = new DtoOptions();
|
||||||
|
|
||||||
var dtos = trailerIds
|
var dtos = trailerIds
|
||||||
.Select(_libraryManager.GetItemById)
|
.Select(_libraryManager.GetItemById)
|
||||||
.OrderBy(i => i.SortName)
|
.OrderBy(i => i.SortName)
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item));
|
||||||
|
|
||||||
return dtos.ToList();
|
return dtos.ToList();
|
||||||
}
|
}
|
||||||
@ -537,10 +539,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
|
|
||||||
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id);
|
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _libraryManager.GetItemById(request.Id);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
||||||
|
|
||||||
var result = _dtoService.GetBaseItemDto(item, fields, user);
|
var result = _dtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
|
|
||||||
return ToOptimizedSerializedResultUsingCache(result);
|
return ToOptimizedSerializedResultUsingCache(result);
|
||||||
}
|
}
|
||||||
@ -556,10 +557,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
|
|
||||||
var item = user.RootFolder;
|
var item = user.RootFolder;
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
|
|
||||||
|
|
||||||
var result = _dtoService.GetBaseItemDto(item, fields, user);
|
var result = _dtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
|
|
||||||
return ToOptimizedSerializedResultUsingCache(result);
|
return ToOptimizedSerializedResultUsingCache(result);
|
||||||
}
|
}
|
||||||
@ -577,12 +577,9 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
|
|
||||||
var items = await _libraryManager.GetIntros(item, user).ConfigureAwait(false);
|
var items = await _libraryManager.GetIntros(item, user).ConfigureAwait(false);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var dtos = items.Select(i => _dtoService.GetBaseItemDto(i, fields, user))
|
var dtos = items.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var result = new ItemsResult
|
var result = new ItemsResult
|
||||||
|
@ -73,17 +73,16 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
var item = LibraryManager.GetYear(request.Year);
|
var item = LibraryManager.GetYear(request.Year);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
|
|
||||||
|
|
||||||
if (request.UserId.HasValue)
|
if (request.UserId.HasValue)
|
||||||
{
|
{
|
||||||
var user = UserManager.GetUserById(request.UserId.Value);
|
var user = UserManager.GetUserById(request.UserId.Value);
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList(), user);
|
return DtoService.GetBaseItemDto(item, dtoOptions, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoService.GetBaseItemDto(item, fields.ToList());
|
return DtoService.GetBaseItemDto(item, dtoOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Devices;
|
||||||
using MediaBrowser.Controller.Dto;
|
using MediaBrowser.Controller.Dto;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Controller.Session;
|
using MediaBrowser.Controller.Session;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Connect;
|
using MediaBrowser.Model.Connect;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Users;
|
using MediaBrowser.Model.Users;
|
||||||
@ -51,7 +53,7 @@ namespace MediaBrowser.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The id.</value>
|
/// <value>The id.</value>
|
||||||
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||||
public Guid Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -66,7 +68,7 @@ namespace MediaBrowser.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The id.</value>
|
/// <value>The id.</value>
|
||||||
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
||||||
public Guid Id { get; set; }
|
public string Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -80,7 +82,7 @@ namespace MediaBrowser.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The id.</value>
|
/// <value>The id.</value>
|
||||||
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||||
public Guid Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the password.
|
/// Gets or sets the password.
|
||||||
@ -125,7 +127,7 @@ namespace MediaBrowser.Api
|
|||||||
/// Gets or sets the id.
|
/// Gets or sets the id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The id.</value>
|
/// <value>The id.</value>
|
||||||
public Guid Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the password.
|
/// Gets or sets the password.
|
||||||
@ -155,6 +157,28 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class UpdateUser
|
||||||
|
/// </summary>
|
||||||
|
[Route("/Users/{Id}/Policy", "POST", Summary = "Updates a user policy")]
|
||||||
|
[Authenticated(Roles = "admin")]
|
||||||
|
public class UpdateUserPolicy : UserPolicy, IReturnVoid
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class UpdateUser
|
||||||
|
/// </summary>
|
||||||
|
[Route("/Users/{Id}/Configuration", "POST", Summary = "Updates a user configuration")]
|
||||||
|
[Authenticated]
|
||||||
|
public class UpdateUserConfiguration : UserConfiguration, IReturnVoid
|
||||||
|
{
|
||||||
|
[ApiMember(Name = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class CreateUser
|
/// Class CreateUser
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -193,22 +217,18 @@ namespace MediaBrowser.Api
|
|||||||
private readonly ISessionManager _sessionMananger;
|
private readonly ISessionManager _sessionMananger;
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly INetworkManager _networkManager;
|
private readonly INetworkManager _networkManager;
|
||||||
|
private readonly IDeviceManager _deviceManager;
|
||||||
|
|
||||||
public IAuthorizationContext AuthorizationContext { get; set; }
|
public IAuthorizationContext AuthorizationContext { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
public UserService(IUserManager userManager, IDtoService dtoService, ISessionManager sessionMananger, IServerConfigurationManager config, INetworkManager networkManager, IDeviceManager deviceManager)
|
||||||
/// Initializes a new instance of the <see cref="UserService" /> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="userManager">The user manager.</param>
|
|
||||||
/// <param name="dtoService">The dto service.</param>
|
|
||||||
/// <param name="sessionMananger">The session mananger.</param>
|
|
||||||
public UserService(IUserManager userManager, IDtoService dtoService, ISessionManager sessionMananger, IServerConfigurationManager config, INetworkManager networkManager)
|
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
_dtoService = dtoService;
|
_dtoService = dtoService;
|
||||||
_sessionMananger = sessionMananger;
|
_sessionMananger = sessionMananger;
|
||||||
_config = config;
|
_config = config;
|
||||||
_networkManager = networkManager;
|
_networkManager = networkManager;
|
||||||
|
_deviceManager = deviceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetPublicUsers request)
|
public object Get(GetPublicUsers request)
|
||||||
@ -222,18 +242,12 @@ namespace MediaBrowser.Api
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Uncomment once clients can handle an empty user list (and below)
|
return Get(new GetUsers
|
||||||
//if (Request.IsLocal || IsInLocalNetwork(Request.RemoteIp))
|
|
||||||
{
|
{
|
||||||
return Get(new GetUsers
|
IsHidden = false,
|
||||||
{
|
IsDisabled = false
|
||||||
IsHidden = false,
|
|
||||||
IsDisabled = false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//// Return empty when external
|
}, true);
|
||||||
//return ToOptimizedResult(new List<UserDto>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -242,25 +256,39 @@ namespace MediaBrowser.Api
|
|||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
public object Get(GetUsers request)
|
public object Get(GetUsers request)
|
||||||
|
{
|
||||||
|
return Get(request, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private object Get(GetUsers request, bool filterByDevice)
|
||||||
{
|
{
|
||||||
var users = _userManager.Users;
|
var users = _userManager.Users;
|
||||||
|
|
||||||
if (request.IsDisabled.HasValue)
|
if (request.IsDisabled.HasValue)
|
||||||
{
|
{
|
||||||
users = users.Where(i => i.Configuration.IsDisabled == request.IsDisabled.Value);
|
users = users.Where(i => i.Policy.IsDisabled == request.IsDisabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.IsHidden.HasValue)
|
if (request.IsHidden.HasValue)
|
||||||
{
|
{
|
||||||
users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value);
|
users = users.Where(i => i.Policy.IsHidden == request.IsHidden.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.IsGuest.HasValue)
|
if (request.IsGuest.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
users = users.Where(i => (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest) == request.IsGuest.Value);
|
users = users.Where(i => (i.ConnectLinkType.HasValue && i.ConnectLinkType.Value == UserLinkType.Guest) == request.IsGuest.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filterByDevice)
|
||||||
|
{
|
||||||
|
var deviceId = AuthorizationContext.GetAuthorizationInfo(Request).DeviceId;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(deviceId))
|
||||||
|
{
|
||||||
|
users = users.Where(i => _deviceManager.CanAccessDevice(i.Id.ToString("N"), deviceId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var result = users
|
var result = users
|
||||||
.OrderBy(u => u.Name)
|
.OrderBy(u => u.Name)
|
||||||
.Select(i => _userManager.GetUserDto(i, Request.RemoteIp))
|
.Select(i => _userManager.GetUserDto(i, Request.RemoteIp))
|
||||||
@ -428,39 +456,13 @@ namespace MediaBrowser.Api
|
|||||||
|
|
||||||
var user = _userManager.GetUserById(id);
|
var user = _userManager.GetUserById(id);
|
||||||
|
|
||||||
// If removing admin access
|
|
||||||
if (!dtoUser.Configuration.IsAdministrator && user.Configuration.IsAdministrator)
|
|
||||||
{
|
|
||||||
if (_userManager.Users.Count(i => i.Configuration.IsAdministrator) == 1)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("There must be at least one user in the system with administrative access.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If disabling
|
|
||||||
if (dtoUser.Configuration.IsDisabled && user.Configuration.IsAdministrator)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Administrators cannot be disabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// If disabling
|
|
||||||
if (dtoUser.Configuration.IsDisabled && !user.Configuration.IsDisabled)
|
|
||||||
{
|
|
||||||
if (_userManager.Users.Count(i => !i.Configuration.IsDisabled) == 1)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("There must be at least one enabled user in the system.");
|
|
||||||
}
|
|
||||||
|
|
||||||
await _sessionMananger.RevokeUserTokens(user.Id.ToString("N")).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var task = user.Name.Equals(dtoUser.Name, StringComparison.Ordinal) ?
|
var task = user.Name.Equals(dtoUser.Name, StringComparison.Ordinal) ?
|
||||||
_userManager.UpdateUser(user) :
|
_userManager.UpdateUser(user) :
|
||||||
_userManager.RenameUser(user, dtoUser.Name);
|
_userManager.RenameUser(user, dtoUser.Name);
|
||||||
|
|
||||||
await task.ConfigureAwait(false);
|
await task.ConfigureAwait(false);
|
||||||
|
|
||||||
user.UpdateConfiguration(dtoUser.Configuration);
|
await _userManager.UpdateConfiguration(dtoUser.Id, dtoUser.Configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -495,5 +497,51 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
return _userManager.RedeemPasswordResetPin(request.Pin);
|
return _userManager.RedeemPasswordResetPin(request.Pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Post(UpdateUserConfiguration request)
|
||||||
|
{
|
||||||
|
var task = _userManager.UpdateConfiguration(request.Id, request);
|
||||||
|
|
||||||
|
Task.WaitAll(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Post(UpdateUserPolicy request)
|
||||||
|
{
|
||||||
|
var task = UpdateUserPolicy(request);
|
||||||
|
Task.WaitAll(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateUserPolicy(UpdateUserPolicy request)
|
||||||
|
{
|
||||||
|
var user = _userManager.GetUserById(request.Id);
|
||||||
|
|
||||||
|
// If removing admin access
|
||||||
|
if (!request.IsAdministrator && user.Policy.IsAdministrator)
|
||||||
|
{
|
||||||
|
if (_userManager.Users.Count(i => i.Policy.IsAdministrator) == 1)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("There must be at least one user in the system with administrative access.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If disabling
|
||||||
|
if (request.IsDisabled && user.Policy.IsAdministrator)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Administrators cannot be disabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If disabling
|
||||||
|
if (request.IsDisabled && !user.Policy.IsDisabled)
|
||||||
|
{
|
||||||
|
if (_userManager.Users.Count(i => !i.Policy.IsDisabled) == 1)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("There must be at least one enabled user in the system.");
|
||||||
|
}
|
||||||
|
|
||||||
|
await _sessionMananger.RevokeUserTokens(user.Id.ToString("N")).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
await _userManager.UpdateUserPolicy(request.Id, request).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using MediaBrowser.Controller.Entities;
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using System;
|
using System;
|
||||||
@ -79,15 +80,12 @@ namespace MediaBrowser.Api
|
|||||||
: _libraryManager.RootFolder)
|
: _libraryManager.RootFolder)
|
||||||
: _libraryManager.GetItemById(request.Id);
|
: _libraryManager.GetItemById(request.Id);
|
||||||
|
|
||||||
// Get everything
|
var dtoOptions = new DtoOptions();
|
||||||
var fields = Enum.GetNames(typeof(ItemFields))
|
|
||||||
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
var video = (Video)item;
|
var video = (Video)item;
|
||||||
|
|
||||||
var items = video.GetAdditionalParts()
|
var items = video.GetAdditionalParts()
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, video))
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, video))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var result = new ItemsResult
|
var result = new ItemsResult
|
||||||
@ -114,11 +112,11 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
link.PrimaryVersionId = null;
|
link.PrimaryVersionId = null;
|
||||||
|
|
||||||
await link.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false);
|
await link.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
video.LinkedAlternateVersions.Clear();
|
video.LinkedAlternateVersions.Clear();
|
||||||
await video.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false);
|
await video.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Post(MergeVersions request)
|
public void Post(MergeVersions request)
|
||||||
@ -186,7 +184,7 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
item.PrimaryVersionId = primaryVersion.Id;
|
item.PrimaryVersionId = primaryVersion.Id;
|
||||||
|
|
||||||
await item.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false);
|
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
primaryVersion.LinkedAlternateVersions.Add(new LinkedChild
|
primaryVersion.LinkedAlternateVersions.Add(new LinkedChild
|
||||||
{
|
{
|
||||||
@ -195,7 +193,7 @@ namespace MediaBrowser.Api
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await primaryVersion.UpdateToRepository(ItemUpdateType.MetadataDownload, CancellationToken.None).ConfigureAwait(false);
|
await primaryVersion.UpdateToRepository(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,7 +466,7 @@ namespace MediaBrowser.Common.Implementations
|
|||||||
|
|
||||||
RegisterSingleInstance(FileSystemManager);
|
RegisterSingleInstance(FileSystemManager);
|
||||||
|
|
||||||
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, FileSystemManager, ConfigurationManager);
|
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, Logger, FileSystemManager);
|
||||||
RegisterSingleInstance(HttpClient);
|
RegisterSingleInstance(HttpClient);
|
||||||
|
|
||||||
NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
|
NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
|
||||||
|
@ -105,7 +105,7 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
|||||||
UpdateCachePath();
|
UpdateCachePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddParts(IEnumerable<IConfigurationFactory> factories)
|
public virtual void AddParts(IEnumerable<IConfigurationFactory> factories)
|
||||||
{
|
{
|
||||||
_configurationFactories = factories.ToArray();
|
_configurationFactories = factories.ToArray();
|
||||||
|
|
||||||
@ -208,20 +208,51 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
|||||||
|
|
||||||
lock (_configurationSyncLock)
|
lock (_configurationSyncLock)
|
||||||
{
|
{
|
||||||
return ConfigurationHelper.GetXmlConfiguration(configurationType, file, XmlSerializer);
|
return LoadConfiguration(file, configurationType);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object LoadConfiguration(string path, Type configurationType)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return XmlSerializer.DeserializeFromFile(configurationType, path);
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
return Activator.CreateInstance(configurationType);
|
||||||
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
return Activator.CreateInstance(configurationType);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error loading configuration file: {0}", ex, path);
|
||||||
|
|
||||||
|
return Activator.CreateInstance(configurationType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SaveConfiguration(string key, object configuration)
|
public void SaveConfiguration(string key, object configuration)
|
||||||
{
|
{
|
||||||
var configurationType = GetConfigurationType(key);
|
var configurationStore = GetConfigurationStore(key);
|
||||||
|
var configurationType = configurationStore.ConfigurationType;
|
||||||
|
|
||||||
if (configuration.GetType() != configurationType)
|
if (configuration.GetType() != configurationType)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Expected configuration type is " + configurationType.Name);
|
throw new ArgumentException("Expected configuration type is " + configurationType.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var validatingStore = configurationStore as IValidatingConfiguration;
|
||||||
|
if (validatingStore != null)
|
||||||
|
{
|
||||||
|
var currentConfiguration = GetConfiguration(key);
|
||||||
|
|
||||||
|
validatingStore.Validate(currentConfiguration, configuration);
|
||||||
|
}
|
||||||
|
|
||||||
EventHelper.FireEventIfNotNull(NamedConfigurationUpdating, this, new ConfigurationUpdateEventArgs
|
EventHelper.FireEventIfNotNull(NamedConfigurationUpdating, this, new ConfigurationUpdateEventArgs
|
||||||
{
|
{
|
||||||
Key = key,
|
Key = key,
|
||||||
@ -239,6 +270,11 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
|||||||
XmlSerializer.SerializeToFile(configuration, path);
|
XmlSerializer.SerializeToFile(configuration, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnNamedConfigurationUpdated(key, configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnNamedConfigurationUpdated(string key, object configuration)
|
||||||
|
{
|
||||||
EventHelper.FireEventIfNotNull(NamedConfigurationUpdated, this, new ConfigurationUpdateEventArgs
|
EventHelper.FireEventIfNotNull(NamedConfigurationUpdated, this, new ConfigurationUpdateEventArgs
|
||||||
{
|
{
|
||||||
Key = key,
|
Key = key,
|
||||||
@ -249,9 +285,14 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
|||||||
|
|
||||||
public Type GetConfigurationType(string key)
|
public Type GetConfigurationType(string key)
|
||||||
{
|
{
|
||||||
return _configurationStores
|
return GetConfigurationStore(key)
|
||||||
.First(i => string.Equals(i.Key, key, StringComparison.OrdinalIgnoreCase))
|
|
||||||
.ConfigurationType;
|
.ConfigurationType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ConfigurationStore GetConfigurationStore(string key)
|
||||||
|
{
|
||||||
|
return _configurationStores
|
||||||
|
.First(i => string.Equals(i.Key, key, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Configuration
|
namespace MediaBrowser.Common.Implementations.Configuration
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class ConfigurationHelper
|
/// Class ConfigurationHelper
|
||||||
@ -55,20 +55,5 @@ namespace MediaBrowser.Common.Configuration
|
|||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Reads an xml configuration file from the file system
|
|
||||||
/// It will immediately save the configuration after loading it, just
|
|
||||||
/// in case there are new serializable properties
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="xmlSerializer">The XML serializer.</param>
|
|
||||||
/// <returns>``0.</returns>
|
|
||||||
public static T GetXmlConfiguration<T>(string path, IXmlSerializer xmlSerializer)
|
|
||||||
where T : class
|
|
||||||
{
|
|
||||||
return GetXmlConfiguration(typeof(T), path, xmlSerializer) as T;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,7 +38,10 @@ namespace MediaBrowser.Common.Implementations.Devices
|
|||||||
_logger.Error("Invalid value found in device id file");
|
_logger.Error("Invalid value found in device id file");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex)
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -41,7 +41,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
private readonly IApplicationPaths _appPaths;
|
private readonly IApplicationPaths _appPaths;
|
||||||
|
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly IConfigurationManager _config;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HttpClientManager" /> class.
|
/// Initializes a new instance of the <see cref="HttpClientManager" /> class.
|
||||||
@ -52,7 +51,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
/// <exception cref="System.ArgumentNullException">appPaths
|
/// <exception cref="System.ArgumentNullException">appPaths
|
||||||
/// or
|
/// or
|
||||||
/// logger</exception>
|
/// logger</exception>
|
||||||
public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem, IConfigurationManager config)
|
public HttpClientManager(IApplicationPaths appPaths, ILogger logger, IFileSystem fileSystem)
|
||||||
{
|
{
|
||||||
if (appPaths == null)
|
if (appPaths == null)
|
||||||
{
|
{
|
||||||
@ -65,7 +64,6 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
|||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
_config = config;
|
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
|
// http://stackoverflow.com/questions/566437/http-post-returns-the-error-417-expectation-failed-c
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
<Compile Include="BaseApplicationHost.cs" />
|
<Compile Include="BaseApplicationHost.cs" />
|
||||||
<Compile Include="BaseApplicationPaths.cs" />
|
<Compile Include="BaseApplicationPaths.cs" />
|
||||||
<Compile Include="Configuration\BaseConfigurationManager.cs" />
|
<Compile Include="Configuration\BaseConfigurationManager.cs" />
|
||||||
|
<Compile Include="Configuration\ConfigurationHelper.cs" />
|
||||||
<Compile Include="Devices\DeviceId.cs" />
|
<Compile Include="Devices\DeviceId.cs" />
|
||||||
<Compile Include="HttpClientManager\HttpClientInfo.cs" />
|
<Compile Include="HttpClientManager\HttpClientInfo.cs" />
|
||||||
<Compile Include="HttpClientManager\HttpClientManager.cs" />
|
<Compile Include="HttpClientManager\HttpClientManager.cs" />
|
||||||
|
@ -101,6 +101,10 @@ namespace MediaBrowser.Common.Implementations.Security
|
|||||||
{
|
{
|
||||||
contents = File.ReadAllLines(licenseFile);
|
contents = File.ReadAllLines(licenseFile);
|
||||||
}
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
(File.Create(licenseFile)).Close();
|
||||||
|
}
|
||||||
catch (FileNotFoundException)
|
catch (FileNotFoundException)
|
||||||
{
|
{
|
||||||
(File.Create(licenseFile)).Close();
|
(File.Create(licenseFile)).Close();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
@ -10,6 +11,17 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class XmlSerializer : IXmlSerializer
|
public class XmlSerializer : IXmlSerializer
|
||||||
{
|
{
|
||||||
|
// Need to cache these
|
||||||
|
// http://dotnetcodebox.blogspot.com/2013/01/xmlserializer-class-may-result-in.html
|
||||||
|
private readonly ConcurrentDictionary<string, System.Xml.Serialization.XmlSerializer> _serializers =
|
||||||
|
new ConcurrentDictionary<string, System.Xml.Serialization.XmlSerializer>();
|
||||||
|
|
||||||
|
private System.Xml.Serialization.XmlSerializer GetSerializer(Type type)
|
||||||
|
{
|
||||||
|
var key = type.FullName;
|
||||||
|
return _serializers.GetOrAdd(key, k => new System.Xml.Serialization.XmlSerializer(type));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serializes to writer.
|
/// Serializes to writer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -18,7 +30,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
|||||||
private void SerializeToWriter(object obj, XmlTextWriter writer)
|
private void SerializeToWriter(object obj, XmlTextWriter writer)
|
||||||
{
|
{
|
||||||
writer.Formatting = Formatting.Indented;
|
writer.Formatting = Formatting.Indented;
|
||||||
var netSerializer = new System.Xml.Serialization.XmlSerializer(obj.GetType());
|
var netSerializer = GetSerializer(obj.GetType());
|
||||||
netSerializer.Serialize(writer, obj);
|
netSerializer.Serialize(writer, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,8 +44,7 @@ namespace MediaBrowser.Common.Implementations.Serialization
|
|||||||
{
|
{
|
||||||
using (var reader = new XmlTextReader(stream))
|
using (var reader = new XmlTextReader(stream))
|
||||||
{
|
{
|
||||||
var netSerializer = new System.Xml.Serialization.XmlSerializer(type);
|
var netSerializer = GetSerializer(type);
|
||||||
|
|
||||||
return netSerializer.Deserialize(reader);
|
return netSerializer.Deserialize(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="NLog" version="3.1.0.0" targetFramework="net45" />
|
<package id="NLog" version="3.1.0.0" targetFramework="net45" />
|
||||||
<package id="SharpCompress" version="0.10.2" targetFramework="net45" />
|
|
||||||
<package id="SimpleInjector" version="2.6.1" targetFramework="net45" />
|
<package id="SimpleInjector" version="2.6.1" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
||||||
|
@ -14,4 +14,9 @@ namespace MediaBrowser.Common.Configuration
|
|||||||
|
|
||||||
public Type ConfigurationType { get; set; }
|
public Type ConfigurationType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IValidatingConfiguration
|
||||||
|
{
|
||||||
|
void Validate(object oldConfig, object newConfig);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -54,6 +56,15 @@ namespace MediaBrowser.Common.Extensions
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string RemoveDiacritics(this string text)
|
||||||
|
{
|
||||||
|
return String.Concat(
|
||||||
|
text.Normalize(NormalizationForm.FormD)
|
||||||
|
.Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) !=
|
||||||
|
UnicodeCategory.NonSpacingMark)
|
||||||
|
).Normalize(NormalizationForm.FormC);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the M d5.
|
/// Gets the M d5.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
<Link>Properties\SharedVersion.cs</Link>
|
<Link>Properties\SharedVersion.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Configuration\ConfigurationHelper.cs" />
|
|
||||||
<Compile Include="Configuration\ConfigurationUpdateEventArgs.cs" />
|
<Compile Include="Configuration\ConfigurationUpdateEventArgs.cs" />
|
||||||
<Compile Include="Configuration\IConfigurationManager.cs" />
|
<Compile Include="Configuration\IConfigurationManager.cs" />
|
||||||
<Compile Include="Configuration\IConfigurationFactory.cs" />
|
<Compile Include="Configuration\IConfigurationFactory.cs" />
|
||||||
@ -64,19 +63,12 @@
|
|||||||
<Compile Include="IO\IFileSystem.cs" />
|
<Compile Include="IO\IFileSystem.cs" />
|
||||||
<Compile Include="IO\ProgressStream.cs" />
|
<Compile Include="IO\ProgressStream.cs" />
|
||||||
<Compile Include="IO\StreamDefaults.cs" />
|
<Compile Include="IO\StreamDefaults.cs" />
|
||||||
<Compile Include="Net\BasePeriodicWebSocketListener.cs" />
|
|
||||||
<Compile Include="Configuration\IApplicationPaths.cs" />
|
<Compile Include="Configuration\IApplicationPaths.cs" />
|
||||||
<Compile Include="Net\HttpRequestOptions.cs" />
|
<Compile Include="Net\HttpRequestOptions.cs" />
|
||||||
<Compile Include="Net\HttpResponseInfo.cs" />
|
<Compile Include="Net\HttpResponseInfo.cs" />
|
||||||
<Compile Include="Net\IWebSocketListener.cs" />
|
|
||||||
<Compile Include="IApplicationHost.cs" />
|
<Compile Include="IApplicationHost.cs" />
|
||||||
<Compile Include="Net\IHttpClient.cs" />
|
<Compile Include="Net\IHttpClient.cs" />
|
||||||
<Compile Include="Net\INetworkManager.cs" />
|
<Compile Include="Net\INetworkManager.cs" />
|
||||||
<Compile Include="Net\IWebSocket.cs" />
|
|
||||||
<Compile Include="Net\IWebSocketConnection.cs" />
|
|
||||||
<Compile Include="Net\MimeTypes.cs" />
|
|
||||||
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
|
|
||||||
<Compile Include="Net\WebSocketMessageInfo.cs" />
|
|
||||||
<Compile Include="Plugins\IDependencyModule.cs" />
|
<Compile Include="Plugins\IDependencyModule.cs" />
|
||||||
<Compile Include="Plugins\IPlugin.cs" />
|
<Compile Include="Plugins\IPlugin.cs" />
|
||||||
<Compile Include="Progress\ActionableProgress.cs" />
|
<Compile Include="Progress\ActionableProgress.cs" />
|
||||||
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Plugins
|
namespace MediaBrowser.Common.Plugins
|
||||||
{
|
{
|
||||||
@ -164,11 +163,7 @@ namespace MediaBrowser.Common.Plugins
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _configuration sync lock
|
/// The _configuration sync lock
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private object _configurationSyncLock = new object();
|
private readonly object _configurationSyncLock = new object();
|
||||||
/// <summary>
|
|
||||||
/// The _configuration initialized
|
|
||||||
/// </summary>
|
|
||||||
private bool _configurationInitialized;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _configuration
|
/// The _configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -182,17 +177,43 @@ namespace MediaBrowser.Common.Plugins
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
// Lazy load
|
// Lazy load
|
||||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => ConfigurationHelper.GetXmlConfiguration(ConfigurationType, ConfigurationFilePath, XmlSerializer) as TConfigurationType);
|
if (_configuration == null)
|
||||||
|
{
|
||||||
|
lock (_configurationSyncLock)
|
||||||
|
{
|
||||||
|
if (_configuration == null)
|
||||||
|
{
|
||||||
|
_configuration = LoadConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return _configuration;
|
return _configuration;
|
||||||
}
|
}
|
||||||
protected set
|
protected set
|
||||||
{
|
{
|
||||||
_configuration = value;
|
_configuration = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (value == null)
|
private TConfigurationType LoadConfiguration()
|
||||||
{
|
{
|
||||||
_configurationInitialized = false;
|
var path = ConfigurationFilePath;
|
||||||
}
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return (TConfigurationType)XmlSerializer.DeserializeFromFile(typeof(TConfigurationType), path);
|
||||||
|
}
|
||||||
|
catch (DirectoryNotFoundException)
|
||||||
|
{
|
||||||
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
|
{
|
||||||
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Channels
|
|||||||
|
|
||||||
public override bool IsVisible(User user)
|
public override bool IsVisible(User user)
|
||||||
{
|
{
|
||||||
if (user.Configuration.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
if (user.Policy.BlockedChannels.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using MediaBrowser.Model.Entities;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Channels
|
namespace MediaBrowser.Controller.Channels
|
||||||
{
|
{
|
||||||
@ -26,7 +27,7 @@ namespace MediaBrowser.Controller.Channels
|
|||||||
|
|
||||||
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
|
public List<ChannelMediaInfo> ChannelMediaSources { get; set; }
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
|
return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using MediaBrowser.Model.Configuration;
|
|||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Channels
|
namespace MediaBrowser.Controller.Channels
|
||||||
{
|
{
|
||||||
@ -20,7 +21,7 @@ namespace MediaBrowser.Controller.Channels
|
|||||||
|
|
||||||
public string OriginalImageUrl { get; set; }
|
public string OriginalImageUrl { get; set; }
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
// Don't block.
|
// Don't block.
|
||||||
return false;
|
return false;
|
||||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Channels
|
namespace MediaBrowser.Controller.Channels
|
||||||
{
|
{
|
||||||
@ -51,7 +52,7 @@ namespace MediaBrowser.Controller.Channels
|
|||||||
return ExternalId;
|
return ExternalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
|
return config.BlockUnratedItems.Contains(UnratedItem.ChannelContent);
|
||||||
}
|
}
|
||||||
|
@ -85,5 +85,13 @@ namespace MediaBrowser.Controller.Devices
|
|||||||
/// <param name="file">The file.</param>
|
/// <param name="file">The file.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file);
|
Task AcceptCameraUpload(string deviceId, Stream stream, LocalFileInfo file);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether this instance [can access device] the specified user identifier.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user identifier.</param>
|
||||||
|
/// <param name="deviceId">The device identifier.</param>
|
||||||
|
/// <returns><c>true</c> if this instance [can access device] the specified user identifier; otherwise, <c>false</c>.</returns>
|
||||||
|
bool CanAccessDevice(string userId, string deviceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Dto
|
namespace MediaBrowser.Controller.Dto
|
||||||
{
|
{
|
||||||
public class DtoOptions
|
public class DtoOptions
|
||||||
{
|
{
|
||||||
|
private static readonly List<ItemFields> DefaultExcludedFields = new List<ItemFields>
|
||||||
|
{
|
||||||
|
ItemFields.SeasonUserData
|
||||||
|
};
|
||||||
|
|
||||||
public List<ItemFields> Fields { get; set; }
|
public List<ItemFields> Fields { get; set; }
|
||||||
public List<ImageType> ImageTypes { get; set; }
|
public List<ImageType> ImageTypes { get; set; }
|
||||||
public int ImageTypeLimit { get; set; }
|
public int ImageTypeLimit { get; set; }
|
||||||
@ -14,9 +21,17 @@ namespace MediaBrowser.Model.Dto
|
|||||||
public DtoOptions()
|
public DtoOptions()
|
||||||
{
|
{
|
||||||
Fields = new List<ItemFields>();
|
Fields = new List<ItemFields>();
|
||||||
ImageTypes = new List<ImageType>();
|
|
||||||
ImageTypeLimit = int.MaxValue;
|
ImageTypeLimit = int.MaxValue;
|
||||||
EnableImages = true;
|
EnableImages = true;
|
||||||
|
|
||||||
|
Fields = Enum.GetNames(typeof (ItemFields))
|
||||||
|
.Select(i => (ItemFields) Enum.Parse(typeof (ItemFields), i, true))
|
||||||
|
.Except(DefaultExcludedFields)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
ImageTypes = Enum.GetNames(typeof(ImageType))
|
||||||
|
.Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true))
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetImageLimit(ImageType type)
|
public int GetImageLimit(ImageType type)
|
@ -8,6 +8,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities.Audio
|
namespace MediaBrowser.Controller.Entities.Audio
|
||||||
{
|
{
|
||||||
@ -88,6 +89,21 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool IsArchive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var ext = System.IO.Path.GetExtension(Path) ?? string.Empty;
|
||||||
|
|
||||||
|
return new[] { ".zip", ".rar", ".7z" }.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the artist.
|
/// Gets or sets the artist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -173,7 +189,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||||||
return base.GetUserDataKey();
|
return base.GetUserDataKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities.Audio
|
namespace MediaBrowser.Controller.Entities.Audio
|
||||||
{
|
{
|
||||||
@ -154,7 +155,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||||||
return base.GetUserDataKey();
|
return base.GetUserDataKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities.Audio
|
namespace MediaBrowser.Controller.Entities.Audio
|
||||||
{
|
{
|
||||||
@ -114,7 +115,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||||||
return "Artist-" + item.Name;
|
return "Artist-" + item.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||||
}
|
}
|
||||||
@ -135,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||||||
// Refresh songs
|
// Refresh songs
|
||||||
foreach (var item in songs)
|
foreach (var item in songs)
|
||||||
{
|
{
|
||||||
if (tasks.Count >= 3)
|
if (tasks.Count >= 2)
|
||||||
{
|
{
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
tasks.Clear();
|
tasks.Clear();
|
||||||
@ -172,37 +173,23 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||||||
// Refresh all non-songs
|
// Refresh all non-songs
|
||||||
foreach (var item in others)
|
foreach (var item in others)
|
||||||
{
|
{
|
||||||
if (tasks.Count >= 3)
|
|
||||||
{
|
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
||||||
tasks.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
var innerProgress = new ActionableProgress<double>();
|
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
// Avoid implicitly captured closure
|
||||||
var currentChild = item;
|
var currentChild = item;
|
||||||
innerProgress.RegisterAction(p =>
|
|
||||||
|
await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
|
||||||
|
lock (percentages)
|
||||||
{
|
{
|
||||||
lock (percentages)
|
percentages[currentChild.Id] = 1;
|
||||||
{
|
|
||||||
percentages[currentChild.Id] = p / 100;
|
|
||||||
|
|
||||||
var percent = percentages.Values.Sum();
|
var percent = percentages.Values.Sum();
|
||||||
percent /= totalItems;
|
percent /= totalItems;
|
||||||
percent *= 100;
|
percent *= 100;
|
||||||
progress.Report(percent);
|
progress.Report(percent);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
|
||||||
var taskChild = item;
|
|
||||||
tasks.Add(Task.Run(async () => await RefreshItem(taskChild, refreshOptions, innerProgress, cancellationToken).ConfigureAwait(false), cancellationToken));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
|
||||||
|
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using MediaBrowser.Model.Dto;
|
|||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Library;
|
using MediaBrowser.Model.Library;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -45,6 +46,8 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn" };
|
public static readonly string[] SupportedImageExtensions = { ".png", ".jpg", ".jpeg", ".tbn" };
|
||||||
|
|
||||||
|
public static readonly List<string> SupportedImageExtensionsList = SupportedImageExtensions.ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The trailer folder name
|
/// The trailer folder name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -593,7 +596,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <returns>PlayAccess.</returns>
|
/// <returns>PlayAccess.</returns>
|
||||||
public PlayAccess GetPlayAccess(User user)
|
public PlayAccess GetPlayAccess(User user)
|
||||||
{
|
{
|
||||||
if (!user.Configuration.EnableMediaPlayback)
|
if (!user.Policy.EnableMediaPlayback)
|
||||||
{
|
{
|
||||||
return PlayAccess.None;
|
return PlayAccess.None;
|
||||||
}
|
}
|
||||||
@ -985,7 +988,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxAllowedRating = user.Configuration.MaxParentalRating;
|
var maxAllowedRating = user.Policy.MaxParentalRating;
|
||||||
|
|
||||||
if (maxAllowedRating == null)
|
if (maxAllowedRating == null)
|
||||||
{
|
{
|
||||||
@ -1001,7 +1004,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(rating))
|
if (string.IsNullOrWhiteSpace(rating))
|
||||||
{
|
{
|
||||||
return !GetBlockUnratedValue(user.Configuration);
|
return !GetBlockUnratedValue(user.Policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = LocalizationManager.GetRatingLevel(rating);
|
var value = LocalizationManager.GetRatingLevel(rating);
|
||||||
@ -1021,7 +1024,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
if (hasTags != null)
|
if (hasTags != null)
|
||||||
{
|
{
|
||||||
if (user.Configuration.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
if (user.Policy.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1035,7 +1038,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="config">The configuration.</param>
|
/// <param name="config">The configuration.</param>
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
protected virtual bool GetBlockUnratedValue(UserConfiguration config)
|
protected virtual bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
||||||
}
|
}
|
||||||
@ -1574,6 +1577,11 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
foreach (var newImage in images)
|
foreach (var newImage in images)
|
||||||
{
|
{
|
||||||
|
if (newImage == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("null image found in list");
|
||||||
|
}
|
||||||
|
|
||||||
var existing = existingImages
|
var existing = existingImages
|
||||||
.FirstOrDefault(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
|
.FirstOrDefault(i => string.Equals(i.Path, newImage.FullName, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
@ -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 MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -36,7 +37,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
Tags = new List<string>();
|
Tags = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Book);
|
return config.BlockUnratedItems.Contains(UnratedItem.Book);
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,22 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return CreateResolveArgs(directoryService).FileSystemChildren;
|
return CreateResolveArgs(directoryService).FileSystemChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal override bool IsValidFromResolver(BaseItem newItem)
|
||||||
|
{
|
||||||
|
var newCollectionFolder = newItem as CollectionFolder;
|
||||||
|
|
||||||
|
if (newCollectionFolder != null)
|
||||||
|
{
|
||||||
|
if (!string.Equals(CollectionType, newCollectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return base.IsValidFromResolver(newItem);
|
||||||
|
}
|
||||||
|
|
||||||
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService)
|
private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService)
|
||||||
{
|
{
|
||||||
var path = ContainingFolderPath;
|
var path = ContainingFolderPath;
|
||||||
|
@ -303,10 +303,10 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
if (this is ICollectionFolder)
|
if (this is ICollectionFolder)
|
||||||
{
|
{
|
||||||
if (user.Configuration.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) ||
|
if (user.Policy.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) ||
|
||||||
|
|
||||||
// Backwards compatibility
|
// Backwards compatibility
|
||||||
user.Configuration.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase))
|
user.Policy.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -545,7 +545,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
foreach (var child in children)
|
foreach (var child in children)
|
||||||
{
|
{
|
||||||
if (tasks.Count >= 3)
|
if (tasks.Count >= 2)
|
||||||
{
|
{
|
||||||
await Task.WhenAll(tasks).ConfigureAwait(false);
|
await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||||
tasks.Clear();
|
tasks.Clear();
|
||||||
@ -708,7 +708,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||||
protected virtual IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
protected virtual IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
|
||||||
{
|
{
|
||||||
var collectionType = LibraryManager.FindCollectionType(this);
|
var collectionType = LibraryManager.GetContentType(this);
|
||||||
|
|
||||||
return LibraryManager.ResolvePaths(GetFileSystemChildren(directoryService), directoryService, this, collectionType);
|
return LibraryManager.ResolvePaths(GetFileSystemChildren(directoryService), directoryService, this, collectionType);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using MediaBrowser.Model.Entities;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -108,7 +109,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return base.GetDeletePaths();
|
return base.GetDeletePaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Game);
|
return config.BlockUnratedItems.Contains(UnratedItem.Game);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using System;
|
using System;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -43,7 +44,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return base.GetUserDataKey();
|
return base.GetUserDataKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
// Don't block. Determine by game
|
// Don't block. Determine by game
|
||||||
return false;
|
return false;
|
||||||
|
@ -49,8 +49,8 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
: new[] { user.Configuration.AudioLanguagePreference };
|
: new[] { user.Configuration.AudioLanguagePreference };
|
||||||
|
|
||||||
var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference)
|
var preferredSubs = string.IsNullOrEmpty(user.Configuration.SubtitleLanguagePreference)
|
||||||
? new string[] { }
|
? new List<string> { }
|
||||||
: new[] { user.Configuration.SubtitleLanguagePreference };
|
: new List<string> { user.Configuration.SubtitleLanguagePreference };
|
||||||
|
|
||||||
foreach (var source in sources)
|
foreach (var source in sources)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities.Movies
|
namespace MediaBrowser.Controller.Entities.Movies
|
||||||
{
|
{
|
||||||
@ -67,7 +68,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||||||
/// <value>The display order.</value>
|
/// <value>The display order.</value>
|
||||||
public string DisplayOrder { get; set; }
|
public string DisplayOrder { get; set; }
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
||||||
}
|
}
|
||||||
@ -170,10 +171,13 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||||||
{
|
{
|
||||||
var userId = user.Id.ToString("N");
|
var userId = user.Id.ToString("N");
|
||||||
|
|
||||||
return Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)) ||
|
// Need to check Count > 0 for boxsets created prior to the introduction of Shares
|
||||||
|
if (Shares.Count > 0 && !Shares.Any(i => string.Equals(userId, i.UserId, StringComparison.OrdinalIgnoreCase)))
|
||||||
|
{
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Need to support this for boxsets created prior to the creation of Shares
|
return true;
|
||||||
Shares.Count == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -146,14 +147,21 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||||||
return itemsChanged;
|
return itemsChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MovieInfo GetLookupInfo()
|
public MovieInfo GetLookupInfo()
|
||||||
{
|
{
|
||||||
return GetItemLookupInfo<MovieInfo>();
|
var info = GetItemLookupInfo<MovieInfo>();
|
||||||
|
|
||||||
|
if (!IsInMixedFolder)
|
||||||
|
{
|
||||||
|
info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool BeforeMetadataRefresh()
|
public override bool BeforeMetadataRefresh()
|
||||||
|
@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -80,7 +81,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey();
|
return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using MediaBrowser.Model.Drawing;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -70,7 +71,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
public double? Altitude { get; set; }
|
public double? Altitude { get; set; }
|
||||||
public int? IsoSpeedRating { get; set; }
|
public int? IsoSpeedRating { get; set; }
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -23,7 +24,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Providers;
|
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -178,6 +178,15 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool IsInSeasonFolder
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return FindParent<Season>() != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public string SeriesName
|
public string SeriesName
|
||||||
{
|
{
|
||||||
@ -275,7 +284,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
return new[] { Path };
|
return new[] { Path };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
||||||
}
|
}
|
||||||
@ -301,51 +310,9 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
{
|
{
|
||||||
var hasChanges = base.BeforeMetadataRefresh();
|
var hasChanges = base.BeforeMetadataRefresh();
|
||||||
|
|
||||||
var locationType = LocationType;
|
if (LibraryManager.FillMissingEpisodeNumbersFromPath(this))
|
||||||
if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
|
|
||||||
{
|
{
|
||||||
if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
hasChanges = true;
|
||||||
{
|
|
||||||
IndexNumber = LibraryManager.GetEpisodeNumberFromFile(Path, true);
|
|
||||||
|
|
||||||
// If a change was made record it
|
|
||||||
if (IndexNumber.HasValue)
|
|
||||||
{
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IndexNumberEnd.HasValue && !string.IsNullOrEmpty(Path))
|
|
||||||
{
|
|
||||||
IndexNumberEnd = LibraryManager.GetEndingEpisodeNumberFromFile(Path);
|
|
||||||
|
|
||||||
// If a change was made record it
|
|
||||||
if (IndexNumberEnd.HasValue)
|
|
||||||
{
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ParentIndexNumber.HasValue)
|
|
||||||
{
|
|
||||||
var season = Season;
|
|
||||||
|
|
||||||
if (season != null)
|
|
||||||
{
|
|
||||||
ParentIndexNumber = season.IndexNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ParentIndexNumber.HasValue && !string.IsNullOrEmpty(Path))
|
|
||||||
{
|
|
||||||
ParentIndexNumber = LibraryManager.GetSeasonNumberFromEpisodeFile(Path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a change was made record it
|
|
||||||
if (ParentIndexNumber.HasValue)
|
|
||||||
{
|
|
||||||
hasChanges = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasChanges;
|
return hasChanges;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Localization;
|
||||||
using MediaBrowser.Controller.Localization;
|
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Configuration;
|
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
using MoreLinq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
@ -155,24 +155,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name;
|
return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Episode> GetEpisodes()
|
|
||||||
{
|
|
||||||
var series = Series;
|
|
||||||
|
|
||||||
if (series != null && series.ContainsEpisodesWithoutSeasonFolders)
|
|
||||||
{
|
|
||||||
var seasonNumber = IndexNumber;
|
|
||||||
|
|
||||||
if (seasonNumber.HasValue)
|
|
||||||
{
|
|
||||||
return series.RecursiveChildren.OfType<Episode>()
|
|
||||||
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == seasonNumber.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Children.OfType<Episode>();
|
|
||||||
}
|
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public bool IsMissingSeason
|
public bool IsMissingSeason
|
||||||
{
|
{
|
||||||
@ -220,14 +202,30 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
var episodes = GetRecursiveChildren(user)
|
var episodes = GetRecursiveChildren(user)
|
||||||
.OfType<Episode>();
|
.OfType<Episode>();
|
||||||
|
|
||||||
if (IndexNumber.HasValue)
|
var series = Series;
|
||||||
{
|
|
||||||
var series = Series;
|
|
||||||
|
|
||||||
if (series != null)
|
if (IndexNumber.HasValue && series != null)
|
||||||
|
{
|
||||||
|
return series.GetEpisodes(user, IndexNumber.Value, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series != null && series.ContainsEpisodesWithoutSeasonFolders)
|
||||||
|
{
|
||||||
|
var seasonNumber = IndexNumber;
|
||||||
|
var list = episodes.ToList();
|
||||||
|
|
||||||
|
if (seasonNumber.HasValue)
|
||||||
{
|
{
|
||||||
return series.GetEpisodes(user, IndexNumber.Value, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes);
|
list.AddRange(series.GetRecursiveChildren(user).OfType<Episode>()
|
||||||
|
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == seasonNumber.Value));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.AddRange(series.GetRecursiveChildren(user).OfType<Episode>()
|
||||||
|
.Where(i => !i.ParentIndexNumber.HasValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
episodes = list.DistinctBy(i => i.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!includeMissingEpisodes)
|
if (!includeMissingEpisodes)
|
||||||
@ -244,12 +242,39 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
.Cast<Episode>();
|
.Cast<Episode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<Episode> GetEpisodes()
|
||||||
|
{
|
||||||
|
var episodes = RecursiveChildren.OfType<Episode>();
|
||||||
|
var series = Series;
|
||||||
|
|
||||||
|
if (series != null && series.ContainsEpisodesWithoutSeasonFolders)
|
||||||
|
{
|
||||||
|
var seasonNumber = IndexNumber;
|
||||||
|
var list = episodes.ToList();
|
||||||
|
|
||||||
|
if (seasonNumber.HasValue)
|
||||||
|
{
|
||||||
|
list.AddRange(series.RecursiveChildren.OfType<Episode>()
|
||||||
|
.Where(i => i.ParentIndexNumber.HasValue && i.ParentIndexNumber.Value == seasonNumber.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.AddRange(series.RecursiveChildren.OfType<Episode>()
|
||||||
|
.Where(i => !i.ParentIndexNumber.HasValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
episodes = list.DistinctBy(i => i.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return episodes;
|
||||||
|
}
|
||||||
|
|
||||||
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
|
||||||
{
|
{
|
||||||
return GetEpisodes(user);
|
return GetEpisodes(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
// Don't block. Let either the entire series rating or episode rating determine it
|
// Don't block. Let either the entire series rating or episode rating determine it
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,6 +3,7 @@ using MediaBrowser.Controller.Providers;
|
|||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -87,7 +88,17 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
/// Gets or sets the date last episode added.
|
/// Gets or sets the date last episode added.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The date last episode added.</value>
|
/// <value>The date last episode added.</value>
|
||||||
public DateTime DateLastEpisodeAdded { get; set; }
|
[IgnoreDataMember]
|
||||||
|
public DateTime DateLastEpisodeAdded
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return RecursiveChildren.OfType<Episode>()
|
||||||
|
.Select(i => i.DateCreated)
|
||||||
|
.OrderByDescending(i => i)
|
||||||
|
.FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Series aren't included directly in indices - Their Episodes will roll up to them
|
/// Series aren't included directly in indices - Their Episodes will roll up to them
|
||||||
@ -246,7 +257,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -98,7 +99,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return base.GetUserDataKey();
|
return base.GetUserDataKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.Trailer);
|
return config.BlockUnratedItems.Contains(UnratedItem.Trailer);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Connect;
|
using MediaBrowser.Model.Connect;
|
||||||
@ -107,37 +106,27 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <value>The last activity date.</value>
|
/// <value>The last activity date.</value>
|
||||||
public DateTime? LastActivityDate { get; set; }
|
public DateTime? LastActivityDate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
private UserConfiguration _config;
|
||||||
/// The _configuration
|
private readonly object _configSyncLock = new object();
|
||||||
/// </summary>
|
|
||||||
private UserConfiguration _configuration;
|
|
||||||
/// <summary>
|
|
||||||
/// The _configuration initialized
|
|
||||||
/// </summary>
|
|
||||||
private bool _configurationInitialized;
|
|
||||||
/// <summary>
|
|
||||||
/// The _configuration sync lock
|
|
||||||
/// </summary>
|
|
||||||
private object _configurationSyncLock = new object();
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the user's configuration
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The configuration.</value>
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public UserConfiguration Configuration
|
public UserConfiguration Configuration
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
// Lazy load
|
if (_config == null)
|
||||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)ConfigurationHelper.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath, XmlSerializer));
|
{
|
||||||
return _configuration;
|
lock (_configSyncLock)
|
||||||
}
|
{
|
||||||
private set
|
if (_config == null)
|
||||||
{
|
{
|
||||||
_configuration = value;
|
_config = UserManager.GetUserConfiguration(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_configurationInitialized = value != null;
|
return _config;
|
||||||
}
|
}
|
||||||
|
set { _config = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserPolicy _policy;
|
private UserPolicy _policy;
|
||||||
@ -256,35 +245,6 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return System.IO.Path.Combine(parentPath, Id.ToString("N"));
|
return System.IO.Path.Combine(parentPath, Id.ToString("N"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the path to the user's configuration file
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The configuration file path.</value>
|
|
||||||
[IgnoreDataMember]
|
|
||||||
public string ConfigurationFilePath
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return System.IO.Path.Combine(ConfigurationDirectoryPath, "config.xml");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the configuration.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="config">The config.</param>
|
|
||||||
/// <exception cref="System.ArgumentNullException">config</exception>
|
|
||||||
public void UpdateConfiguration(UserConfiguration config)
|
|
||||||
{
|
|
||||||
if (config == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("config");
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration = config;
|
|
||||||
UserManager.UpdateConfiguration(this, Configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsParentalScheduleAllowed()
|
public bool IsParentalScheduleAllowed()
|
||||||
{
|
{
|
||||||
return IsParentalScheduleAllowed(DateTime.UtcNow);
|
return IsParentalScheduleAllowed(DateTime.UtcNow);
|
||||||
@ -292,7 +252,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
public bool IsParentalScheduleAllowed(DateTime date)
|
public bool IsParentalScheduleAllowed(DateTime date)
|
||||||
{
|
{
|
||||||
var schedules = Configuration.AccessSchedules;
|
var schedules = Policy.AccessSchedules;
|
||||||
|
|
||||||
if (schedules.Length == 0)
|
if (schedules.Length == 0)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,8 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
{
|
{
|
||||||
CollectionType.Books,
|
CollectionType.Books,
|
||||||
CollectionType.HomeVideos,
|
CollectionType.HomeVideos,
|
||||||
CollectionType.Photos
|
CollectionType.Photos,
|
||||||
|
string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
var collectionFolder = folder as ICollectionFolder;
|
var collectionFolder = folder as ICollectionFolder;
|
||||||
|
@ -91,6 +91,21 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
get { return LocalAlternateVersions.Count > 0; }
|
get { return LocalAlternateVersions.Count > 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public bool IsArchive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var ext = System.IO.Path.GetExtension(Path) ?? string.Empty;
|
||||||
|
|
||||||
|
return new[] { ".zip", ".rar", ".7z" }.Contains(ext, StringComparer.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Guid> GetAdditionalPartIds()
|
public IEnumerable<Guid> GetAdditionalPartIds()
|
||||||
{
|
{
|
||||||
return AdditionalParts.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));
|
return AdditionalParts.Select(i => LibraryManager.GetNewItemId(i, typeof(Video)));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
@ -22,11 +23,9 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fileInfo">The file information.</param>
|
/// <param name="fileInfo">The file information.</param>
|
||||||
/// <param name="parent">The parent.</param>
|
/// <param name="parent">The parent.</param>
|
||||||
/// <param name="collectionType">Type of the collection.</param>
|
|
||||||
/// <returns>BaseItem.</returns>
|
/// <returns>BaseItem.</returns>
|
||||||
BaseItem ResolvePath(FileSystemInfo fileInfo,
|
BaseItem ResolvePath(FileSystemInfo fileInfo,
|
||||||
Folder parent = null,
|
Folder parent = null);
|
||||||
string collectionType = null);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves a set of files into a list of BaseItem
|
/// Resolves a set of files into a list of BaseItem
|
||||||
@ -258,7 +257,14 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item.</param>
|
/// <param name="item">The item.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
string FindCollectionType(BaseItem item);
|
string GetContentType(BaseItem item);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the inherited content.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string GetInheritedContentType(BaseItem item);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Normalizes the root path list.
|
/// Normalizes the root path list.
|
||||||
@ -340,26 +346,11 @@ namespace MediaBrowser.Controller.Library
|
|||||||
int? GetSeasonNumberFromPath(string path);
|
int? GetSeasonNumberFromPath(string path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the season number from episode file.
|
/// Fills the missing episode numbers from path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">The path.</param>
|
/// <param name="episode">The episode.</param>
|
||||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
int? GetSeasonNumberFromEpisodeFile(string path);
|
bool FillMissingEpisodeNumbersFromPath(Episode episode);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the ending episode number from file.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
|
||||||
int? GetEndingEpisodeNumberFromFile(string path);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the episode number from file.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="path">The path.</param>
|
|
||||||
/// <param name="considerSeasonless">if set to <c>true</c> [consider seasonless].</param>
|
|
||||||
/// <returns>System.Nullable<System.Int32>.</returns>
|
|
||||||
int? GetEpisodeNumberFromFile(string path, bool considerSeasonless);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parses the name.
|
/// Parses the name.
|
||||||
|
@ -61,5 +61,9 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken);
|
Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates playstate for an item and returns true or false indicating if it was played to completion
|
||||||
|
/// </summary>
|
||||||
|
bool UpdatePlayState(BaseItem item, UserItemData data, long positionTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,13 +35,6 @@ namespace MediaBrowser.Controller.Library
|
|||||||
event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
|
event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
|
||||||
event EventHandler<GenericEventArgs<User>> UserPasswordChanged;
|
event EventHandler<GenericEventArgs<User>> UserPasswordChanged;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the configuration.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The user.</param>
|
|
||||||
/// <param name="newConfiguration">The new configuration.</param>
|
|
||||||
void UpdateConfiguration(User user, UserConfiguration newConfiguration);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a User by Id
|
/// Gets a User by Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -172,11 +165,33 @@ namespace MediaBrowser.Controller.Library
|
|||||||
/// <returns>UserPolicy.</returns>
|
/// <returns>UserPolicy.</returns>
|
||||||
UserPolicy GetUserPolicy(User user);
|
UserPolicy GetUserPolicy(User user);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the user configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user">The user.</param>
|
||||||
|
/// <returns>UserConfiguration.</returns>
|
||||||
|
UserConfiguration GetUserConfiguration(User user);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">The user identifier.</param>
|
||||||
|
/// <param name="newConfiguration">The new configuration.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task UpdateConfiguration(string userId, UserConfiguration newConfiguration);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the user policy.
|
/// Updates the user policy.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The user identifier.</param>
|
/// <param name="userId">The user identifier.</param>
|
||||||
/// <param name="userPolicy">The user policy.</param>
|
/// <param name="userPolicy">The user policy.</param>
|
||||||
Task UpdateUserPolicy(string userId, UserPolicy userPolicy);
|
Task UpdateUserPolicy(string userId, UserPolicy userPolicy);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Makes the valid username.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="username">The username.</param>
|
||||||
|
/// <returns>System.String.</returns>
|
||||||
|
string MakeValidUsername(string username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.LiveTv
|
namespace MediaBrowser.Controller.LiveTv
|
||||||
{
|
{
|
||||||
@ -78,7 +79,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
|
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using MediaBrowser.Model.LiveTv;
|
|||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.LiveTv
|
namespace MediaBrowser.Controller.LiveTv
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvChannel);
|
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvChannel);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.LiveTv
|
namespace MediaBrowser.Controller.LiveTv
|
||||||
{
|
{
|
||||||
@ -199,7 +200,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
return ItemRepository.SaveItem(this, cancellationToken);
|
return ItemRepository.SaveItem(this, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
|
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.LiveTv
|
namespace MediaBrowser.Controller.LiveTv
|
||||||
{
|
{
|
||||||
@ -78,7 +79,7 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
|
return config.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.LiveTv
|
namespace MediaBrowser.Controller.LiveTv
|
||||||
{
|
{
|
||||||
public class RecordingGroup : Folder
|
public class RecordingGroup : Folder
|
||||||
{
|
{
|
||||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||||
{
|
{
|
||||||
// Don't block.
|
// Don't block.
|
||||||
return false;
|
return false;
|
||||||
|
@ -115,6 +115,7 @@
|
|||||||
<Compile Include="Drawing\ImageProcessingOptions.cs" />
|
<Compile Include="Drawing\ImageProcessingOptions.cs" />
|
||||||
<Compile Include="Drawing\ImageProcessorExtensions.cs" />
|
<Compile Include="Drawing\ImageProcessorExtensions.cs" />
|
||||||
<Compile Include="Drawing\ImageStream.cs" />
|
<Compile Include="Drawing\ImageStream.cs" />
|
||||||
|
<Compile Include="Dto\DtoOptions.cs" />
|
||||||
<Compile Include="Dto\IDtoService.cs" />
|
<Compile Include="Dto\IDtoService.cs" />
|
||||||
<Compile Include="Entities\AdultVideo.cs" />
|
<Compile Include="Entities\AdultVideo.cs" />
|
||||||
<Compile Include="Entities\Audio\IHasAlbumArtist.cs" />
|
<Compile Include="Entities\Audio\IHasAlbumArtist.cs" />
|
||||||
@ -198,18 +199,17 @@
|
|||||||
<Compile Include="LiveTv\SeriesTimerInfo.cs" />
|
<Compile Include="LiveTv\SeriesTimerInfo.cs" />
|
||||||
<Compile Include="LiveTv\TimerInfo.cs" />
|
<Compile Include="LiveTv\TimerInfo.cs" />
|
||||||
<Compile Include="Localization\ILocalizationManager.cs" />
|
<Compile Include="Localization\ILocalizationManager.cs" />
|
||||||
<Compile Include="MediaEncoding\EncodingOptions.cs" />
|
|
||||||
<Compile Include="MediaEncoding\ChapterImageRefreshOptions.cs" />
|
<Compile Include="MediaEncoding\ChapterImageRefreshOptions.cs" />
|
||||||
<Compile Include="MediaEncoding\EncodingResult.cs" />
|
<Compile Include="MediaEncoding\EncodingJobOptions.cs" />
|
||||||
<Compile Include="MediaEncoding\IEncodingManager.cs" />
|
<Compile Include="MediaEncoding\IEncodingManager.cs" />
|
||||||
<Compile Include="MediaEncoding\ImageEncodingOptions.cs" />
|
<Compile Include="MediaEncoding\ImageEncodingOptions.cs" />
|
||||||
<Compile Include="MediaEncoding\IMediaEncoder.cs" />
|
<Compile Include="MediaEncoding\IMediaEncoder.cs" />
|
||||||
<Compile Include="MediaEncoding\InternalMediaInfoResult.cs" />
|
<Compile Include="MediaEncoding\InternalMediaInfoResult.cs" />
|
||||||
<Compile Include="MediaEncoding\ISubtitleEncoder.cs" />
|
<Compile Include="MediaEncoding\ISubtitleEncoder.cs" />
|
||||||
<Compile Include="MediaEncoding\MediaStreamSelector.cs" />
|
<Compile Include="MediaEncoding\MediaStreamSelector.cs" />
|
||||||
<Compile Include="MediaEncoding\VideoEncodingOptions.cs" />
|
|
||||||
<Compile Include="Net\AuthenticatedAttribute.cs" />
|
<Compile Include="Net\AuthenticatedAttribute.cs" />
|
||||||
<Compile Include="Net\AuthorizationInfo.cs" />
|
<Compile Include="Net\AuthorizationInfo.cs" />
|
||||||
|
<Compile Include="Net\BasePeriodicWebSocketListener.cs" />
|
||||||
<Compile Include="Net\IAuthorizationContext.cs" />
|
<Compile Include="Net\IAuthorizationContext.cs" />
|
||||||
<Compile Include="Net\IAuthService.cs" />
|
<Compile Include="Net\IAuthService.cs" />
|
||||||
<Compile Include="Net\IHasAuthorization.cs" />
|
<Compile Include="Net\IHasAuthorization.cs" />
|
||||||
@ -221,10 +221,15 @@
|
|||||||
<Compile Include="Net\IServerManager.cs" />
|
<Compile Include="Net\IServerManager.cs" />
|
||||||
<Compile Include="Net\IServiceRequest.cs" />
|
<Compile Include="Net\IServiceRequest.cs" />
|
||||||
<Compile Include="Net\ISessionContext.cs" />
|
<Compile Include="Net\ISessionContext.cs" />
|
||||||
|
<Compile Include="Net\IWebSocket.cs" />
|
||||||
|
<Compile Include="Net\IWebSocketConnection.cs" />
|
||||||
|
<Compile Include="Net\IWebSocketListener.cs" />
|
||||||
<Compile Include="Net\LoggedAttribute.cs" />
|
<Compile Include="Net\LoggedAttribute.cs" />
|
||||||
<Compile Include="Net\SecurityException.cs" />
|
<Compile Include="Net\SecurityException.cs" />
|
||||||
<Compile Include="Net\ServiceStackServiceRequest.cs" />
|
<Compile Include="Net\ServiceStackServiceRequest.cs" />
|
||||||
<Compile Include="Net\StaticResultOptions.cs" />
|
<Compile Include="Net\StaticResultOptions.cs" />
|
||||||
|
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
|
||||||
|
<Compile Include="Net\WebSocketMessageInfo.cs" />
|
||||||
<Compile Include="News\INewsService.cs" />
|
<Compile Include="News\INewsService.cs" />
|
||||||
<Compile Include="Notifications\INotificationManager.cs" />
|
<Compile Include="Notifications\INotificationManager.cs" />
|
||||||
<Compile Include="Notifications\INotificationService.cs" />
|
<Compile Include="Notifications\INotificationService.cs" />
|
||||||
|
91
MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs
Normal file
91
MediaBrowser.Controller/MediaEncoding/EncodingJobOptions.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Controller.MediaEncoding
|
||||||
|
{
|
||||||
|
public class EncodingJobOptions
|
||||||
|
{
|
||||||
|
public string OutputContainer { get; set; }
|
||||||
|
|
||||||
|
public long? StartTimeTicks { get; set; }
|
||||||
|
public int? Width { get; set; }
|
||||||
|
public int? Height { get; set; }
|
||||||
|
public int? MaxWidth { get; set; }
|
||||||
|
public int? MaxHeight { get; set; }
|
||||||
|
public bool Static = false;
|
||||||
|
public float? Framerate { get; set; }
|
||||||
|
public float? MaxFramerate { get; set; }
|
||||||
|
public string Profile { get; set; }
|
||||||
|
public int? Level { get; set; }
|
||||||
|
|
||||||
|
public string DeviceId { get; set; }
|
||||||
|
public string ItemId { get; set; }
|
||||||
|
public string MediaSourceId { get; set; }
|
||||||
|
public string AudioCodec { get; set; }
|
||||||
|
|
||||||
|
public bool EnableAutoStreamCopy { get; set; }
|
||||||
|
|
||||||
|
public int? MaxAudioChannels { get; set; }
|
||||||
|
public int? AudioChannels { get; set; }
|
||||||
|
public int? AudioBitRate { get; set; }
|
||||||
|
public int? AudioSampleRate { get; set; }
|
||||||
|
|
||||||
|
public DeviceProfile DeviceProfile { get; set; }
|
||||||
|
public EncodingContext Context { get; set; }
|
||||||
|
|
||||||
|
public string VideoCodec { get; set; }
|
||||||
|
|
||||||
|
public int? VideoBitRate { get; set; }
|
||||||
|
public int? AudioStreamIndex { get; set; }
|
||||||
|
public int? VideoStreamIndex { get; set; }
|
||||||
|
public int? SubtitleStreamIndex { get; set; }
|
||||||
|
public int? MaxRefFrames { get; set; }
|
||||||
|
public int? MaxVideoBitDepth { get; set; }
|
||||||
|
public SubtitleDeliveryMethod SubtitleMethod { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this instance has fixed resolution.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance has fixed resolution; otherwise, <c>false</c>.</value>
|
||||||
|
public bool HasFixedResolution
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Width.HasValue || Height.HasValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool? Cabac { get; set; }
|
||||||
|
|
||||||
|
public EncodingJobOptions()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public EncodingJobOptions(StreamInfo info, DeviceProfile deviceProfile)
|
||||||
|
{
|
||||||
|
OutputContainer = info.Container;
|
||||||
|
StartTimeTicks = info.StartPositionTicks;
|
||||||
|
MaxWidth = info.MaxWidth;
|
||||||
|
MaxHeight = info.MaxHeight;
|
||||||
|
MaxFramerate = info.MaxFramerate;
|
||||||
|
Profile = info.VideoProfile;
|
||||||
|
Level = info.VideoLevel;
|
||||||
|
ItemId = info.ItemId;
|
||||||
|
MediaSourceId = info.MediaSourceId;
|
||||||
|
AudioCodec = info.AudioCodec;
|
||||||
|
MaxAudioChannels = info.MaxAudioChannels;
|
||||||
|
AudioBitRate = info.AudioBitrate;
|
||||||
|
AudioSampleRate = info.TargetAudioSampleRate;
|
||||||
|
DeviceProfile = deviceProfile;
|
||||||
|
VideoCodec = info.VideoCodec;
|
||||||
|
VideoBitRate = info.VideoBitrate;
|
||||||
|
AudioStreamIndex = info.AudioStreamIndex;
|
||||||
|
SubtitleStreamIndex = info.SubtitleStreamIndex;
|
||||||
|
MaxRefFrames = info.MaxRefFrames;
|
||||||
|
MaxVideoBitDepth = info.MaxVideoBitDepth;
|
||||||
|
SubtitleMethod = info.SubtitleDeliveryMethod;
|
||||||
|
Cabac = info.Cabac;
|
||||||
|
Context = info.Context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,80 +0,0 @@
|
|||||||
using MediaBrowser.Controller.Dlna;
|
|
||||||
using MediaBrowser.Model.Dlna;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.MediaEncoding
|
|
||||||
{
|
|
||||||
public class EncodingOptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the item identifier.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The item identifier.</value>
|
|
||||||
public string ItemId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the media source identifier.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The media source identifier.</value>
|
|
||||||
public string MediaSourceId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the device profile.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The device profile.</value>
|
|
||||||
public DeviceProfile DeviceProfile { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the output path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The output path.</value>
|
|
||||||
public string OutputPath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the container.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The container.</value>
|
|
||||||
public string Container { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the audio codec.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The audio codec.</value>
|
|
||||||
public string AudioCodec { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the start time ticks.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The start time ticks.</value>
|
|
||||||
public long? StartTimeTicks { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the maximum channels.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The maximum channels.</value>
|
|
||||||
public int? MaxAudioChannels { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the channels.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The channels.</value>
|
|
||||||
public int? AudioChannels { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the sample rate.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The sample rate.</value>
|
|
||||||
public int? AudioSampleRate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the bit rate.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The bit rate.</value>
|
|
||||||
public int? AudioBitRate { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the maximum audio bit rate.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The maximum audio bit rate.</value>
|
|
||||||
public int? MaxAudioBitRate { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.MediaEncoding
|
|
||||||
{
|
|
||||||
public class EncodingResult
|
|
||||||
{
|
|
||||||
public string OutputPath { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -96,5 +96,27 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
/// <param name="ticks">The ticks.</param>
|
/// <param name="ticks">The ticks.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
string GetTimeParameter(long ticks);
|
string GetTimeParameter(long ticks);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes the audio.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">The options.</param>
|
||||||
|
/// <param name="progress">The progress.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task.</returns>
|
||||||
|
Task<string> EncodeAudio(EncodingJobOptions options,
|
||||||
|
IProgress<double> progress,
|
||||||
|
CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Encodes the video.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="options">The options.</param>
|
||||||
|
/// <param name="progress">The progress.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task<System.String>.</returns>
|
||||||
|
Task<string> EncodeVideo(EncodingJobOptions options,
|
||||||
|
IProgress<double> progress,
|
||||||
|
CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,13 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int? GetDefaultSubtitleStreamIndex(List<MediaStream> streams,
|
public static int? GetDefaultSubtitleStreamIndex(List<MediaStream> streams,
|
||||||
IEnumerable<string> preferredLanguages,
|
List<string> preferredLanguages,
|
||||||
SubtitlePlaybackMode mode,
|
SubtitlePlaybackMode mode,
|
||||||
string audioTrackLanguage)
|
string audioTrackLanguage)
|
||||||
{
|
{
|
||||||
var languages = preferredLanguages.ToList();
|
streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages).ToList();
|
||||||
streams = GetSortedStreams(streams, MediaStreamType.Subtitle, languages).ToList();
|
|
||||||
|
|
||||||
var full = streams.Where(s => !s.IsForced);
|
var full = streams.Where(s => !s.IsForced);
|
||||||
var forced = streams.Where(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase));
|
|
||||||
|
|
||||||
MediaStream stream = null;
|
MediaStream stream = null;
|
||||||
|
|
||||||
@ -54,9 +52,9 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
if (mode == SubtitlePlaybackMode.Default)
|
if (mode == SubtitlePlaybackMode.Default)
|
||||||
{
|
{
|
||||||
// if the audio language is not understood by the user, load their preferred subs, if there are any
|
// if the audio language is not understood by the user, load their preferred subs, if there are any
|
||||||
if (!ContainsOrdinal(languages, audioTrackLanguage))
|
if (!ContainsOrdinal(preferredLanguages, audioTrackLanguage))
|
||||||
{
|
{
|
||||||
stream = full.FirstOrDefault(s => ContainsOrdinal(languages, s.Language));
|
stream = full.FirstOrDefault(s => ContainsOrdinal(preferredLanguages, s.Language));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == SubtitlePlaybackMode.Always)
|
else if (mode == SubtitlePlaybackMode.Always)
|
||||||
@ -66,7 +64,7 @@ namespace MediaBrowser.Controller.MediaEncoding
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load forced subs if we have found no suitable full subtitles
|
// load forced subs if we have found no suitable full subtitles
|
||||||
stream = stream ?? forced.FirstOrDefault();
|
stream = stream ?? streams.FirstOrDefault(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
{
|
{
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
|
|
||||||
namespace MediaBrowser.Controller.MediaEncoding
|
|
||||||
{
|
|
||||||
public class VideoEncodingOptions : EncodingOptions
|
|
||||||
{
|
|
||||||
public string VideoCodec { get; set; }
|
|
||||||
|
|
||||||
public string VideoProfile { get; set; }
|
|
||||||
|
|
||||||
public double? VideoLevel { get; set; }
|
|
||||||
|
|
||||||
public int? VideoStreamIndex { get; set; }
|
|
||||||
|
|
||||||
public int? AudioStreamIndex { get; set; }
|
|
||||||
|
|
||||||
public int? SubtitleStreamIndex { get; set; }
|
|
||||||
|
|
||||||
public int? MaxWidth { get; set; }
|
|
||||||
|
|
||||||
public int? MaxHeight { get; set; }
|
|
||||||
|
|
||||||
public int? Height { get; set; }
|
|
||||||
|
|
||||||
public int? Width { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -7,7 +8,7 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Controller.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts sending data over a web socket periodically when a message is received, and then stops when a corresponding stop message is received
|
/// Starts sending data over a web socket periodically when a message is received, and then stops when a corresponding stop message is received
|
@ -3,7 +3,7 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Controller.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface IWebSocket
|
/// Interface IWebSocket
|
@ -3,7 +3,7 @@ using System;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Controller.Net
|
||||||
{
|
{
|
||||||
public interface IWebSocketConnection : IDisposable
|
public interface IWebSocketConnection : IDisposable
|
||||||
{
|
{
|
@ -1,6 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using MediaBrowser.Common.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Controller.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///This is an interface for listening to messages coming through a web socket connection
|
///This is an interface for listening to messages coming through a web socket connection
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Controller.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class WebSocketConnectEventArgs
|
/// Class WebSocketConnectEventArgs
|
@ -1,6 +1,6 @@
|
|||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Controller.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class WebSocketMessageInfo
|
/// Class WebSocketMessageInfo
|
@ -46,6 +46,11 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
|
|
||||||
private Dictionary<string, FileSystemInfo> GetFileSystemDictionary(string path, bool clearCache)
|
private Dictionary<string, FileSystemInfo> GetFileSystemDictionary(string path, bool clearCache)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(path))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("path");
|
||||||
|
}
|
||||||
|
|
||||||
Dictionary<string, FileSystemInfo> entries;
|
Dictionary<string, FileSystemInfo> entries;
|
||||||
|
|
||||||
if (clearCache)
|
if (clearCache)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user