| | 1 | | #nullable disable |
| | 2 | |
|
| | 3 | | #pragma warning disable CS1591 |
| | 4 | |
|
| | 5 | | using System; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using System.Globalization; |
| | 8 | | using System.Linq; |
| | 9 | | using Jellyfin.Data; |
| | 10 | | using Jellyfin.Data.Enums; |
| | 11 | | using Jellyfin.Database.Implementations.Entities; |
| | 12 | | using Jellyfin.Database.Implementations.Enums; |
| | 13 | | using Jellyfin.Extensions; |
| | 14 | | using MediaBrowser.Controller.Library; |
| | 15 | | using MediaBrowser.Controller.TV; |
| | 16 | | using MediaBrowser.Model.Entities; |
| | 17 | | using MediaBrowser.Model.Querying; |
| | 18 | | using Microsoft.Extensions.Logging; |
| | 19 | | using Episode = MediaBrowser.Controller.Entities.TV.Episode; |
| | 20 | | using MetadataProvider = MediaBrowser.Model.Entities.MetadataProvider; |
| | 21 | | using Series = MediaBrowser.Controller.Entities.TV.Series; |
| | 22 | |
|
| | 23 | | namespace MediaBrowser.Controller.Entities |
| | 24 | | { |
| | 25 | | public class UserViewBuilder |
| | 26 | | { |
| | 27 | | private readonly IUserViewManager _userViewManager; |
| | 28 | | private readonly ILibraryManager _libraryManager; |
| | 29 | | private readonly ILogger<BaseItem> _logger; |
| | 30 | | private readonly IUserDataManager _userDataManager; |
| | 31 | | private readonly ITVSeriesManager _tvSeriesManager; |
| | 32 | |
|
| | 33 | | public UserViewBuilder( |
| | 34 | | IUserViewManager userViewManager, |
| | 35 | | ILibraryManager libraryManager, |
| | 36 | | ILogger<BaseItem> logger, |
| | 37 | | IUserDataManager userDataManager, |
| | 38 | | ITVSeriesManager tvSeriesManager) |
| | 39 | | { |
| 0 | 40 | | _userViewManager = userViewManager; |
| 0 | 41 | | _libraryManager = libraryManager; |
| 0 | 42 | | _logger = logger; |
| 0 | 43 | | _userDataManager = userDataManager; |
| 0 | 44 | | _tvSeriesManager = tvSeriesManager; |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | public QueryResult<BaseItem> GetUserItems(Folder queryParent, Folder displayParent, CollectionType? viewType, In |
| | 48 | | { |
| 0 | 49 | | var user = query.User; |
| | 50 | |
|
| | 51 | | // if (query.IncludeItemTypes is not null && |
| | 52 | | // query.IncludeItemTypes.Length == 1 && |
| | 53 | | // string.Equals(query.IncludeItemTypes[0], "Playlist", StringComparison.OrdinalIgnoreCase)) |
| | 54 | | // { |
| | 55 | | // if (!string.Equals(viewType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)) |
| | 56 | | // { |
| | 57 | | // return await FindPlaylists(queryParent, user, query).ConfigureAwait(false); |
| | 58 | | // } |
| | 59 | | // } |
| | 60 | |
|
| | 61 | | switch (viewType) |
| | 62 | | { |
| | 63 | | case CollectionType.folders: |
| 0 | 64 | | return GetResult(_libraryManager.GetUserRootFolder().GetChildren(user, true), query); |
| | 65 | |
|
| | 66 | | case CollectionType.tvshows: |
| 0 | 67 | | return GetTvView(queryParent, user, query); |
| | 68 | |
|
| | 69 | | case CollectionType.movies: |
| 0 | 70 | | return GetMovieFolders(queryParent, user, query); |
| | 71 | |
|
| | 72 | | case CollectionType.tvshowseries: |
| 0 | 73 | | return GetTvSeries(queryParent, user, query); |
| | 74 | |
|
| | 75 | | case CollectionType.tvgenres: |
| 0 | 76 | | return GetTvGenres(queryParent, user, query); |
| | 77 | |
|
| | 78 | | case CollectionType.tvgenre: |
| 0 | 79 | | return GetTvGenreItems(queryParent, displayParent, user, query); |
| | 80 | |
|
| | 81 | | case CollectionType.tvresume: |
| 0 | 82 | | return GetTvResume(queryParent, user, query); |
| | 83 | |
|
| | 84 | | case CollectionType.tvnextup: |
| 0 | 85 | | return GetTvNextUp(queryParent, query); |
| | 86 | |
|
| | 87 | | case CollectionType.tvlatest: |
| 0 | 88 | | return GetTvLatest(queryParent, user, query); |
| | 89 | |
|
| | 90 | | case CollectionType.moviefavorites: |
| 0 | 91 | | return GetFavoriteMovies(queryParent, user, query); |
| | 92 | |
|
| | 93 | | case CollectionType.movielatest: |
| 0 | 94 | | return GetMovieLatest(queryParent, user, query); |
| | 95 | |
|
| | 96 | | case CollectionType.moviegenres: |
| 0 | 97 | | return GetMovieGenres(queryParent, user, query); |
| | 98 | |
|
| | 99 | | case CollectionType.moviegenre: |
| 0 | 100 | | return GetMovieGenreItems(queryParent, displayParent, user, query); |
| | 101 | |
|
| | 102 | | case CollectionType.movieresume: |
| 0 | 103 | | return GetMovieResume(queryParent, user, query); |
| | 104 | |
|
| | 105 | | case CollectionType.moviemovies: |
| 0 | 106 | | return GetMovieMovies(queryParent, user, query); |
| | 107 | |
|
| | 108 | | case CollectionType.moviecollection: |
| 0 | 109 | | return GetMovieCollections(user, query); |
| | 110 | |
|
| | 111 | | case CollectionType.tvfavoriteepisodes: |
| 0 | 112 | | return GetFavoriteEpisodes(queryParent, user, query); |
| | 113 | |
|
| | 114 | | case CollectionType.tvfavoriteseries: |
| 0 | 115 | | return GetFavoriteSeries(queryParent, user, query); |
| | 116 | |
|
| | 117 | | default: |
| | 118 | | { |
| 0 | 119 | | if (queryParent is UserView) |
| | 120 | | { |
| 0 | 121 | | return GetResult(GetMediaFolders(user).OfType<Folder>().SelectMany(i => i.GetChildren(user, |
| | 122 | | } |
| | 123 | |
|
| 0 | 124 | | return queryParent.GetItems(query); |
| | 125 | | } |
| | 126 | | } |
| | 127 | | } |
| | 128 | |
|
| | 129 | | private int GetSpecialItemsLimit() |
| | 130 | | { |
| 0 | 131 | | return 50; |
| | 132 | | } |
| | 133 | |
|
| | 134 | | private QueryResult<BaseItem> GetMovieFolders(Folder parent, User user, InternalItemsQuery query) |
| | 135 | | { |
| 0 | 136 | | if (query.Recursive) |
| | 137 | | { |
| 0 | 138 | | query.Recursive = true; |
| 0 | 139 | | query.SetUser(user); |
| | 140 | |
|
| 0 | 141 | | if (query.IncludeItemTypes.Length == 0) |
| | 142 | | { |
| 0 | 143 | | query.IncludeItemTypes = new[] { BaseItemKind.Movie }; |
| | 144 | | } |
| | 145 | |
|
| 0 | 146 | | return parent.QueryRecursive(query); |
| | 147 | | } |
| | 148 | |
|
| 0 | 149 | | var list = new List<BaseItem> |
| 0 | 150 | | { |
| 0 | 151 | | GetUserView(CollectionType.movieresume, "HeaderContinueWatching", "0", parent), |
| 0 | 152 | | GetUserView(CollectionType.movielatest, "Latest", "1", parent), |
| 0 | 153 | | GetUserView(CollectionType.moviemovies, "Movies", "2", parent), |
| 0 | 154 | | GetUserView(CollectionType.moviecollection, "Collections", "3", parent), |
| 0 | 155 | | GetUserView(CollectionType.moviefavorites, "Favorites", "4", parent), |
| 0 | 156 | | GetUserView(CollectionType.moviegenres, "Genres", "5", parent) |
| 0 | 157 | | }; |
| | 158 | |
|
| 0 | 159 | | return GetResult(list, query); |
| | 160 | | } |
| | 161 | |
|
| | 162 | | private QueryResult<BaseItem> GetFavoriteMovies(Folder parent, User user, InternalItemsQuery query) |
| | 163 | | { |
| 0 | 164 | | query.Recursive = true; |
| 0 | 165 | | query.Parent = parent; |
| 0 | 166 | | query.SetUser(user); |
| 0 | 167 | | query.IsFavorite = true; |
| 0 | 168 | | query.IncludeItemTypes = new[] { BaseItemKind.Movie }; |
| | 169 | |
|
| 0 | 170 | | return _libraryManager.GetItemsResult(query); |
| | 171 | | } |
| | 172 | |
|
| | 173 | | private QueryResult<BaseItem> GetFavoriteSeries(Folder parent, User user, InternalItemsQuery query) |
| | 174 | | { |
| 0 | 175 | | query.Recursive = true; |
| 0 | 176 | | query.Parent = parent; |
| 0 | 177 | | query.SetUser(user); |
| 0 | 178 | | query.IsFavorite = true; |
| 0 | 179 | | query.IncludeItemTypes = new[] { BaseItemKind.Series }; |
| | 180 | |
|
| 0 | 181 | | return _libraryManager.GetItemsResult(query); |
| | 182 | | } |
| | 183 | |
|
| | 184 | | private QueryResult<BaseItem> GetFavoriteEpisodes(Folder parent, User user, InternalItemsQuery query) |
| | 185 | | { |
| 0 | 186 | | query.Recursive = true; |
| 0 | 187 | | query.Parent = parent; |
| 0 | 188 | | query.SetUser(user); |
| 0 | 189 | | query.IsFavorite = true; |
| 0 | 190 | | query.IncludeItemTypes = new[] { BaseItemKind.Episode }; |
| | 191 | |
|
| 0 | 192 | | return _libraryManager.GetItemsResult(query); |
| | 193 | | } |
| | 194 | |
|
| | 195 | | private QueryResult<BaseItem> GetMovieMovies(Folder parent, User user, InternalItemsQuery query) |
| | 196 | | { |
| 0 | 197 | | query.Recursive = true; |
| 0 | 198 | | query.Parent = parent; |
| 0 | 199 | | query.SetUser(user); |
| | 200 | |
|
| 0 | 201 | | query.IncludeItemTypes = new[] { BaseItemKind.Movie }; |
| | 202 | |
|
| 0 | 203 | | return _libraryManager.GetItemsResult(query); |
| | 204 | | } |
| | 205 | |
|
| | 206 | | private QueryResult<BaseItem> GetMovieCollections(User user, InternalItemsQuery query) |
| | 207 | | { |
| 0 | 208 | | query.Parent = null; |
| 0 | 209 | | query.IncludeItemTypes = new[] { BaseItemKind.BoxSet }; |
| 0 | 210 | | query.SetUser(user); |
| 0 | 211 | | query.Recursive = true; |
| | 212 | |
|
| 0 | 213 | | return _libraryManager.GetItemsResult(query); |
| | 214 | | } |
| | 215 | |
|
| | 216 | | private QueryResult<BaseItem> GetMovieLatest(Folder parent, User user, InternalItemsQuery query) |
| | 217 | | { |
| 0 | 218 | | query.OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending), (ItemSortBy.SortName, SortOrder.Desc |
| 0 | 219 | | query.Recursive = true; |
| 0 | 220 | | query.Parent = parent; |
| 0 | 221 | | query.SetUser(user); |
| 0 | 222 | | query.Limit = GetSpecialItemsLimit(); |
| 0 | 223 | | query.IncludeItemTypes = new[] { BaseItemKind.Movie }; |
| | 224 | |
|
| 0 | 225 | | return ConvertToResult(_libraryManager.GetItemList(query)); |
| | 226 | | } |
| | 227 | |
|
| | 228 | | private QueryResult<BaseItem> GetMovieResume(Folder parent, User user, InternalItemsQuery query) |
| | 229 | | { |
| 0 | 230 | | query.OrderBy = new[] { (ItemSortBy.DatePlayed, SortOrder.Descending), (ItemSortBy.SortName, SortOrder.Desce |
| 0 | 231 | | query.IsResumable = true; |
| 0 | 232 | | query.Recursive = true; |
| 0 | 233 | | query.Parent = parent; |
| 0 | 234 | | query.SetUser(user); |
| 0 | 235 | | query.Limit = GetSpecialItemsLimit(); |
| 0 | 236 | | query.IncludeItemTypes = new[] { BaseItemKind.Movie }; |
| | 237 | |
|
| 0 | 238 | | return ConvertToResult(_libraryManager.GetItemList(query)); |
| | 239 | | } |
| | 240 | |
|
| | 241 | | private QueryResult<BaseItem> ConvertToResult(IReadOnlyList<BaseItem> items) |
| | 242 | | { |
| 0 | 243 | | return new QueryResult<BaseItem>(items); |
| | 244 | | } |
| | 245 | |
|
| | 246 | | private QueryResult<BaseItem> GetMovieGenres(Folder parent, User user, InternalItemsQuery query) |
| | 247 | | { |
| 0 | 248 | | var genres = parent.QueryRecursive(new InternalItemsQuery(user) |
| 0 | 249 | | { |
| 0 | 250 | | IncludeItemTypes = new[] { BaseItemKind.Movie }, |
| 0 | 251 | | Recursive = true, |
| 0 | 252 | | EnableTotalRecordCount = false |
| 0 | 253 | | }).Items |
| 0 | 254 | | .SelectMany(i => i.Genres) |
| 0 | 255 | | .DistinctNames() |
| 0 | 256 | | .Select(i => |
| 0 | 257 | | { |
| 0 | 258 | | try |
| 0 | 259 | | { |
| 0 | 260 | | return _libraryManager.GetGenre(i); |
| 0 | 261 | | } |
| 0 | 262 | | catch (Exception ex) |
| 0 | 263 | | { |
| 0 | 264 | | _logger.LogError(ex, "Error getting genre"); |
| 0 | 265 | | return null; |
| 0 | 266 | | } |
| 0 | 267 | | }) |
| 0 | 268 | | .Where(i => i is not null) |
| 0 | 269 | | .Select(i => GetUserViewWithName(CollectionType.moviegenre, i.SortName, parent)); |
| | 270 | |
|
| 0 | 271 | | return GetResult(genres, query); |
| | 272 | | } |
| | 273 | |
|
| | 274 | | private QueryResult<BaseItem> GetMovieGenreItems(Folder queryParent, Folder displayParent, User user, InternalIt |
| | 275 | | { |
| 0 | 276 | | query.Recursive = true; |
| 0 | 277 | | query.Parent = queryParent; |
| 0 | 278 | | query.GenreIds = new[] { displayParent.Id }; |
| 0 | 279 | | query.SetUser(user); |
| | 280 | |
|
| 0 | 281 | | query.IncludeItemTypes = new[] { BaseItemKind.Movie }; |
| | 282 | |
|
| 0 | 283 | | return _libraryManager.GetItemsResult(query); |
| | 284 | | } |
| | 285 | |
|
| | 286 | | private QueryResult<BaseItem> GetTvView(Folder parent, User user, InternalItemsQuery query) |
| | 287 | | { |
| 0 | 288 | | if (query.Recursive) |
| | 289 | | { |
| 0 | 290 | | query.Recursive = true; |
| 0 | 291 | | query.SetUser(user); |
| | 292 | |
|
| 0 | 293 | | if (query.IncludeItemTypes.Length == 0) |
| | 294 | | { |
| 0 | 295 | | query.IncludeItemTypes = new[] |
| 0 | 296 | | { |
| 0 | 297 | | BaseItemKind.Series, |
| 0 | 298 | | BaseItemKind.Season, |
| 0 | 299 | | BaseItemKind.Episode |
| 0 | 300 | | }; |
| | 301 | | } |
| | 302 | |
|
| 0 | 303 | | return parent.QueryRecursive(query); |
| | 304 | | } |
| | 305 | |
|
| 0 | 306 | | var list = new List<BaseItem> |
| 0 | 307 | | { |
| 0 | 308 | | GetUserView(CollectionType.tvresume, "HeaderContinueWatching", "0", parent), |
| 0 | 309 | | GetUserView(CollectionType.tvnextup, "HeaderNextUp", "1", parent), |
| 0 | 310 | | GetUserView(CollectionType.tvlatest, "Latest", "2", parent), |
| 0 | 311 | | GetUserView(CollectionType.tvshowseries, "Shows", "3", parent), |
| 0 | 312 | | GetUserView(CollectionType.tvfavoriteseries, "HeaderFavoriteShows", "4", parent), |
| 0 | 313 | | GetUserView(CollectionType.tvfavoriteepisodes, "HeaderFavoriteEpisodes", "5", parent), |
| 0 | 314 | | GetUserView(CollectionType.tvgenres, "Genres", "6", parent) |
| 0 | 315 | | }; |
| | 316 | |
|
| 0 | 317 | | return GetResult(list, query); |
| | 318 | | } |
| | 319 | |
|
| | 320 | | private QueryResult<BaseItem> GetTvLatest(Folder parent, User user, InternalItemsQuery query) |
| | 321 | | { |
| 0 | 322 | | query.OrderBy = new[] { (ItemSortBy.DateCreated, SortOrder.Descending), (ItemSortBy.SortName, SortOrder.Desc |
| 0 | 323 | | query.Recursive = true; |
| 0 | 324 | | query.Parent = parent; |
| 0 | 325 | | query.SetUser(user); |
| 0 | 326 | | query.Limit = GetSpecialItemsLimit(); |
| 0 | 327 | | query.IncludeItemTypes = new[] { BaseItemKind.Episode }; |
| 0 | 328 | | query.IsVirtualItem = false; |
| | 329 | |
|
| 0 | 330 | | return ConvertToResult(_libraryManager.GetItemList(query)); |
| | 331 | | } |
| | 332 | |
|
| | 333 | | private QueryResult<BaseItem> GetTvNextUp(Folder parent, InternalItemsQuery query) |
| | 334 | | { |
| 0 | 335 | | var parentFolders = GetMediaFolders(parent, query.User, new[] { CollectionType.tvshows }); |
| | 336 | |
|
| 0 | 337 | | var result = _tvSeriesManager.GetNextUp( |
| 0 | 338 | | new NextUpQuery |
| 0 | 339 | | { |
| 0 | 340 | | Limit = query.Limit, |
| 0 | 341 | | StartIndex = query.StartIndex, |
| 0 | 342 | | User = query.User |
| 0 | 343 | | }, |
| 0 | 344 | | parentFolders, |
| 0 | 345 | | query.DtoOptions); |
| | 346 | |
|
| 0 | 347 | | return result; |
| | 348 | | } |
| | 349 | |
|
| | 350 | | private QueryResult<BaseItem> GetTvResume(Folder parent, User user, InternalItemsQuery query) |
| | 351 | | { |
| 0 | 352 | | query.OrderBy = new[] { (ItemSortBy.DatePlayed, SortOrder.Descending), (ItemSortBy.SortName, SortOrder.Desce |
| 0 | 353 | | query.IsResumable = true; |
| 0 | 354 | | query.Recursive = true; |
| 0 | 355 | | query.Parent = parent; |
| 0 | 356 | | query.SetUser(user); |
| 0 | 357 | | query.Limit = GetSpecialItemsLimit(); |
| 0 | 358 | | query.IncludeItemTypes = new[] { BaseItemKind.Episode }; |
| | 359 | |
|
| 0 | 360 | | return ConvertToResult(_libraryManager.GetItemList(query)); |
| | 361 | | } |
| | 362 | |
|
| | 363 | | private QueryResult<BaseItem> GetTvSeries(Folder parent, User user, InternalItemsQuery query) |
| | 364 | | { |
| 0 | 365 | | query.Recursive = true; |
| 0 | 366 | | query.Parent = parent; |
| 0 | 367 | | query.SetUser(user); |
| | 368 | |
|
| 0 | 369 | | query.IncludeItemTypes = new[] { BaseItemKind.Series }; |
| | 370 | |
|
| 0 | 371 | | return _libraryManager.GetItemsResult(query); |
| | 372 | | } |
| | 373 | |
|
| | 374 | | private QueryResult<BaseItem> GetTvGenres(Folder parent, User user, InternalItemsQuery query) |
| | 375 | | { |
| 0 | 376 | | var genres = parent.QueryRecursive(new InternalItemsQuery(user) |
| 0 | 377 | | { |
| 0 | 378 | | IncludeItemTypes = new[] { BaseItemKind.Series }, |
| 0 | 379 | | Recursive = true, |
| 0 | 380 | | EnableTotalRecordCount = false |
| 0 | 381 | | }).Items |
| 0 | 382 | | .SelectMany(i => i.Genres) |
| 0 | 383 | | .DistinctNames() |
| 0 | 384 | | .Select(i => |
| 0 | 385 | | { |
| 0 | 386 | | try |
| 0 | 387 | | { |
| 0 | 388 | | return _libraryManager.GetGenre(i); |
| 0 | 389 | | } |
| 0 | 390 | | catch (Exception ex) |
| 0 | 391 | | { |
| 0 | 392 | | _logger.LogError(ex, "Error getting genre"); |
| 0 | 393 | | return null; |
| 0 | 394 | | } |
| 0 | 395 | | }) |
| 0 | 396 | | .Where(i => i is not null) |
| 0 | 397 | | .Select(i => GetUserViewWithName(CollectionType.tvgenre, i.SortName, parent)); |
| | 398 | |
|
| 0 | 399 | | return GetResult(genres, query); |
| | 400 | | } |
| | 401 | |
|
| | 402 | | private QueryResult<BaseItem> GetTvGenreItems(Folder queryParent, Folder displayParent, User user, InternalItems |
| | 403 | | { |
| 0 | 404 | | query.Recursive = true; |
| 0 | 405 | | query.Parent = queryParent; |
| 0 | 406 | | query.GenreIds = new[] { displayParent.Id }; |
| 0 | 407 | | query.SetUser(user); |
| | 408 | |
|
| 0 | 409 | | query.IncludeItemTypes = new[] { BaseItemKind.Series }; |
| | 410 | |
|
| 0 | 411 | | return _libraryManager.GetItemsResult(query); |
| | 412 | | } |
| | 413 | |
|
| | 414 | | private QueryResult<BaseItem> GetResult<T>( |
| | 415 | | IEnumerable<T> items, |
| | 416 | | InternalItemsQuery query) |
| | 417 | | where T : BaseItem |
| | 418 | | { |
| 0 | 419 | | items = items.Where(i => Filter(i, query.User, query, _userDataManager, _libraryManager)); |
| | 420 | |
|
| 0 | 421 | | return PostFilterAndSort(items, null, query, _libraryManager); |
| | 422 | | } |
| | 423 | |
|
| | 424 | | public static bool FilterItem(BaseItem item, InternalItemsQuery query) |
| | 425 | | { |
| 10 | 426 | | return Filter(item, query.User, query, BaseItem.UserDataManager, BaseItem.LibraryManager); |
| | 427 | | } |
| | 428 | |
|
| | 429 | | public static QueryResult<BaseItem> PostFilterAndSort( |
| | 430 | | IEnumerable<BaseItem> items, |
| | 431 | | int? totalRecordLimit, |
| | 432 | | InternalItemsQuery query, |
| | 433 | | ILibraryManager libraryManager) |
| | 434 | | { |
| | 435 | | // This must be the last filter |
| 0 | 436 | | if (!query.AdjacentTo.IsNullOrEmpty()) |
| | 437 | | { |
| 0 | 438 | | items = FilterForAdjacency(items.ToList(), query.AdjacentTo.Value); |
| | 439 | | } |
| | 440 | |
|
| 0 | 441 | | return SortAndPage(items, totalRecordLimit, query, libraryManager, true); |
| | 442 | | } |
| | 443 | |
|
| | 444 | | public static QueryResult<BaseItem> SortAndPage( |
| | 445 | | IEnumerable<BaseItem> items, |
| | 446 | | int? totalRecordLimit, |
| | 447 | | InternalItemsQuery query, |
| | 448 | | ILibraryManager libraryManager, |
| | 449 | | bool enableSorting) |
| | 450 | | { |
| 0 | 451 | | if (enableSorting) |
| | 452 | | { |
| 0 | 453 | | if (query.OrderBy.Count > 0) |
| | 454 | | { |
| 0 | 455 | | items = libraryManager.Sort(items, query.User, query.OrderBy); |
| | 456 | | } |
| | 457 | | } |
| | 458 | |
|
| 0 | 459 | | var itemsArray = totalRecordLimit.HasValue ? items.Take(totalRecordLimit.Value).ToArray() : items.ToArray(); |
| 0 | 460 | | var totalCount = itemsArray.Length; |
| | 461 | |
|
| 0 | 462 | | if (query.Limit.HasValue) |
| | 463 | | { |
| 0 | 464 | | itemsArray = itemsArray.Skip(query.StartIndex ?? 0).Take(query.Limit.Value).ToArray(); |
| | 465 | | } |
| 0 | 466 | | else if (query.StartIndex.HasValue) |
| | 467 | | { |
| 0 | 468 | | itemsArray = itemsArray.Skip(query.StartIndex.Value).ToArray(); |
| | 469 | | } |
| | 470 | |
|
| 0 | 471 | | return new QueryResult<BaseItem>( |
| 0 | 472 | | query.StartIndex, |
| 0 | 473 | | totalCount, |
| 0 | 474 | | itemsArray); |
| | 475 | | } |
| | 476 | |
|
| | 477 | | public static bool Filter(BaseItem item, User user, InternalItemsQuery query, IUserDataManager userDataManager, |
| | 478 | | { |
| 10 | 479 | | if (query.MediaTypes.Length > 0 && !query.MediaTypes.Contains(item.MediaType)) |
| | 480 | | { |
| 0 | 481 | | return false; |
| | 482 | | } |
| | 483 | |
|
| 10 | 484 | | if (query.IncludeItemTypes.Length > 0 && !query.IncludeItemTypes.Contains(item.GetBaseItemKind())) |
| | 485 | | { |
| 0 | 486 | | return false; |
| | 487 | | } |
| | 488 | |
|
| 10 | 489 | | if (query.ExcludeItemTypes.Length > 0 && query.ExcludeItemTypes.Contains(item.GetBaseItemKind())) |
| | 490 | | { |
| 0 | 491 | | return false; |
| | 492 | | } |
| | 493 | |
|
| 10 | 494 | | if (query.IsVirtualItem.HasValue && item.IsVirtualItem != query.IsVirtualItem.Value) |
| | 495 | | { |
| 0 | 496 | | return false; |
| | 497 | | } |
| | 498 | |
|
| 10 | 499 | | if (query.IsFolder.HasValue && query.IsFolder.Value != item.IsFolder) |
| | 500 | | { |
| 0 | 501 | | return false; |
| | 502 | | } |
| | 503 | |
|
| 10 | 504 | | UserItemData userData = null; |
| | 505 | |
|
| 10 | 506 | | if (query.IsLiked.HasValue) |
| | 507 | | { |
| 0 | 508 | | userData = userDataManager.GetUserData(user, item); |
| | 509 | |
|
| 0 | 510 | | if (!userData.Likes.HasValue || userData.Likes != query.IsLiked.Value) |
| | 511 | | { |
| 0 | 512 | | return false; |
| | 513 | | } |
| | 514 | | } |
| | 515 | |
|
| 10 | 516 | | if (query.IsFavoriteOrLiked.HasValue) |
| | 517 | | { |
| 0 | 518 | | userData = userData ?? userDataManager.GetUserData(user, item); |
| 0 | 519 | | var isFavoriteOrLiked = userData.IsFavorite || (userData.Likes ?? false); |
| | 520 | |
|
| 0 | 521 | | if (isFavoriteOrLiked != query.IsFavoriteOrLiked.Value) |
| | 522 | | { |
| 0 | 523 | | return false; |
| | 524 | | } |
| | 525 | | } |
| | 526 | |
|
| 10 | 527 | | if (query.IsFavorite.HasValue) |
| | 528 | | { |
| 0 | 529 | | userData = userData ?? userDataManager.GetUserData(user, item); |
| | 530 | |
|
| 0 | 531 | | if (userData.IsFavorite != query.IsFavorite.Value) |
| | 532 | | { |
| 0 | 533 | | return false; |
| | 534 | | } |
| | 535 | | } |
| | 536 | |
|
| 10 | 537 | | if (query.IsResumable.HasValue) |
| | 538 | | { |
| 0 | 539 | | userData = userData ?? userDataManager.GetUserData(user, item); |
| 0 | 540 | | var isResumable = userData.PlaybackPositionTicks > 0; |
| | 541 | |
|
| 0 | 542 | | if (isResumable != query.IsResumable.Value) |
| | 543 | | { |
| 0 | 544 | | return false; |
| | 545 | | } |
| | 546 | | } |
| | 547 | |
|
| 10 | 548 | | if (query.IsPlayed.HasValue) |
| | 549 | | { |
| 0 | 550 | | if (item.IsPlayed(user) != query.IsPlayed.Value) |
| | 551 | | { |
| 0 | 552 | | return false; |
| | 553 | | } |
| | 554 | | } |
| | 555 | |
|
| | 556 | | // Filter by Video3DFormat |
| 10 | 557 | | if (query.Is3D.HasValue) |
| | 558 | | { |
| 0 | 559 | | var val = query.Is3D.Value; |
| 0 | 560 | | var video = item as Video; |
| | 561 | |
|
| 0 | 562 | | if (video is null || val != video.Video3DFormat.HasValue) |
| | 563 | | { |
| 0 | 564 | | return false; |
| | 565 | | } |
| | 566 | | } |
| | 567 | |
|
| | 568 | | /* |
| | 569 | | * fuck - fix this |
| | 570 | | if (query.IsHD.HasValue) |
| | 571 | | { |
| | 572 | | if (item.IsHD != query.IsHD.Value) |
| | 573 | | { |
| | 574 | | return false; |
| | 575 | | } |
| | 576 | | } |
| | 577 | | */ |
| | 578 | |
|
| 10 | 579 | | if (query.IsLocked.HasValue) |
| | 580 | | { |
| 0 | 581 | | var val = query.IsLocked.Value; |
| 0 | 582 | | if (item.IsLocked != val) |
| | 583 | | { |
| 0 | 584 | | return false; |
| | 585 | | } |
| | 586 | | } |
| | 587 | |
|
| 10 | 588 | | if (query.HasOverview.HasValue) |
| | 589 | | { |
| 0 | 590 | | var filterValue = query.HasOverview.Value; |
| | 591 | |
|
| 0 | 592 | | var hasValue = !string.IsNullOrEmpty(item.Overview); |
| | 593 | |
|
| 0 | 594 | | if (hasValue != filterValue) |
| | 595 | | { |
| 0 | 596 | | return false; |
| | 597 | | } |
| | 598 | | } |
| | 599 | |
|
| 10 | 600 | | if (query.HasImdbId.HasValue) |
| | 601 | | { |
| 0 | 602 | | var filterValue = query.HasImdbId.Value; |
| | 603 | |
|
| 0 | 604 | | var hasValue = !string.IsNullOrEmpty(item.GetProviderId(MetadataProvider.Imdb)); |
| | 605 | |
|
| 0 | 606 | | if (hasValue != filterValue) |
| | 607 | | { |
| 0 | 608 | | return false; |
| | 609 | | } |
| | 610 | | } |
| | 611 | |
|
| 10 | 612 | | if (query.HasTmdbId.HasValue) |
| | 613 | | { |
| 0 | 614 | | var filterValue = query.HasTmdbId.Value; |
| | 615 | |
|
| 0 | 616 | | var hasValue = !string.IsNullOrEmpty(item.GetProviderId(MetadataProvider.Tmdb)); |
| | 617 | |
|
| 0 | 618 | | if (hasValue != filterValue) |
| | 619 | | { |
| 0 | 620 | | return false; |
| | 621 | | } |
| | 622 | | } |
| | 623 | |
|
| 10 | 624 | | if (query.HasTvdbId.HasValue) |
| | 625 | | { |
| 0 | 626 | | var filterValue = query.HasTvdbId.Value; |
| | 627 | |
|
| 0 | 628 | | var hasValue = !string.IsNullOrEmpty(item.GetProviderId(MetadataProvider.Tvdb)); |
| | 629 | |
|
| 0 | 630 | | if (hasValue != filterValue) |
| | 631 | | { |
| 0 | 632 | | return false; |
| | 633 | | } |
| | 634 | | } |
| | 635 | |
|
| 10 | 636 | | if (query.HasOfficialRating.HasValue) |
| | 637 | | { |
| 0 | 638 | | var filterValue = query.HasOfficialRating.Value; |
| | 639 | |
|
| 0 | 640 | | var hasValue = !string.IsNullOrEmpty(item.OfficialRating); |
| | 641 | |
|
| 0 | 642 | | if (hasValue != filterValue) |
| | 643 | | { |
| 0 | 644 | | return false; |
| | 645 | | } |
| | 646 | | } |
| | 647 | |
|
| 10 | 648 | | if (query.IsPlaceHolder.HasValue) |
| | 649 | | { |
| 0 | 650 | | var filterValue = query.IsPlaceHolder.Value; |
| | 651 | |
|
| 0 | 652 | | var isPlaceHolder = false; |
| | 653 | |
|
| 0 | 654 | | if (item is ISupportsPlaceHolders hasPlaceHolder) |
| | 655 | | { |
| 0 | 656 | | isPlaceHolder = hasPlaceHolder.IsPlaceHolder; |
| | 657 | | } |
| | 658 | |
|
| 0 | 659 | | if (isPlaceHolder != filterValue) |
| | 660 | | { |
| 0 | 661 | | return false; |
| | 662 | | } |
| | 663 | | } |
| | 664 | |
|
| 10 | 665 | | if (query.HasSpecialFeature.HasValue) |
| | 666 | | { |
| 0 | 667 | | var filterValue = query.HasSpecialFeature.Value; |
| | 668 | |
|
| 0 | 669 | | if (item is IHasSpecialFeatures movie) |
| | 670 | | { |
| 0 | 671 | | var ok = filterValue |
| 0 | 672 | | ? movie.SpecialFeatureIds.Count > 0 |
| 0 | 673 | | : movie.SpecialFeatureIds.Count == 0; |
| | 674 | |
|
| 0 | 675 | | if (!ok) |
| | 676 | | { |
| 0 | 677 | | return false; |
| | 678 | | } |
| | 679 | | } |
| | 680 | | else |
| | 681 | | { |
| 0 | 682 | | return false; |
| | 683 | | } |
| | 684 | | } |
| | 685 | |
|
| 10 | 686 | | if (query.HasSubtitles.HasValue) |
| | 687 | | { |
| 0 | 688 | | var val = query.HasSubtitles.Value; |
| | 689 | |
|
| 0 | 690 | | var video = item as Video; |
| | 691 | |
|
| 0 | 692 | | if (video is null || val != video.HasSubtitles) |
| | 693 | | { |
| 0 | 694 | | return false; |
| | 695 | | } |
| | 696 | | } |
| | 697 | |
|
| 10 | 698 | | if (query.HasParentalRating.HasValue) |
| | 699 | | { |
| 0 | 700 | | var val = query.HasParentalRating.Value; |
| | 701 | |
|
| 0 | 702 | | var rating = item.CustomRating; |
| | 703 | |
|
| 0 | 704 | | if (string.IsNullOrEmpty(rating)) |
| | 705 | | { |
| 0 | 706 | | rating = item.OfficialRating; |
| | 707 | | } |
| | 708 | |
|
| 0 | 709 | | if (val) |
| | 710 | | { |
| 0 | 711 | | if (string.IsNullOrEmpty(rating)) |
| | 712 | | { |
| 0 | 713 | | return false; |
| | 714 | | } |
| | 715 | | } |
| | 716 | | else |
| | 717 | | { |
| 0 | 718 | | if (!string.IsNullOrEmpty(rating)) |
| | 719 | | { |
| 0 | 720 | | return false; |
| | 721 | | } |
| | 722 | | } |
| | 723 | | } |
| | 724 | |
|
| 10 | 725 | | if (query.HasTrailer.HasValue) |
| | 726 | | { |
| 0 | 727 | | var val = query.HasTrailer.Value; |
| 0 | 728 | | var trailerCount = 0; |
| | 729 | |
|
| 0 | 730 | | if (item is IHasTrailers hasTrailers) |
| | 731 | | { |
| 0 | 732 | | trailerCount = hasTrailers.GetTrailerCount(); |
| | 733 | | } |
| | 734 | |
|
| 0 | 735 | | var ok = val ? trailerCount > 0 : trailerCount == 0; |
| | 736 | |
|
| 0 | 737 | | if (!ok) |
| | 738 | | { |
| 0 | 739 | | return false; |
| | 740 | | } |
| | 741 | | } |
| | 742 | |
|
| 10 | 743 | | if (query.HasThemeSong.HasValue) |
| | 744 | | { |
| 0 | 745 | | var filterValue = query.HasThemeSong.Value; |
| | 746 | |
|
| 0 | 747 | | var themeCount = item.GetThemeSongs(user).Count; |
| 0 | 748 | | var ok = filterValue ? themeCount > 0 : themeCount == 0; |
| | 749 | |
|
| 0 | 750 | | if (!ok) |
| | 751 | | { |
| 0 | 752 | | return false; |
| | 753 | | } |
| | 754 | | } |
| | 755 | |
|
| 10 | 756 | | if (query.HasThemeVideo.HasValue) |
| | 757 | | { |
| 0 | 758 | | var filterValue = query.HasThemeVideo.Value; |
| | 759 | |
|
| 0 | 760 | | var themeCount = item.GetThemeVideos(user).Count; |
| 0 | 761 | | var ok = filterValue ? themeCount > 0 : themeCount == 0; |
| | 762 | |
|
| 0 | 763 | | if (!ok) |
| | 764 | | { |
| 0 | 765 | | return false; |
| | 766 | | } |
| | 767 | | } |
| | 768 | |
|
| | 769 | | // Apply genre filter |
| 10 | 770 | | if (query.Genres.Count > 0 && !query.Genres.Any(v => item.Genres.Contains(v, StringComparison.OrdinalIgnoreC |
| | 771 | | { |
| 0 | 772 | | return false; |
| | 773 | | } |
| | 774 | |
|
| | 775 | | // Filter by VideoType |
| 10 | 776 | | if (query.VideoTypes.Length > 0) |
| | 777 | | { |
| 0 | 778 | | var video = item as Video; |
| 0 | 779 | | if (video is null || !query.VideoTypes.Contains(video.VideoType)) |
| | 780 | | { |
| 0 | 781 | | return false; |
| | 782 | | } |
| | 783 | | } |
| | 784 | |
|
| 10 | 785 | | if (query.ImageTypes.Length > 0 && !query.ImageTypes.Any(item.HasImage)) |
| | 786 | | { |
| 0 | 787 | | return false; |
| | 788 | | } |
| | 789 | |
|
| | 790 | | // Apply studio filter |
| 10 | 791 | | if (query.StudioIds.Length > 0 && !query.StudioIds.Any(id => |
| 10 | 792 | | { |
| 10 | 793 | | var studioItem = libraryManager.GetItemById(id); |
| 10 | 794 | | return studioItem is not null && item.Studios.Contains(studioItem.Name, StringComparison.OrdinalIgnoreCa |
| 10 | 795 | | })) |
| | 796 | | { |
| 0 | 797 | | return false; |
| | 798 | | } |
| | 799 | |
|
| | 800 | | // Apply genre filter |
| 10 | 801 | | if (query.GenreIds.Count > 0 && !query.GenreIds.Any(id => |
| 10 | 802 | | { |
| 10 | 803 | | var genreItem = libraryManager.GetItemById(id); |
| 10 | 804 | | return genreItem is not null && item.Genres.Contains(genreItem.Name, StringComparison.OrdinalIgnoreCase) |
| 10 | 805 | | })) |
| | 806 | | { |
| 0 | 807 | | return false; |
| | 808 | | } |
| | 809 | |
|
| | 810 | | // Apply year filter |
| 10 | 811 | | if (query.Years.Length > 0) |
| | 812 | | { |
| 0 | 813 | | if (!(item.ProductionYear.HasValue && query.Years.Contains(item.ProductionYear.Value))) |
| | 814 | | { |
| 0 | 815 | | return false; |
| | 816 | | } |
| | 817 | | } |
| | 818 | |
|
| | 819 | | // Apply official rating filter |
| 10 | 820 | | if (query.OfficialRatings.Length > 0 && !query.OfficialRatings.Contains(item.OfficialRating ?? string.Empty) |
| | 821 | | { |
| 0 | 822 | | return false; |
| | 823 | | } |
| | 824 | |
|
| 10 | 825 | | if (query.ItemIds.Length > 0) |
| | 826 | | { |
| 0 | 827 | | if (!query.ItemIds.Contains(item.Id)) |
| | 828 | | { |
| 0 | 829 | | return false; |
| | 830 | | } |
| | 831 | | } |
| | 832 | |
|
| | 833 | | // Apply tag filter |
| 10 | 834 | | var tags = query.Tags; |
| 10 | 835 | | if (tags.Length > 0) |
| | 836 | | { |
| 0 | 837 | | if (!tags.Any(v => item.Tags.Contains(v, StringComparison.OrdinalIgnoreCase))) |
| | 838 | | { |
| 0 | 839 | | return false; |
| | 840 | | } |
| | 841 | | } |
| | 842 | |
|
| 10 | 843 | | if (query.MinCommunityRating.HasValue) |
| | 844 | | { |
| 0 | 845 | | var val = query.MinCommunityRating.Value; |
| | 846 | |
|
| 0 | 847 | | if (!(item.CommunityRating.HasValue && item.CommunityRating >= val)) |
| | 848 | | { |
| 0 | 849 | | return false; |
| | 850 | | } |
| | 851 | | } |
| | 852 | |
|
| 10 | 853 | | if (query.MinCriticRating.HasValue) |
| | 854 | | { |
| 0 | 855 | | var val = query.MinCriticRating.Value; |
| | 856 | |
|
| 0 | 857 | | if (!(item.CriticRating.HasValue && item.CriticRating >= val)) |
| | 858 | | { |
| 0 | 859 | | return false; |
| | 860 | | } |
| | 861 | | } |
| | 862 | |
|
| 10 | 863 | | if (query.MinIndexNumber.HasValue) |
| | 864 | | { |
| 0 | 865 | | var val = query.MinIndexNumber.Value; |
| | 866 | |
|
| 0 | 867 | | if (!(item.IndexNumber.HasValue && item.IndexNumber.Value >= val)) |
| | 868 | | { |
| 0 | 869 | | return false; |
| | 870 | | } |
| | 871 | | } |
| | 872 | |
|
| 10 | 873 | | if (query.MinPremiereDate.HasValue) |
| | 874 | | { |
| 0 | 875 | | var val = query.MinPremiereDate.Value; |
| | 876 | |
|
| 0 | 877 | | if (!(item.PremiereDate.HasValue && item.PremiereDate.Value >= val)) |
| | 878 | | { |
| 0 | 879 | | return false; |
| | 880 | | } |
| | 881 | | } |
| | 882 | |
|
| 10 | 883 | | if (query.MaxPremiereDate.HasValue) |
| | 884 | | { |
| 0 | 885 | | var val = query.MaxPremiereDate.Value; |
| | 886 | |
|
| 0 | 887 | | if (!(item.PremiereDate.HasValue && item.PremiereDate.Value <= val)) |
| | 888 | | { |
| 0 | 889 | | return false; |
| | 890 | | } |
| | 891 | | } |
| | 892 | |
|
| 10 | 893 | | if (query.ParentIndexNumber.HasValue) |
| | 894 | | { |
| 0 | 895 | | var filterValue = query.ParentIndexNumber.Value; |
| | 896 | |
|
| 0 | 897 | | if (item.ParentIndexNumber.HasValue && item.ParentIndexNumber.Value != filterValue) |
| | 898 | | { |
| 0 | 899 | | return false; |
| | 900 | | } |
| | 901 | | } |
| | 902 | |
|
| 10 | 903 | | if (query.SeriesStatuses.Length > 0) |
| | 904 | | { |
| 0 | 905 | | var ok = new[] { item }.OfType<Series>().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.S |
| 0 | 906 | | if (!ok) |
| | 907 | | { |
| 0 | 908 | | return false; |
| | 909 | | } |
| | 910 | | } |
| | 911 | |
|
| 10 | 912 | | if (query.AiredDuringSeason.HasValue) |
| | 913 | | { |
| 0 | 914 | | var episode = item as Episode; |
| | 915 | |
|
| 0 | 916 | | if (episode is null) |
| | 917 | | { |
| 0 | 918 | | return false; |
| | 919 | | } |
| | 920 | |
|
| 0 | 921 | | if (!Series.FilterEpisodesBySeason(new[] { episode }, query.AiredDuringSeason.Value, true).Any()) |
| | 922 | | { |
| 0 | 923 | | return false; |
| | 924 | | } |
| | 925 | | } |
| | 926 | |
|
| 10 | 927 | | return true; |
| | 928 | | } |
| | 929 | |
|
| | 930 | | private IEnumerable<BaseItem> GetMediaFolders(User user) |
| | 931 | | { |
| 0 | 932 | | if (user is null) |
| | 933 | | { |
| 0 | 934 | | return _libraryManager.RootFolder |
| 0 | 935 | | .Children |
| 0 | 936 | | .OfType<Folder>() |
| 0 | 937 | | .Where(UserView.IsEligibleForGrouping); |
| | 938 | | } |
| | 939 | |
|
| 0 | 940 | | return _libraryManager.GetUserRootFolder() |
| 0 | 941 | | .GetChildren(user, true) |
| 0 | 942 | | .OfType<Folder>() |
| 0 | 943 | | .Where(i => user.IsFolderGrouped(i.Id) && UserView.IsEligibleForGrouping(i)); |
| | 944 | | } |
| | 945 | |
|
| | 946 | | private BaseItem[] GetMediaFolders(User user, IEnumerable<CollectionType> viewTypes) |
| | 947 | | { |
| 0 | 948 | | if (user is null) |
| | 949 | | { |
| 0 | 950 | | return GetMediaFolders(null) |
| 0 | 951 | | .Where(i => |
| 0 | 952 | | { |
| 0 | 953 | | var folder = i as ICollectionFolder; |
| 0 | 954 | |
|
| 0 | 955 | | return folder?.CollectionType is not null && viewTypes.Contains(folder.CollectionType.Value); |
| 0 | 956 | | }).ToArray(); |
| | 957 | | } |
| | 958 | |
|
| 0 | 959 | | return GetMediaFolders(user) |
| 0 | 960 | | .Where(i => |
| 0 | 961 | | { |
| 0 | 962 | | var folder = i as ICollectionFolder; |
| 0 | 963 | |
|
| 0 | 964 | | return folder?.CollectionType is not null && viewTypes.Contains(folder.CollectionType.Value); |
| 0 | 965 | | }).ToArray(); |
| | 966 | | } |
| | 967 | |
|
| | 968 | | private BaseItem[] GetMediaFolders(Folder parent, User user, IEnumerable<CollectionType> viewTypes) |
| | 969 | | { |
| 0 | 970 | | if (parent is null || parent is UserView) |
| | 971 | | { |
| 0 | 972 | | return GetMediaFolders(user, viewTypes); |
| | 973 | | } |
| | 974 | |
|
| 0 | 975 | | return new BaseItem[] { parent }; |
| | 976 | | } |
| | 977 | |
|
| | 978 | | private UserView GetUserViewWithName(CollectionType? type, string sortName, BaseItem parent) |
| | 979 | | { |
| 0 | 980 | | return _userViewManager.GetUserSubView(parent.Id, type, parent.Id.ToString("N", CultureInfo.InvariantCulture |
| | 981 | | } |
| | 982 | |
|
| | 983 | | private UserView GetUserView(CollectionType? type, string localizationKey, string sortName, BaseItem parent) |
| | 984 | | { |
| 0 | 985 | | return _userViewManager.GetUserSubView(parent.Id, type, localizationKey, sortName); |
| | 986 | | } |
| | 987 | |
|
| | 988 | | public static IEnumerable<BaseItem> FilterForAdjacency(List<BaseItem> list, Guid adjacentTo) |
| | 989 | | { |
| 0 | 990 | | var adjacentToItem = list.FirstOrDefault(i => i.Id.Equals(adjacentTo)); |
| | 991 | |
|
| 0 | 992 | | var index = list.IndexOf(adjacentToItem); |
| | 993 | |
|
| 0 | 994 | | var previousId = Guid.Empty; |
| 0 | 995 | | var nextId = Guid.Empty; |
| | 996 | |
|
| 0 | 997 | | if (index > 0) |
| | 998 | | { |
| 0 | 999 | | previousId = list[index - 1].Id; |
| | 1000 | | } |
| | 1001 | |
|
| 0 | 1002 | | if (index < list.Count - 1) |
| | 1003 | | { |
| 0 | 1004 | | nextId = list[index + 1].Id; |
| | 1005 | | } |
| | 1006 | |
|
| 0 | 1007 | | return list.Where(i => i.Id.Equals(previousId) || i.Id.Equals(nextId) || i.Id.Equals(adjacentTo)); |
| | 1008 | | } |
| | 1009 | | } |
| | 1010 | | } |