added dlna music folders
This commit is contained in:
parent
dd2798a3d6
commit
91ffff7771
|
@ -1,6 +1,5 @@
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Controller.Dlna;
|
using MediaBrowser.Controller.Dlna;
|
||||||
using MediaBrowser.Model.Configuration;
|
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
using ServiceStack.Text.Controller;
|
using ServiceStack.Text.Controller;
|
||||||
using ServiceStack.Web;
|
using ServiceStack.Web;
|
||||||
|
|
|
@ -788,7 +788,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
protected string GetInputArgument(string transcodingJobId, StreamState state)
|
protected string GetInputArgument(string transcodingJobId, StreamState state)
|
||||||
{
|
{
|
||||||
if (state.InputProtocol == MediaProtocol.File &&
|
if (SupportsThrottling && state.InputProtocol == MediaProtocol.File &&
|
||||||
state.RunTimeTicks.HasValue &&
|
state.RunTimeTicks.HasValue &&
|
||||||
state.VideoType == VideoType.VideoFile &&
|
state.VideoType == VideoType.VideoFile &&
|
||||||
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
|
@ -62,14 +62,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool SupportsThrottling
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the specified request.
|
/// Gets the specified request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace MediaBrowser.Common.Implementations.Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfigurationStore[] _configurationStores = {};
|
private ConfigurationStore[] _configurationStores = {};
|
||||||
private IConfigurationFactory[] _configurationFactories;
|
private IConfigurationFactory[] _configurationFactories = {};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseConfigurationManager" /> class.
|
/// Initializes a new instance of the <see cref="BaseConfigurationManager" /> class.
|
||||||
|
|
99
MediaBrowser.Common.Implementations/Devices/DeviceId.cs
Normal file
99
MediaBrowser.Common.Implementations/Devices/DeviceId.cs
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Implementations.Devices
|
||||||
|
{
|
||||||
|
public class DeviceId
|
||||||
|
{
|
||||||
|
private readonly IApplicationPaths _appPaths;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly object _syncLock = new object();
|
||||||
|
|
||||||
|
private string CachePath
|
||||||
|
{
|
||||||
|
get { return Path.Combine(_appPaths.DataPath, "device.txt"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCachedId()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (_syncLock)
|
||||||
|
{
|
||||||
|
var value = File.ReadAllText(CachePath, Encoding.UTF8);
|
||||||
|
|
||||||
|
Guid guid;
|
||||||
|
if (Guid.TryParse(value, out guid))
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.Error("Invalid value found in device id file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FileNotFoundException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error reading file", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveId(string id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = CachePath;
|
||||||
|
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||||
|
|
||||||
|
lock (_syncLock)
|
||||||
|
{
|
||||||
|
File.WriteAllText(path, id, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error writing to file", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetNewId()
|
||||||
|
{
|
||||||
|
return Guid.NewGuid().ToString("N");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetDeviceId()
|
||||||
|
{
|
||||||
|
var id = GetCachedId();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
id = GetNewId();
|
||||||
|
SaveId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _id;
|
||||||
|
|
||||||
|
public DeviceId(IApplicationPaths appPaths, ILogger logger)
|
||||||
|
{
|
||||||
|
_appPaths = appPaths;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get { return _id ?? (_id = GetDeviceId()); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -82,6 +82,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="Devices\DeviceId.cs" />
|
||||||
<Compile Include="HttpClientManager\HttpClientInfo.cs" />
|
<Compile Include="HttpClientManager\HttpClientInfo.cs" />
|
||||||
<Compile Include="HttpClientManager\HttpClientManager.cs" />
|
<Compile Include="HttpClientManager\HttpClientManager.cs" />
|
||||||
<Compile Include="IO\CommonFileSystem.cs" />
|
<Compile Include="IO\CommonFileSystem.cs" />
|
||||||
|
|
|
@ -12,5 +12,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||||
bool HasArtist(string name);
|
bool HasArtist(string name);
|
||||||
|
|
||||||
List<string> AllArtists { get; }
|
List<string> AllArtists { get; }
|
||||||
|
|
||||||
|
List<string> Artists { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,23 @@ namespace MediaBrowser.Controller.Entities
|
||||||
ProductionLocations = new List<string>();
|
ProductionLocations = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreDataMember]
|
||||||
|
public List<string> Artists
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var list = new List<string>();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Artist))
|
||||||
|
{
|
||||||
|
list.Add(Artist);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[IgnoreDataMember]
|
[IgnoreDataMember]
|
||||||
public List<string> AllArtists
|
public List<string> AllArtists
|
||||||
{
|
{
|
||||||
|
|
|
@ -171,6 +171,18 @@ namespace MediaBrowser.Controller.Entities
|
||||||
case CollectionType.MovieCollections:
|
case CollectionType.MovieCollections:
|
||||||
return GetMovieCollections(parent, user, query);
|
return GetMovieCollections(parent, user, query);
|
||||||
|
|
||||||
|
case CollectionType.MusicLatest:
|
||||||
|
return GetMusicLatest(parent, user, query);
|
||||||
|
|
||||||
|
case CollectionType.MusicAlbums:
|
||||||
|
return GetMusicAlbums(parent, user, query);
|
||||||
|
|
||||||
|
case CollectionType.MusicAlbumArtists:
|
||||||
|
return GetMusicAlbumArtists(parent, user, query);
|
||||||
|
|
||||||
|
case CollectionType.MusicArtists:
|
||||||
|
return GetMusicArtists(parent, user, query);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), query);
|
return GetResult(GetMediaFolders(user).SelectMany(i => i.GetChildren(user, true)), query);
|
||||||
}
|
}
|
||||||
|
@ -188,7 +200,78 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Music }), query);
|
return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Music }), query);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Music }).OfType<MusicArtist>(), query);
|
var list = new List<BaseItem>();
|
||||||
|
|
||||||
|
var category = "music";
|
||||||
|
|
||||||
|
list.Add(await GetUserView(category, CollectionType.MusicLatest, user, "0", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.MusicAlbums, user, "1", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.MusicAlbumArtists, user, "2", parent).ConfigureAwait(false));
|
||||||
|
//list.Add(await GetUserView(CollectionType.MusicArtists, user, "3", parent).ConfigureAwait(false));
|
||||||
|
//list.Add(await GetUserView(CollectionType.MusicGenres, user, "5", parent).ConfigureAwait(false));
|
||||||
|
|
||||||
|
return GetResult(list, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryResult<BaseItem> GetMusicAlbumArtists(Folder parent, User user, UserItemsQuery query)
|
||||||
|
{
|
||||||
|
var artists = GetRecursiveChildren(parent, user, new[] { CollectionType.Music })
|
||||||
|
.Where(i => !i.IsFolder)
|
||||||
|
.OfType<IHasAlbumArtist>()
|
||||||
|
.SelectMany(i => i.AlbumArtists)
|
||||||
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
|
.Select(i =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _libraryManager.GetArtist(i);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Already logged at lower levels
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Where(i => i != null);
|
||||||
|
|
||||||
|
return GetResult(artists, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryResult<BaseItem> GetMusicArtists(Folder parent, User user, UserItemsQuery query)
|
||||||
|
{
|
||||||
|
var artists = GetRecursiveChildren(parent, user, new[] { CollectionType.Music })
|
||||||
|
.Where(i => !i.IsFolder)
|
||||||
|
.OfType<IHasArtist>()
|
||||||
|
.SelectMany(i => i.Artists)
|
||||||
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
|
.Select(i =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _libraryManager.GetArtist(i);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Already logged at lower levels
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.Where(i => i != null);
|
||||||
|
|
||||||
|
return GetResult(artists, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryResult<BaseItem> GetMusicAlbums(Folder parent, User user, UserItemsQuery query)
|
||||||
|
{
|
||||||
|
return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Music }).Where(i => i is MusicAlbum), query);
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryResult<BaseItem> GetMusicLatest(Folder parent, User user, UserItemsQuery query)
|
||||||
|
{
|
||||||
|
query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName };
|
||||||
|
query.SortOrder = SortOrder.Descending;
|
||||||
|
|
||||||
|
return GetResult(GetRecursiveChildren(parent, user, new[] { CollectionType.Music }).Where(i => i is MusicVideo || i is Audio.Audio), GetSpecialItemsLimit(), query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<QueryResult<BaseItem>> GetMovieFolders(Folder parent, User user, UserItemsQuery query)
|
private async Task<QueryResult<BaseItem>> GetMovieFolders(Folder parent, User user, UserItemsQuery query)
|
||||||
|
@ -200,11 +283,13 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
var list = new List<BaseItem>();
|
var list = new List<BaseItem>();
|
||||||
|
|
||||||
list.Add(await GetUserView(CollectionType.MovieResume, user, "0", parent).ConfigureAwait(false));
|
var category = "movies";
|
||||||
list.Add(await GetUserView(CollectionType.MovieLatest, user, "1", parent).ConfigureAwait(false));
|
|
||||||
list.Add(await GetUserView(CollectionType.MovieMovies, user, "2", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.MovieResume, user, "0", parent).ConfigureAwait(false));
|
||||||
list.Add(await GetUserView(CollectionType.MovieCollections, user, "3", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.MovieLatest, user, "1", parent).ConfigureAwait(false));
|
||||||
list.Add(await GetUserView(CollectionType.MovieFavorites, user, "4", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.MovieMovies, user, "2", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.MovieCollections, user, "3", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.MovieFavorites, user, "4", parent).ConfigureAwait(false));
|
||||||
//list.Add(await GetUserView(CollectionType.MovieGenres, user, "5", parent).ConfigureAwait(false));
|
//list.Add(await GetUserView(CollectionType.MovieGenres, user, "5", parent).ConfigureAwait(false));
|
||||||
|
|
||||||
return GetResult(list, query);
|
return GetResult(list, query);
|
||||||
|
@ -278,10 +363,12 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
var list = new List<BaseItem>();
|
var list = new List<BaseItem>();
|
||||||
|
|
||||||
list.Add(await GetUserView(CollectionType.TvResume, user, "0", parent).ConfigureAwait(false));
|
var category = "tv";
|
||||||
list.Add(await GetUserView(CollectionType.TvNextUp, user, "1", parent).ConfigureAwait(false));
|
|
||||||
list.Add(await GetUserView(CollectionType.TvLatest, user, "2", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.TvResume, user, "0", parent).ConfigureAwait(false));
|
||||||
list.Add(await GetUserView(CollectionType.TvSeries, user, "3", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.TvNextUp, user, "1", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.TvLatest, user, "2", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.TvSeries, user, "3", parent).ConfigureAwait(false));
|
||||||
//list.Add(await GetUserView(CollectionType.TvFavorites, user, "4", parent).ConfigureAwait(false));
|
//list.Add(await GetUserView(CollectionType.TvFavorites, user, "4", parent).ConfigureAwait(false));
|
||||||
//list.Add(await GetUserView(CollectionType.TvGenres, user, "5", parent).ConfigureAwait(false));
|
//list.Add(await GetUserView(CollectionType.TvGenres, user, "5", parent).ConfigureAwait(false));
|
||||||
|
|
||||||
|
@ -297,10 +384,12 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
var list = new List<BaseItem>();
|
var list = new List<BaseItem>();
|
||||||
|
|
||||||
list.Add(await GetUserView(CollectionType.LatestGames, user, "0", parent).ConfigureAwait(false));
|
var category = "games";
|
||||||
list.Add(await GetUserView(CollectionType.RecentlyPlayedGames, user, "1", parent).ConfigureAwait(false));
|
|
||||||
list.Add(await GetUserView(CollectionType.GameFavorites, user, "2", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.LatestGames, user, "0", parent).ConfigureAwait(false));
|
||||||
list.Add(await GetUserView(CollectionType.GameSystems, user, "3", parent).ConfigureAwait(false));
|
list.Add(await GetUserView(category, CollectionType.RecentlyPlayedGames, user, "1", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.GameFavorites, user, "2", parent).ConfigureAwait(false));
|
||||||
|
list.Add(await GetUserView(category, CollectionType.GameSystems, user, "3", parent).ConfigureAwait(false));
|
||||||
//list.Add(await GetUserView(CollectionType.GameGenres, user, "4", parent).ConfigureAwait(false));
|
//list.Add(await GetUserView(CollectionType.GameGenres, user, "4", parent).ConfigureAwait(false));
|
||||||
|
|
||||||
return GetResult(list, query);
|
return GetResult(list, query);
|
||||||
|
@ -589,16 +678,16 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
var list = new List<BaseItem>();
|
var list = new List<BaseItem>();
|
||||||
|
|
||||||
list.Add(await _userViewManager.GetUserView(CollectionType.LiveTvNowPlaying, user, "0", CancellationToken.None).ConfigureAwait(false));
|
list.Add(await _userViewManager.GetUserView("livetv", CollectionType.LiveTvNowPlaying, user, "0", CancellationToken.None).ConfigureAwait(false));
|
||||||
list.Add(await _userViewManager.GetUserView(CollectionType.LiveTvChannels, user, string.Empty, CancellationToken.None).ConfigureAwait(false));
|
list.Add(await _userViewManager.GetUserView("livetv", CollectionType.LiveTvChannels, user, string.Empty, CancellationToken.None).ConfigureAwait(false));
|
||||||
list.Add(await _userViewManager.GetUserView(CollectionType.LiveTvRecordingGroups, user, string.Empty, CancellationToken.None).ConfigureAwait(false));
|
list.Add(await _userViewManager.GetUserView("livetv", CollectionType.LiveTvRecordingGroups, user, string.Empty, CancellationToken.None).ConfigureAwait(false));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<UserView> GetUserView(string type, User user, string sortName, Folder parent)
|
private async Task<UserView> GetUserView(string category, string type, User user, string sortName, Folder parent)
|
||||||
{
|
{
|
||||||
var view = await _userViewManager.GetUserView(type, user, sortName, CancellationToken.None)
|
var view = await _userViewManager.GetUserView(category, type, user, sortName, CancellationToken.None)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (parent.Id != view.ParentId)
|
if (parent.Id != view.ParentId)
|
||||||
|
|
|
@ -336,10 +336,21 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// Gets the named folder.
|
/// Gets the named folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="category">The category.</param>
|
||||||
/// <param name="viewType">Type of the view.</param>
|
/// <param name="viewType">Type of the view.</param>
|
||||||
/// <param name="sortName">Name of the sort.</param>
|
/// <param name="sortName">Name of the sort.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{Folder}.</returns>
|
/// <returns>Task{Folder}.</returns>
|
||||||
|
Task<UserView> GetNamedView(string name, string category, string viewType, string sortName, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the named view.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="viewType">Type of the view.</param>
|
||||||
|
/// <param name="sortName">Name of the sort.</param>
|
||||||
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
|
/// <returns>Task<UserView>.</returns>
|
||||||
Task<UserView> GetNamedView(string name, string viewType, string sortName, CancellationToken cancellationToken);
|
Task<UserView> GetNamedView(string name, string viewType, string sortName, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,5 +11,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken);
|
Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken);
|
||||||
|
|
||||||
Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken);
|
Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken);
|
||||||
|
|
||||||
|
Task<UserView> GetUserView(string category, string type, User user, string sortName, CancellationToken cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.FileOrganization;
|
using MediaBrowser.Model.FileOrganization;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
using MediaBrowser.Model.Notifications;
|
|
||||||
using MediaBrowser.Model.Providers;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Configuration
|
namespace MediaBrowser.Model.Configuration
|
||||||
{
|
{
|
||||||
|
@ -178,9 +176,10 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
public bool DefaultMetadataSettingsApplied { get; set; }
|
public bool DefaultMetadataSettingsApplied { get; set; }
|
||||||
|
|
||||||
public bool EnableTokenAuthentication { get; set; }
|
|
||||||
public PeopleMetadataOptions PeopleMetadataOptions { get; set; }
|
public PeopleMetadataOptions PeopleMetadataOptions { get; set; }
|
||||||
|
|
||||||
|
public string[] SecureApps { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -225,6 +224,17 @@ namespace MediaBrowser.Model.Configuration
|
||||||
|
|
||||||
PeopleMetadataOptions = new PeopleMetadataOptions();
|
PeopleMetadataOptions = new PeopleMetadataOptions();
|
||||||
|
|
||||||
|
SecureApps = new[]
|
||||||
|
{
|
||||||
|
"Dashboard",
|
||||||
|
"Chrome Companion",
|
||||||
|
"MBKinect",
|
||||||
|
"NuVue",
|
||||||
|
"Media Browser Theater",
|
||||||
|
|
||||||
|
//"MB-Classic"
|
||||||
|
};
|
||||||
|
|
||||||
MetadataOptions = new[]
|
MetadataOptions = new[]
|
||||||
{
|
{
|
||||||
new MetadataOptions(1, 1280) {ItemType = "Book"},
|
new MetadataOptions(1, 1280) {ItemType = "Book"},
|
||||||
|
|
|
@ -49,5 +49,11 @@
|
||||||
public const string GameSystems = "GameSystems";
|
public const string GameSystems = "GameSystems";
|
||||||
public const string GameGenres = "GameGenres";
|
public const string GameGenres = "GameGenres";
|
||||||
public const string GameFavorites = "GameFavorites";
|
public const string GameFavorites = "GameFavorites";
|
||||||
|
|
||||||
|
public const string MusicArtists = "MusicArtists";
|
||||||
|
public const string MusicAlbumArtists = "MusicAlbumArtists";
|
||||||
|
public const string MusicAlbums = "MusicAlbums";
|
||||||
|
public const string MusicGenres = "MusicGenres";
|
||||||
|
public const string MusicLatest = "MusicLatest";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,17 +53,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
ValidateUser(req, allowLocal);
|
ValidateUser(req, allowLocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove this when all clients have supported the new sescurity
|
|
||||||
private readonly List<string> _updatedClients = new List<string>() { "Dashboard", "Chromecast" };
|
|
||||||
|
|
||||||
private void ValidateUser(IRequest req, bool allowLocal)
|
private void ValidateUser(IRequest req, bool allowLocal)
|
||||||
{
|
{
|
||||||
//This code is executed before the service
|
//This code is executed before the service
|
||||||
var auth = AuthorizationContext.GetAuthorizationInfo(req);
|
var auth = AuthorizationContext.GetAuthorizationInfo(req);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(auth.Token)
|
if (!string.IsNullOrWhiteSpace(auth.Token)
|
||||||
|| _config.Configuration.EnableTokenAuthentication
|
|| _config.Configuration.SecureApps.Contains(auth.Client ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||||
|| _updatedClients.Contains(auth.Client ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
if (!allowLocal || !req.IsLocal)
|
if (!allowLocal || !req.IsLocal)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="httpReq">The HTTP req.</param>
|
/// <param name="httpReq">The HTTP req.</param>
|
||||||
/// <returns>Dictionary{System.StringSystem.String}.</returns>
|
/// <returns>Dictionary{System.StringSystem.String}.</returns>
|
||||||
private static AuthorizationInfo GetAuthorization(IRequest httpReq)
|
private AuthorizationInfo GetAuthorization(IRequest httpReq)
|
||||||
{
|
{
|
||||||
var auth = GetAuthorizationDictionary(httpReq);
|
var auth = GetAuthorizationDictionary(httpReq);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="httpReq">The HTTP req.</param>
|
/// <param name="httpReq">The HTTP req.</param>
|
||||||
/// <returns>Dictionary{System.StringSystem.String}.</returns>
|
/// <returns>Dictionary{System.StringSystem.String}.</returns>
|
||||||
private static Dictionary<string, string> GetAuthorizationDictionary(IRequest httpReq)
|
private Dictionary<string, string> GetAuthorizationDictionary(IRequest httpReq)
|
||||||
{
|
{
|
||||||
var auth = httpReq.Headers["Authorization"];
|
var auth = httpReq.Headers["Authorization"];
|
||||||
|
|
||||||
|
@ -71,14 +71,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="authorizationHeader">The authorization header.</param>
|
/// <param name="authorizationHeader">The authorization header.</param>
|
||||||
/// <returns>Dictionary{System.StringSystem.String}.</returns>
|
/// <returns>Dictionary{System.StringSystem.String}.</returns>
|
||||||
private static Dictionary<string, string> GetAuthorization(string authorizationHeader)
|
private Dictionary<string, string> GetAuthorization(string authorizationHeader)
|
||||||
{
|
{
|
||||||
if (authorizationHeader == null) return null;
|
if (authorizationHeader == null) return null;
|
||||||
|
|
||||||
var parts = authorizationHeader.Split(' ');
|
var parts = authorizationHeader.Split(new[] { ' ' }, 2);
|
||||||
|
|
||||||
// There should be at least to parts
|
// There should be at least to parts
|
||||||
if (parts.Length < 2) return null;
|
if (parts.Length != 2) return null;
|
||||||
|
|
||||||
// It has to be a digest request
|
// It has to be a digest request
|
||||||
if (!string.Equals(parts[0], "MediaBrowser", StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(parts[0], "MediaBrowser", StringComparison.OrdinalIgnoreCase))
|
||||||
|
@ -87,7 +87,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove uptil the first space
|
// Remove uptil the first space
|
||||||
authorizationHeader = authorizationHeader.Substring(authorizationHeader.IndexOf(' '));
|
authorizationHeader = parts[1];
|
||||||
parts = authorizationHeader.Split(',');
|
parts = authorizationHeader.Split(',');
|
||||||
|
|
||||||
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
@ -95,7 +95,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
|
||||||
foreach (var item in parts)
|
foreach (var item in parts)
|
||||||
{
|
{
|
||||||
var param = item.Trim().Split(new[] { '=' }, 2);
|
var param = item.Trim().Split(new[] { '=' }, 2);
|
||||||
result.Add(param[0], param[1].Trim(new[] { '"' }));
|
|
||||||
|
if (param.Length == 2)
|
||||||
|
{
|
||||||
|
result.Add(param[0], param[1].Trim(new[] { '"' }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1484,11 +1484,22 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<UserView> GetNamedView(string name, string type, string sortName, CancellationToken cancellationToken)
|
public Task<UserView> GetNamedView(string name, string type, string sortName, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
return GetNamedView(name, null, type, sortName, cancellationToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<UserView> GetNamedView(string name, string category, string type, string sortName, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
|
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
|
||||||
"views",
|
"views");
|
||||||
_fileSystem.GetValidFilename(type));
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(category))
|
||||||
|
{
|
||||||
|
path = Path.Combine(path, _fileSystem.GetValidFilename(category));
|
||||||
|
}
|
||||||
|
|
||||||
|
path = Path.Combine(path, _fileSystem.GetValidFilename(type));
|
||||||
|
|
||||||
var id = (path + "_namedview_" + name).GetMBId(typeof(UserView));
|
var id = (path + "_namedview_" + name).GetMBId(typeof(UserView));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -16,7 +15,6 @@ using MediaBrowser.Model.Library;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -148,43 +146,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
.ThenBy(i => i.SortName);
|
.ThenBy(i => i.SortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
|
public Task<UserView> GetUserView(string category, string type, User user, string sortName, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var name = _localizationManager.GetLocalizedString("ViewType" + type);
|
var name = _localizationManager.GetLocalizedString("ViewType" + type);
|
||||||
|
|
||||||
return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
|
return _libraryManager.GetNamedView(name, category, type, sortName, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SpecialFolder> GetSpecialFolder(string name, SpecialFolderType type, string itemType, CancellationToken cancellationToken)
|
public Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(_appPaths.ItemsByNamePath,
|
return GetUserView(null, type, user, sortName, cancellationToken);
|
||||||
"specialfolders",
|
|
||||||
_fileSystem.GetValidFilename(name));
|
|
||||||
|
|
||||||
var id = (path + "_specialfolder_" + name).GetMBId(typeof(SpecialFolder));
|
|
||||||
|
|
||||||
var item = _libraryManager.GetItemById(id) as SpecialFolder;
|
|
||||||
|
|
||||||
if (item == null)
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
|
||||||
|
|
||||||
item = new SpecialFolder
|
|
||||||
{
|
|
||||||
Path = path,
|
|
||||||
Id = id,
|
|
||||||
DateCreated = DateTime.UtcNow,
|
|
||||||
Name = name,
|
|
||||||
SpecialFolderType = type,
|
|
||||||
ItemTypeName = itemType
|
|
||||||
};
|
|
||||||
|
|
||||||
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
await item.RefreshMetadata(cancellationToken).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -859,6 +859,9 @@
|
||||||
"ViewTypeMovieCollections": "Collections",
|
"ViewTypeMovieCollections": "Collections",
|
||||||
"ViewTypeMovieFavorites": "Favorites",
|
"ViewTypeMovieFavorites": "Favorites",
|
||||||
"ViewTypeMovieGenres": "Genres",
|
"ViewTypeMovieGenres": "Genres",
|
||||||
|
"ViewTypeMusicLatest": "Latest",
|
||||||
|
"ViewTypeMusicAlbums": "Albums",
|
||||||
|
"ViewTypeMusicAlbumArtists": "Album Artists",
|
||||||
"HeaderOtherDisplaySettings": "Display Settings",
|
"HeaderOtherDisplaySettings": "Display Settings",
|
||||||
"HeaderMyViews": "My Views",
|
"HeaderMyViews": "My Views",
|
||||||
"LabelSelectFolderGroups": "Automatically group content from the following folders into views such as Movies, Music and TV:",
|
"LabelSelectFolderGroups": "Automatically group content from the following folders into views such as Movies, Music and TV:",
|
||||||
|
@ -1109,12 +1112,14 @@
|
||||||
"HeaderMetadataSettings": "Metadata Settings",
|
"HeaderMetadataSettings": "Metadata Settings",
|
||||||
"LabelLockItemToPreventChanges": "Lock this item to prevent future changes",
|
"LabelLockItemToPreventChanges": "Lock this item to prevent future changes",
|
||||||
"MessageLeaveEmptyToInherit": "Leave empty to inherit settings from a parent item, or the global default value.",
|
"MessageLeaveEmptyToInherit": "Leave empty to inherit settings from a parent item, or the global default value.",
|
||||||
"TabSupporterClub": "Supporter Club",
|
"TabDonate": "Donate",
|
||||||
"HeaderDonationType": "Donation type:",
|
"HeaderDonationType": "Donation type:",
|
||||||
"OptionMakeOneTimeDonation": "Make a separate donation",
|
"OptionMakeOneTimeDonation": "Make a separate donation",
|
||||||
"OptionOneTimeDescription": "This is an additional donation to the team to show your support. It does not have any additional benefits.",
|
"OptionOneTimeDescription": "This is an additional donation to the team to show your support. It does not have any additional benefits.",
|
||||||
"OptionLifeTimeSupporterClubMembership": "Lifetime supporter club membership",
|
"OptionLifeTimeSupporterMembership": "Lifetime supporter membership",
|
||||||
"HeaderSupporterBenefit": "Becoming a supporter club member provides additional benefits such as access to premium plugins, internet channel content, and more.",
|
"OptionYearlySupporterMembership": "Yearly supporter membership",
|
||||||
|
"OptionMonthlySupporterMembership": "Monthly supporter membership",
|
||||||
|
"HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more.",
|
||||||
"OptionNoTrailer": "No Trailer",
|
"OptionNoTrailer": "No Trailer",
|
||||||
"OptionNoThemeSong": "No Theme Song",
|
"OptionNoThemeSong": "No Theme Song",
|
||||||
"OptionNoThemeVideo": "No Theme Video",
|
"OptionNoThemeVideo": "No Theme Video",
|
||||||
|
|
|
@ -4,6 +4,7 @@ using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Events;
|
using MediaBrowser.Common.Events;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Implementations;
|
using MediaBrowser.Common.Implementations;
|
||||||
|
using MediaBrowser.Common.Implementations.Devices;
|
||||||
using MediaBrowser.Common.Implementations.ScheduledTasks;
|
using MediaBrowser.Common.Implementations.ScheduledTasks;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
@ -903,11 +904,18 @@ namespace MediaBrowser.ServerApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly string _systemId = Environment.MachineName.GetMD5().ToString();
|
private DeviceId _serverId;
|
||||||
|
|
||||||
public string ServerId
|
public string ServerId
|
||||||
{
|
{
|
||||||
get { return _systemId; }
|
get
|
||||||
|
{
|
||||||
|
if (_serverId == null)
|
||||||
|
{
|
||||||
|
_serverId = new DeviceId(ApplicationPaths, LogManager.GetLogger("ServerId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _serverId.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user