pünktchen 1261 Posted September 23, 2018 Share Posted September 23, 2018 Hi @@Luke, in my live tv recording channel i'd like to present items by series -> season -> episodes, the same way as it is done in real libraries. But somehow this seems to be broken. If i define ChannelItem FolderType = ChannelFolderType.Series, then no further items for this folder are imported. In my case the other items should be FolderType = ChannelFolderType.Season, but this doesn't work. What works is to define FolderType = ChannelFolderType.Container for both the series and season level, but then the presentation in emby isn't like a tv show. It's just a dump folder structur. Here's the relevant part of my code: public Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(query.FolderId)) { return GetRecordingGroups(query, cancellationToken); } if (string.Equals(query.FolderId, "tvshows", StringComparison.OrdinalIgnoreCase)) { return GetRecordingSeriesGroups(query, cancellationToken); } if (query.FolderId.StartsWith("series_", StringComparison.OrdinalIgnoreCase)) { var hash = query.FolderId.Split('_')[1]; return GetRecordingSeasonGroups(query, i => i.IsSeries && string.Equals(i.Name.GetMD5().ToString("N"), hash, StringComparison.Ordinal), cancellationToken); } if (query.FolderId.Contains("_season_")) { var series = query.FolderId.Split('_')[0]; var hash = query.FolderId.Split('_')[2]; return GetChannelItems(query, i => i.IsSeries && string.Equals(i.Name, series) && string.Equals(i.SeasonNumber.ToString().GetMD5().ToString("N"), hash, StringComparison.Ordinal), cancellationToken); } var result = new ChannelItemResult() { Items = new List<ChannelItemInfo>() }; return Task.FromResult(result); } public async Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, Func<MyRecordingInfo, bool> filter, CancellationToken cancellationToken) { var service = GetService(); var allRecordings = await service.GetAllRecordingsAsync(cancellationToken).ConfigureAwait(false); var result = new ChannelItemResult() { Items = new List<ChannelItemInfo>() }; result.Items.AddRange(allRecordings.Where(filter).Select(ConvertToChannelItem)); return result; } private async Task<ChannelItemResult> GetRecordingGroups(InternalChannelItemQuery query, CancellationToken cancellationToken) { var service = GetService(); var allRecordings = await service.GetAllRecordingsAsync(cancellationToken).ConfigureAwait(false); var result = new ChannelItemResult() { Items = new List<ChannelItemInfo>(), }; var series = allRecordings.FirstOrDefault(i => i.IsSeries); if (series != null) { result.Items.Add(new ChannelItemInfo { Id = "tvshows", Name = "TV Shows", Type = ChannelItemType.Folder, FolderType = ChannelFolderType.Container, }); } return result; } private async Task<ChannelItemResult> GetRecordingSeriesGroups(InternalChannelItemQuery query, CancellationToken cancellationToken) { var service = GetService(); var allRecordings = await service.GetAllRecordingsAsync(cancellationToken).ConfigureAwait(false); var result = new ChannelItemResult() { Items = new List<ChannelItemInfo>(), }; var series = allRecordings .Where(i => i.IsSeries) .ToLookup(i => i.Name, StringComparer.OrdinalIgnoreCase); result.Items.AddRange(series.OrderBy(i => i.Key).Select(i => new ChannelItemInfo { Id = "series_" + i.Key.GetMD5().ToString("N"), Name = i.Key, SeriesName = i.Key, Type = ChannelItemType.Folder, FolderType = ChannelFolderType.Series, })); return result; } private async Task<ChannelItemResult> GetRecordingSeasonGroups(InternalChannelItemQuery query, Func<MyRecordingInfo, bool> filter, CancellationToken cancellationToken) { var service = GetService(); var allRecordings = await service.GetAllRecordingsAsync(cancellationToken).ConfigureAwait(false); var result = new ChannelItemResult() { Items = new List<ChannelItemInfo>(), }; var series = allRecordings.Where(filter).Select(i => i.Name).First(); var seasons = allRecordings.Where(filter).GroupBy(i => i.SeasonNumber, i => i.Name, (key, g) => new { SeasonNumber = key, Name = g.ToList() }); result.Items.AddRange(seasons.OrderBy(i => i.SeasonNumber).Select(i => new ChannelItemInfo { Id = series + "_season_" + i.SeasonNumber.ToString().GetMD5().ToString("N"), Name = "Season " + i.SeasonNumber, SeriesName = series, IndexNumber = i.SeasonNumber, Type = ChannelItemType.Folder, FolderType = ChannelFolderType.Season, })); return result; } private ChannelItemInfo ConvertToChannelItem(MyRecordingInfo item) { var config = Plugin.Instance.Configuration; var channelItem = new ChannelItemInfo { Id = item.Id, Name = !string.IsNullOrEmpty(item.EpisodeTitle) && (item.IsSeries || item.EpisodeNumber.HasValue && !item.IsMovie) ? item.EpisodeTitle : item.Name, SeriesName = !string.IsNullOrEmpty(item.EpisodeTitle) && (item.IsSeries || item.EpisodeNumber.HasValue && !item.IsMovie) ? item.Name : null, OriginalTitle = !string.IsNullOrEmpty(item.EpisodeTitle) && item.IsMovie ? item.EpisodeTitle : null, IndexNumber = item.EpisodeNumber, ParentIndexNumber = item.SeasonNumber, ProductionYear = item.Year, Overview = item.Overview, Genres = item.Genres, DateCreated = item.StartDate, DateModified = item.EndDate, Type = ChannelItemType.Media, ContentType = item.IsMovie ? ChannelMediaContentType.Movie : (item.IsSeries || item.EpisodeNumber != null ? ChannelMediaContentType.Episode : ChannelMediaContentType.Clip), MediaType = item.ChannelType == ChannelType.TV ? ChannelMediaType.Video : ChannelMediaType.Audio, IsLiveStream = item.Status == RecordingStatus.InProgress, Etag = item.Status.ToString(), MediaSources = new List<MediaSourceInfo> { new MediaSourceInfo { Path = config.EnableDirectAccess && item.Status != RecordingStatus.InProgress ? item.Path : Plugin.StreamingProxy.GetRecordingStream(item.Id), Protocol = item.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? MediaProtocol.Http : MediaProtocol.File, Id = item.Id, SupportsProbing = item.Status == RecordingStatus.InProgress ? false : true, IsInfiniteStream = item.Status == RecordingStatus.InProgress ? true : false, ReadAtNativeFramerate = item.Status == RecordingStatus.InProgress ? true : false, RunTimeTicks = (item.EndDate - item.StartDate).Ticks, RequiredHttpHeaders = config.RequiresAuthentication ? new Dictionary<string, string> {{ "Authentication", "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(String.Format("{0}:{1}", config.UserName, config.Password))) }} : new Dictionary<string, string> {}, } } }; return channelItem; } An here's a log, but nothing usefull in there: embyserver-63673314738.txt Link to comment Share on other sites More sharing options...
Luke 37251 Posted September 23, 2018 Share Posted September 23, 2018 It's there as a placeholder but it's never been done or tested before so it will probably require some new development. Link to comment Share on other sites More sharing options...
pünktchen 1261 Posted September 23, 2018 Author Share Posted September 23, 2018 Ah okay, so please keep it in your mind for the next release. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now