当前位置: 首页>>代码示例>>C#>>正文


C# ILibraryManager.GetItemById方法代码示例

本文整理汇总了C#中ILibraryManager.GetItemById方法的典型用法代码示例。如果您正苦于以下问题:C# ILibraryManager.GetItemById方法的具体用法?C# ILibraryManager.GetItemById怎么用?C# ILibraryManager.GetItemById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILibraryManager的用法示例。


在下文中一共展示了ILibraryManager.GetItemById方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAllLibraryItems

        protected IList<BaseItem> GetAllLibraryItems(string userId, IUserManager userManager, ILibraryManager libraryManager, string parentId, Func<BaseItem, bool> filter)
        {
            if (!string.IsNullOrEmpty(parentId))
            {
                var folder = (Folder)libraryManager.GetItemById(new Guid(parentId));

                if (!string.IsNullOrWhiteSpace(userId))
                {
                    var user = userManager.GetUserById(userId);

                    if (user == null)
                    {
                        throw new ArgumentException("User not found");
                    }

                    return folder
                        .GetRecursiveChildren(user, filter)
                        .ToList();
                }

                return folder
                    .GetRecursiveChildren(filter);
            }
            if (!string.IsNullOrWhiteSpace(userId))
            {
                var user = userManager.GetUserById(userId);

                if (user == null)
                {
                    throw new ArgumentException("User not found");
                }

                return user
                    .RootFolder
                    .GetRecursiveChildren(user, filter)
                    .ToList();
            }

            return libraryManager
                .RootFolder
                .GetRecursiveChildren(filter);
        }
开发者ID:rezafouladian,项目名称:Emby,代码行数:42,代码来源:UserViewManager.cs

示例2: GetItemByClientId

        /// <summary>
        /// Gets a BaseItem based upon it's client-side item id
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="userManager">The user manager.</param>
        /// <param name="libraryManager">The library manager.</param>
        /// <param name="userId">The user id.</param>
        /// <returns>BaseItem.</returns>
        public static BaseItem GetItemByClientId(string id, IUserManager userManager, ILibraryManager libraryManager, Guid? userId = null)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }

            // If the item is an indexed folder we have to do a special routine to get it
            var isIndexFolder = id.IndexOf(IndexFolderDelimeter, StringComparison.OrdinalIgnoreCase) != -1;

            if (isIndexFolder)
            {
                if (userId.HasValue)
                {
                    return GetIndexFolder(id, userId.Value, userManager, libraryManager);
                }
            }

            BaseItem item = null;

            if (userId.HasValue || !isIndexFolder)
            {
                item = libraryManager.GetItemById(new Guid(id));
            }

            // If we still don't find it, look within individual user views
            if (item == null && !userId.HasValue && isIndexFolder)
            {
                foreach (var user in userManager.Users)
                {
                    item = GetItemByClientId(id, userManager, libraryManager, user.Id);

                    if (item != null)
                    {
                        break;
                    }
                }
            }

            return item;
        }
开发者ID:jordy1955,项目名称:MediaBrowser,代码行数:49,代码来源:DtoBuilder.cs

示例3: ParseFromUrl

            public static StreamParams ParseFromUrl(string url, ILibraryManager libraryManager)
            {
                var request = new StreamParams
                {
                    ItemId = GetItemId(url)
                };

                if (string.IsNullOrWhiteSpace(request.ItemId))
                {
                    return request;
                }

                const string srch = "params=";
                var index = url.IndexOf(srch, StringComparison.OrdinalIgnoreCase);

                if (index == -1) return request;

                var vals = url.Substring(index + srch.Length).Split(';');

                for (var i = 0; i < vals.Length; i++)
                {
                    var val = vals[i];

                    if (string.IsNullOrWhiteSpace(val))
                    {
                        continue;
                    }

                    if (i == 0)
                    {
                        request.DeviceProfileId = val;
                    }
                    else if (i == 1)
                    {
                        request.DeviceId = val;
                    }
                    else if (i == 2)
                    {
                        request.MediaSourceId = val;
                    }
                    else if (i == 3)
                    {
                        request.IsDirectStream = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
                    }
                    else if (i == 6)
                    {
                        request.AudioStreamIndex = int.Parse(val, CultureInfo.InvariantCulture);
                    }
                    else if (i == 7)
                    {
                        request.SubtitleStreamIndex = int.Parse(val, CultureInfo.InvariantCulture);
                    }
                    else if (i == 14)
                    {
                        request.StartPositionTicks = long.Parse(val, CultureInfo.InvariantCulture);
                    }
                }

                request.Item = string.IsNullOrWhiteSpace(request.ItemId)
                    ? null
                    : libraryManager.GetItemById(new Guid(request.ItemId));

                var hasMediaSources = request.Item as IHasMediaSources;

                request.MediaSource = hasMediaSources == null ?
                    null :
                    hasMediaSources.GetMediaSources(false).FirstOrDefault(i => string.Equals(i.Id, request.MediaSourceId, StringComparison.OrdinalIgnoreCase));



                return request;
            }
开发者ID:Sile626,项目名称:MediaBrowser,代码行数:72,代码来源:PlayToController.cs

示例4: ApplyAdditionalFilters

        private bool ApplyAdditionalFilters(BaseReportRequest request, BaseItem i, User user, ILibraryManager libraryManager)
        {
            // Artists
            if (!string.IsNullOrEmpty(request.ArtistIds))
            {
                var artistIds = request.ArtistIds.Split(new[] { '|', ',' });

                var audio = i as IHasArtist;

                if (!(audio != null && artistIds.Any(id =>
                {
                    var artistItem = libraryManager.GetItemById(id);
                    return artistItem != null && audio.HasAnyArtist(artistItem.Name);
                })))
                {
                    return false;
                }
            }

            // Artists
            if (!string.IsNullOrEmpty(request.Artists))
            {
                var artists = request.Artists.Split('|');

                var audio = i as IHasArtist;

                if (!(audio != null && artists.Any(audio.HasAnyArtist)))
                {
                    return false;
                }
            }

            // Albums
            if (!string.IsNullOrEmpty(request.Albums))
            {
                var albums = request.Albums.Split('|');

                var audio = i as Audio;

                if (audio != null)
                {
                    if (!albums.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
                    {
                        return false;
                    }
                }

                var album = i as MusicAlbum;

                if (album != null)
                {
                    if (!albums.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
                    {
                        return false;
                    }
                }

                var musicVideo = i as MusicVideo;

                if (musicVideo != null)
                {
                    if (!albums.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
                    {
                        return false;
                    }
                }

                return false;
            }

            // Min index number
            if (request.MinIndexNumber.HasValue)
            {
                if (!(i.IndexNumber.HasValue && i.IndexNumber.Value >= request.MinIndexNumber.Value))
                {
                    return false;
                }
            }

            // Min official rating
            if (!string.IsNullOrEmpty(request.MinOfficialRating))
            {
                var level = _localization.GetRatingLevel(request.MinOfficialRating);

                if (level.HasValue)
                {
                    var rating = i.CustomRating;

                    if (string.IsNullOrEmpty(rating))
                    {
                        rating = i.OfficialRating;
                    }

                    if (!string.IsNullOrEmpty(rating))
                    {
                        var itemLevel = _localization.GetRatingLevel(rating);

                        if (!(!itemLevel.HasValue || itemLevel.Value >= level.Value))
                        {
                            return false;
//.........这里部分代码省略.........
开发者ID:rezafouladian,项目名称:Emby,代码行数:101,代码来源:ReportsService.cs

示例5: ApplyAdditionalFilters


//.........这里部分代码省略.........
				var genres = request.GetGenres();
				if (genres.Length > 0 && !(genres.Any(v => i.Genres.Contains(v, StringComparer.OrdinalIgnoreCase))))
				{
					return false;
				}

				// Filter by VideoType
				var videoTypes = request.GetVideoTypes();
				if (videoTypes.Length > 0 && (video == null || !videoTypes.Contains(video.VideoType)))
				{
					return false;
				}

				var imageTypes = request.GetImageTypes().ToList();
				if (imageTypes.Count > 0)
				{
					if (!(imageTypes.Any(i.HasImage)))
					{
						return false;
					}
				}

				// Apply studio filter
				var studios = request.GetStudios();
				if (studios.Length > 0 && !studios.Any(v => i.Studios.Contains(v, StringComparer.OrdinalIgnoreCase)))
				{
					return false;
				}

				// Apply studio filter
				var studioIds = request.GetStudioIds();
				if (studioIds.Length > 0 && !studioIds.Any(id =>
				{
					var studioItem = libraryManager.GetItemById(id);
					return studioItem != null && i.Studios.Contains(studioItem.Name, StringComparer.OrdinalIgnoreCase);
				}))
				{
					return false;
				}

				// Apply year filter
				var years = request.GetYears();
				if (years.Length > 0 && !(i.ProductionYear.HasValue && years.Contains(i.ProductionYear.Value)))
				{
					return false;
				}

				// Apply person filter
				var personIds = request.GetPersonIds();
				if (personIds.Length > 0)
				{
					var names = personIds
						.Select(libraryManager.GetItemById)
						.Select(p => p == null ? "-1" : p.Name)
						.ToList();

					if (!(names.Any(v => _libraryManager.GetPeople(i).Select(p => p.Name).Contains(v, StringComparer.OrdinalIgnoreCase))))
					{
						return false;
					}
				}

				// Apply person filter
				if (!string.IsNullOrEmpty(request.Person))
				{
					var personTypes = request.GetPersonTypes();
开发者ID:redteamcpu,项目名称:Emby,代码行数:67,代码来源:ReportsService.cs


注:本文中的ILibraryManager.GetItemById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。