mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-26 12:05:04 +01:00
update user views
This commit is contained in:
@@ -1407,9 +1407,8 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
public async Task<Folder> GetInternalChannelFolder(string userId, CancellationToken cancellationToken)
|
||||
{
|
||||
var name = _localization.GetLocalizedString("ViewTypeChannels");
|
||||
var user = _userManager.GetUserById(userId);
|
||||
|
||||
return await _libraryManager.GetNamedView(user, name, "channels", "zz_" + name, cancellationToken).ConfigureAwait(false);
|
||||
return await _libraryManager.GetNamedView(name, "channels", "zz_" + name, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task DownloadChannelItem(IChannelMediaItem item, string destination,
|
||||
|
||||
@@ -1651,7 +1651,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);
|
||||
|
||||
public async Task<UserView> GetNamedView(User user,
|
||||
public Task<UserView> GetNamedView(User user,
|
||||
string name,
|
||||
string viewType,
|
||||
string sortName,
|
||||
@@ -1659,10 +1659,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
if (ConfigurationManager.Configuration.EnableUserSpecificUserViews)
|
||||
{
|
||||
return await GetNamedViewInternal(user, name, null, viewType, sortName, null, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
return GetNamedViewInternal(user, name, null, viewType, sortName, null, cancellationToken);
|
||||
}
|
||||
|
||||
return GetNamedView(name, viewType, sortName, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<UserView> GetNamedView(string name,
|
||||
string viewType,
|
||||
string sortName,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
|
||||
"views");
|
||||
|
||||
@@ -1806,6 +1813,76 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<UserView> GetNamedView(string name,
|
||||
string parentId,
|
||||
string viewType,
|
||||
string sortName,
|
||||
string uniqueId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
|
||||
var idValues = "37_namedview_" + name + (parentId ?? string.Empty);
|
||||
if (!string.IsNullOrWhiteSpace(uniqueId))
|
||||
{
|
||||
idValues += uniqueId;
|
||||
}
|
||||
|
||||
var id = GetNewItemId(idValues, typeof(UserView));
|
||||
|
||||
var path = Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "views", id.ToString("N"));
|
||||
|
||||
var item = GetItemById(id) as UserView;
|
||||
|
||||
var isNew = false;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
item = new UserView
|
||||
{
|
||||
Path = path,
|
||||
Id = id,
|
||||
DateCreated = DateTime.UtcNow,
|
||||
Name = name,
|
||||
ViewType = viewType,
|
||||
ForcedSortName = sortName
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(parentId))
|
||||
{
|
||||
item.ParentId = new Guid(parentId);
|
||||
}
|
||||
|
||||
await CreateItem(item, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
if (!string.Equals(viewType, item.ViewType, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.ViewType = viewType;
|
||||
await item.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var refresh = isNew || (DateTime.UtcNow - item.DateLastSaved) >= _viewRefreshInterval;
|
||||
|
||||
if (refresh)
|
||||
{
|
||||
_providerManagerFactory().QueueRefresh(item.Id, new MetadataRefreshOptions
|
||||
{
|
||||
// Need to force save to increment DateLastSaved
|
||||
ForceSave = true
|
||||
});
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public bool IsVideoFile(string path)
|
||||
{
|
||||
var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger());
|
||||
|
||||
@@ -167,8 +167,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
if (_liveTvManager.GetEnabledUsers().Select(i => i.Id.ToString("N")).Contains(query.UserId))
|
||||
{
|
||||
//list.Add(await _liveTvManager.GetInternalLiveTvFolder(query.UserId, cancellationToken).ConfigureAwait(false));
|
||||
list.Add(await GetUserView(new List<ICollectionFolder>(), list, CollectionType.LiveTv, string.Empty, user, cancellationToken).ConfigureAwait(false));
|
||||
var name = _localizationManager.GetLocalizedString("ViewType" + CollectionType.LiveTv);
|
||||
list.Add(await _libraryManager.GetNamedView(name, CollectionType.LiveTv, string.Empty, cancellationToken).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,18 +187,18 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
.ThenBy(i => i.SortName);
|
||||
}
|
||||
|
||||
public Task<UserView> GetUserSubView(string name, string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
|
||||
public Task<UserView> GetUserSubView(string name, string parentId, string type, string sortName, CancellationToken cancellationToken)
|
||||
{
|
||||
var uniqueId = parentId + "subview" + type;
|
||||
|
||||
return _libraryManager.GetNamedView(user, name, parentId, type, sortName, uniqueId, cancellationToken);
|
||||
return _libraryManager.GetNamedView(name, parentId, type, sortName, uniqueId, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<UserView> GetUserSubView(string parentId, string type, User user, string sortName, CancellationToken cancellationToken)
|
||||
public Task<UserView> GetUserSubView(string parentId, string type, string sortName, CancellationToken cancellationToken)
|
||||
{
|
||||
var name = _localizationManager.GetLocalizedString("ViewType" + type);
|
||||
|
||||
return GetUserSubView(name, parentId, type, user, sortName, cancellationToken);
|
||||
return GetUserSubView(name, parentId, type, sortName, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<UserView> GetUserView(List<ICollectionFolder> parents, List<Folder> currentViews, string viewType, string sortName, User user, CancellationToken cancellationToken)
|
||||
|
||||
@@ -2204,8 +2204,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
public async Task<Folder> GetInternalLiveTvFolder(string userId, CancellationToken cancellationToken)
|
||||
{
|
||||
var name = _localization.GetLocalizedString("ViewTypeLiveTV");
|
||||
var user = _userManager.GetUserById(userId);
|
||||
return await _libraryManager.GetNamedView(user, name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false);
|
||||
return await _libraryManager.GetNamedView(name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info)
|
||||
|
||||
Reference in New Issue
Block a user