mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-03 19:17:24 -05:00 
			
		
		
		
	update user views
This commit is contained in:
		
							parent
							
								
									ec5619e0f9
								
							
						
					
					
						commit
						032891c9f3
					
				@ -285,14 +285,14 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            var list = new List<BaseItem>();
 | 
					            var list = new List<BaseItem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicLatest, user, "0", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicLatest, "0", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicPlaylists, user, "1", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicPlaylists, "1", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicAlbums, user, "2", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicAlbums, "2", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicAlbumArtists, user, "3", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicAlbumArtists, "3", parent).ConfigureAwait(false));
 | 
				
			||||||
            //list.Add(await GetUserView(SpecialFolder.MusicArtists, user, "4", parent).ConfigureAwait(false));
 | 
					            //list.Add(await GetUserView(SpecialFolder.MusicArtists, user, "4", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicSongs, user, "5", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicSongs, "5", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicGenres, user, "6", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicGenres, "6", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicFavorites, user, "7", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicFavorites, "7", parent).ConfigureAwait(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return GetResult(list, parent, query);
 | 
					            return GetResult(list, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -301,9 +301,9 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            var list = new List<BaseItem>();
 | 
					            var list = new List<BaseItem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicFavoriteAlbums, user, "0", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicFavoriteAlbums, "0", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicFavoriteArtists, user, "1", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicFavoriteArtists, "1", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MusicFavoriteSongs, user, "2", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MusicFavoriteSongs, "2", parent).ConfigureAwait(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return GetResult(list, parent, query);
 | 
					            return GetResult(list, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -329,7 +329,7 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .Where(i => i != null)
 | 
					                .Where(i => i != null)
 | 
				
			||||||
                .Select(i => GetUserView(i.Name, SpecialFolder.MusicGenre, user, i.SortName, parent));
 | 
					                .Select(i => GetUserView(i.Name, SpecialFolder.MusicGenre, i.SortName, parent));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
					            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -366,7 +366,7 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
                .OfType<IHasArtist>();
 | 
					                .OfType<IHasArtist>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var artists = _libraryManager.GetArtists(items);
 | 
					            var artists = _libraryManager.GetArtists(items);
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
            return GetResult(artists, parent, query);
 | 
					            return GetResult(artists, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -377,7 +377,7 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
                .OfType<IHasAlbumArtist>();
 | 
					                .OfType<IHasAlbumArtist>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var artists = _libraryManager.GetAlbumArtists(items).Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite);
 | 
					            var artists = _libraryManager.GetAlbumArtists(items).Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite);
 | 
				
			||||||
            
 | 
					
 | 
				
			||||||
            return GetResult(artists, parent, query);
 | 
					            return GetResult(artists, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -443,12 +443,12 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            var list = new List<BaseItem>();
 | 
					            var list = new List<BaseItem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MovieResume, user, "0", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MovieResume, "0", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MovieLatest, user, "1", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MovieLatest, "1", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MovieMovies, user, "2", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MovieMovies, "2", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MovieCollections, user, "3", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MovieCollections, "3", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MovieFavorites, user, "4", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MovieFavorites, "4", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.MovieGenres, user, "5", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.MovieGenres, "5", parent).ConfigureAwait(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return GetResult(list, parent, query);
 | 
					            return GetResult(list, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -554,7 +554,7 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .Where(i => i != null)
 | 
					                .Where(i => i != null)
 | 
				
			||||||
                .Select(i => GetUserView(i.Name, SpecialFolder.MovieGenre, user, i.SortName, parent));
 | 
					                .Select(i => GetUserView(i.Name, SpecialFolder.MovieGenre, i.SortName, parent));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
					            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -616,13 +616,13 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            var list = new List<BaseItem>();
 | 
					            var list = new List<BaseItem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvResume, user, "0", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvResume, "0", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvNextUp, user, "1", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvNextUp, "1", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvLatest, user, "2", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvLatest, "2", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvShowSeries, user, "3", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvShowSeries, "3", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvFavoriteSeries, user, "4", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvFavoriteSeries, "4", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvFavoriteEpisodes, user, "5", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvFavoriteEpisodes, "5", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.TvGenres, user, "6", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.TvGenres, "6", parent).ConfigureAwait(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return GetResult(list, parent, query);
 | 
					            return GetResult(list, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -637,11 +637,11 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            var list = new List<BaseItem>();
 | 
					            var list = new List<BaseItem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.LatestGames, user, "0", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.LatestGames, "0", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.RecentlyPlayedGames, user, "1", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.RecentlyPlayedGames, "1", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.GameFavorites, user, "2", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.GameFavorites, "2", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.GameSystems, user, "3", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.GameSystems, "3", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.GameGenres, user, "4", parent).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.GameGenres, "4", parent).ConfigureAwait(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return GetResult(list, parent, query);
 | 
					            return GetResult(list, parent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -739,7 +739,7 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .Where(i => i != null)
 | 
					                .Where(i => i != null)
 | 
				
			||||||
                .Select(i => GetUserView(i.Name, SpecialFolder.TvGenre, user, i.SortName, parent));
 | 
					                .Select(i => GetUserView(i.Name, SpecialFolder.TvGenre, i.SortName, parent));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
					            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -791,7 +791,7 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
                .Where(i => i != null)
 | 
					                .Where(i => i != null)
 | 
				
			||||||
                .Select(i => GetUserView(i.Name, SpecialFolder.GameGenre, user, i.SortName, parent));
 | 
					                .Select(i => GetUserView(i.Name, SpecialFolder.GameGenre, i.SortName, parent));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
					            var genres = await Task.WhenAll(tasks).ConfigureAwait(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1871,26 +1871,20 @@ namespace MediaBrowser.Controller.Entities
 | 
				
			|||||||
            var list = new List<BaseItem>();
 | 
					            var list = new List<BaseItem>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //list.Add(await GetUserSubView(SpecialFolder.LiveTvNowPlaying, user, "0", parent).ConfigureAwait(false));
 | 
					            //list.Add(await GetUserSubView(SpecialFolder.LiveTvNowPlaying, user, "0", parent).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.LiveTvChannels, user, string.Empty, user.RootFolder).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.LiveTvChannels, string.Empty, user.RootFolder).ConfigureAwait(false));
 | 
				
			||||||
            list.Add(await GetUserView(SpecialFolder.LiveTvRecordingGroups, user, string.Empty, user.RootFolder).ConfigureAwait(false));
 | 
					            list.Add(await GetUserView(SpecialFolder.LiveTvRecordingGroups, string.Empty, user.RootFolder).ConfigureAwait(false));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return GetResult(list, queryParent, query);
 | 
					            return GetResult(list, queryParent, query);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private async Task<UserView> GetUserView(string name, string type, User user, string sortName, BaseItem parent)
 | 
					        private Task<UserView> GetUserView(string name, string type, string sortName, BaseItem parent)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var view = await _userViewManager.GetUserSubView(name, parent.Id.ToString("N"), type, user, sortName, CancellationToken.None)
 | 
					            return _userViewManager.GetUserSubView(name, parent.Id.ToString("N"), type, sortName, CancellationToken.None);
 | 
				
			||||||
                        .ConfigureAwait(false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return view;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        private async Task<UserView> GetUserView(string type, User user, string sortName, BaseItem parent)
 | 
					        private Task<UserView> GetUserView(string type, string sortName, BaseItem parent)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var view = await _userViewManager.GetUserSubView(parent.Id.ToString("N"), type, user, sortName, CancellationToken.None)
 | 
					            return _userViewManager.GetUserSubView(parent.Id.ToString("N"), type, sortName, CancellationToken.None);
 | 
				
			||||||
                        .ConfigureAwait(false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return view;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static bool IsYearMismatched(BaseItem item, ILibraryManager libraryManager)
 | 
					        public static bool IsYearMismatched(BaseItem item, ILibraryManager libraryManager)
 | 
				
			||||||
 | 
				
			|||||||
@ -351,7 +351,37 @@ namespace MediaBrowser.Controller.Library
 | 
				
			|||||||
        Task<UserView> GetNamedView(User user,
 | 
					        Task<UserView> GetNamedView(User user,
 | 
				
			||||||
            string name, 
 | 
					            string name, 
 | 
				
			||||||
            string viewType, 
 | 
					            string viewType, 
 | 
				
			||||||
            string sortName, 
 | 
					            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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /// <summary>
 | 
				
			||||||
 | 
					        /// Gets the named view.
 | 
				
			||||||
 | 
					        /// </summary>
 | 
				
			||||||
 | 
					        /// <param name="name">The name.</param>
 | 
				
			||||||
 | 
					        /// <param name="parentId">The parent identifier.</param>
 | 
				
			||||||
 | 
					        /// <param name="viewType">Type of the view.</param>
 | 
				
			||||||
 | 
					        /// <param name="sortName">Name of the sort.</param>
 | 
				
			||||||
 | 
					        /// <param name="uniqueId">The unique identifier.</param>
 | 
				
			||||||
 | 
					        /// <param name="cancellationToken">The cancellation token.</param>
 | 
				
			||||||
 | 
					        /// <returns>Task<UserView>.</returns>
 | 
				
			||||||
 | 
					        Task<UserView> GetNamedView(string name,
 | 
				
			||||||
 | 
					            string parentId,
 | 
				
			||||||
 | 
					            string viewType,
 | 
				
			||||||
 | 
					            string sortName,
 | 
				
			||||||
 | 
					            string uniqueId,
 | 
				
			||||||
            CancellationToken cancellationToken);
 | 
					            CancellationToken cancellationToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /// <summary>
 | 
					        /// <summary>
 | 
				
			||||||
 | 
				
			|||||||
@ -12,10 +12,9 @@ namespace MediaBrowser.Controller.Library
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken);
 | 
					        Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Task<UserView> GetUserSubView(string name, string parentId, string type, User user, string sortName,
 | 
					        Task<UserView> GetUserSubView(string name, string parentId, string type, string sortName, CancellationToken cancellationToken);
 | 
				
			||||||
            CancellationToken cancellationToken);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Task<UserView> GetUserSubView(string category, string type, User user, string sortName, CancellationToken cancellationToken);
 | 
					        Task<UserView> GetUserSubView(string category, string type, string sortName, CancellationToken cancellationToken);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request);
 | 
					        List<Tuple<BaseItem, List<BaseItem>>> GetLatestItems(LatestItemsQuery request);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1407,9 +1407,8 @@ namespace MediaBrowser.Server.Implementations.Channels
 | 
				
			|||||||
        public async Task<Folder> GetInternalChannelFolder(string userId, CancellationToken cancellationToken)
 | 
					        public async Task<Folder> GetInternalChannelFolder(string userId, CancellationToken cancellationToken)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var name = _localization.GetLocalizedString("ViewTypeChannels");
 | 
					            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,
 | 
					        public async Task DownloadChannelItem(IChannelMediaItem item, string destination,
 | 
				
			||||||
 | 
				
			|||||||
@ -1651,7 +1651,7 @@ namespace MediaBrowser.Server.Implementations.Library
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);
 | 
					        private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async Task<UserView> GetNamedView(User user,
 | 
					        public Task<UserView> GetNamedView(User user,
 | 
				
			||||||
            string name,
 | 
					            string name,
 | 
				
			||||||
            string viewType,
 | 
					            string viewType,
 | 
				
			||||||
            string sortName,
 | 
					            string sortName,
 | 
				
			||||||
@ -1659,10 +1659,17 @@ namespace MediaBrowser.Server.Implementations.Library
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            if (ConfigurationManager.Configuration.EnableUserSpecificUserViews)
 | 
					            if (ConfigurationManager.Configuration.EnableUserSpecificUserViews)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return await GetNamedViewInternal(user, name, null, viewType, sortName, null, cancellationToken)
 | 
					                return GetNamedViewInternal(user, name, null, viewType, sortName, null, cancellationToken);
 | 
				
			||||||
                            .ConfigureAwait(false);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            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,
 | 
					            var path = Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath,
 | 
				
			||||||
                            "views");
 | 
					                            "views");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1806,6 +1813,76 @@ namespace MediaBrowser.Server.Implementations.Library
 | 
				
			|||||||
            return item;
 | 
					            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)
 | 
					        public bool IsVideoFile(string path)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var resolver = new VideoResolver(GetNamingOptions(), new PatternsLogger());
 | 
					            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))
 | 
					                if (_liveTvManager.GetEnabledUsers().Select(i => i.Id.ToString("N")).Contains(query.UserId))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    //list.Add(await _liveTvManager.GetInternalLiveTvFolder(query.UserId, cancellationToken).ConfigureAwait(false));
 | 
					                    var name = _localizationManager.GetLocalizedString("ViewType" + CollectionType.LiveTv);
 | 
				
			||||||
                    list.Add(await GetUserView(new List<ICollectionFolder>(), list, CollectionType.LiveTv, string.Empty, user, cancellationToken).ConfigureAwait(false));
 | 
					                    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);
 | 
					                .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;
 | 
					            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);
 | 
					            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)
 | 
					        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)
 | 
					        public async Task<Folder> GetInternalLiveTvFolder(string userId, CancellationToken cancellationToken)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            var name = _localization.GetLocalizedString("ViewTypeLiveTV");
 | 
					            var name = _localization.GetLocalizedString("ViewTypeLiveTV");
 | 
				
			||||||
            var user = _userManager.GetUserById(userId);
 | 
					            return await _libraryManager.GetNamedView(name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false);
 | 
				
			||||||
            return await _libraryManager.GetNamedView(user, name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info)
 | 
					        public async Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user