diff options
| author | Patrick Barron <barronpm@gmail.com> | 2020-05-12 22:10:35 -0400 |
|---|---|---|
| committer | Patrick Barron <barronpm@gmail.com> | 2020-05-12 22:10:35 -0400 |
| commit | 9ad839c7766bd5d6121a10b2c306d6fef9666c52 (patch) | |
| tree | 47833157e6b40eba243a937b8c93b4bec11de9dd /Emby.Server.Implementations/LiveTv | |
| parent | a78184ef4423be8e320f642eb7b0155810d86cbd (diff) | |
Initial migration code
Diffstat (limited to 'Emby.Server.Implementations/LiveTv')
| -rw-r--r-- | Emby.Server.Implementations/LiveTv/LiveTvManager.cs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index 1b10f2d27c..c58860a99a 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Emby.Server.Implementations.Library; +using Jellyfin.Data.Enums; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; @@ -707,7 +708,6 @@ namespace Emby.Server.Implementations.LiveTv { Path = info.ThumbImageUrl, Type = ImageType.Thumb - }, 0); } } @@ -720,7 +720,6 @@ namespace Emby.Server.Implementations.LiveTv { Path = info.LogoImageUrl, Type = ImageType.Logo - }, 0); } } @@ -733,7 +732,6 @@ namespace Emby.Server.Implementations.LiveTv { Path = info.BackdropImageUrl, Type = ImageType.Backdrop - }, 0); } } @@ -765,13 +763,14 @@ namespace Emby.Server.Implementations.LiveTv return new Tuple<LiveTvProgram, bool, bool>(item, isNew, isUpdated); } - public async Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null) + public async Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, Jellyfin.Data.Entities.User user = null) { var program = _libraryManager.GetItemById(id); var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user); - var list = new List<Tuple<BaseItemDto, string, string>>() { + var list = new List<Tuple<BaseItemDto, string, string>> + { new Tuple<BaseItemDto, string, string>(dto, program.ExternalId, program.ExternalSeriesId) }; @@ -939,7 +938,7 @@ namespace Emby.Server.Implementations.LiveTv }; } - private int GetRecommendationScore(LiveTvProgram program, User user, bool factorChannelWatchCount) + private int GetRecommendationScore(LiveTvProgram program, Jellyfin.Data.Entities.User user, bool factorChannelWatchCount) { var score = 0; @@ -1325,7 +1324,7 @@ namespace Emby.Server.Implementations.LiveTv return 7; } - private QueryResult<BaseItem> GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, User user) + private QueryResult<BaseItem> GetEmbyRecordings(RecordingQuery query, DtoOptions dtoOptions, Jellyfin.Data.Entities.User user) { if (user == null) { @@ -1433,7 +1432,7 @@ namespace Emby.Server.Implementations.LiveTv return result; } - public Task AddInfoToProgramDto(IReadOnlyCollection<(BaseItem, BaseItemDto)> tuples, ItemFields[] fields, User user = null) + public Task AddInfoToProgramDto(IReadOnlyCollection<(BaseItem, BaseItemDto)> tuples, ItemFields[] fields, Jellyfin.Data.Entities.User user = null) { var programTuples = new List<Tuple<BaseItemDto, string, string>>(); var hasChannelImage = fields.Contains(ItemFields.ChannelImage); @@ -1483,7 +1482,7 @@ namespace Emby.Server.Implementations.LiveTv return EmbyTV.EmbyTV.Current.GetActiveRecordingInfo(path); } - public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null) + public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, Jellyfin.Data.Entities.User user = null) { var service = EmbyTV.EmbyTV.Current; @@ -1895,7 +1894,7 @@ namespace Emby.Server.Implementations.LiveTv return _libraryManager.GetItemById(internalChannelId); } - public void AddChannelInfo(IReadOnlyCollection<(BaseItemDto, LiveTvChannel)> tuples, DtoOptions options, User user) + public void AddChannelInfo(IReadOnlyCollection<(BaseItemDto, LiveTvChannel)> tuples, DtoOptions options, Jellyfin.Data.Entities.User user) { var now = DateTime.UtcNow; @@ -2206,23 +2205,22 @@ namespace Emby.Server.Implementations.LiveTv var info = new LiveTvInfo { Services = services, - IsEnabled = services.Length > 0 + IsEnabled = services.Length > 0, + EnabledUsers = _userManager.Users + .Where(IsLiveTvEnabled) + .Select(i => i.Id.ToString("N", CultureInfo.InvariantCulture)) + .ToArray() }; - info.EnabledUsers = _userManager.Users - .Where(IsLiveTvEnabled) - .Select(i => i.Id.ToString("N", CultureInfo.InvariantCulture)) - .ToArray(); - return info; } - private bool IsLiveTvEnabled(User user) + private bool IsLiveTvEnabled(Jellyfin.Data.Entities.User user) { - return user.Policy.EnableLiveTvAccess && (Services.Count > 1 || GetConfiguration().TunerHosts.Length > 0); + return user.HasPermission(PermissionKind.EnableLiveTvAccess) && (Services.Count > 1 || GetConfiguration().TunerHosts.Length > 0); } - public IEnumerable<User> GetEnabledUsers() + public IEnumerable<Jellyfin.Data.Entities.User> GetEnabledUsers() { return _userManager.Users .Where(IsLiveTvEnabled); @@ -2472,12 +2470,12 @@ namespace Emby.Server.Implementations.LiveTv return _tvDtoService.GetInternalProgramId(externalId); } - public List<BaseItem> GetRecordingFolders(User user) + public List<BaseItem> GetRecordingFolders(Jellyfin.Data.Entities.User user) { return GetRecordingFolders(user, false); } - private List<BaseItem> GetRecordingFolders(User user, bool refreshChannels) + private List<BaseItem> GetRecordingFolders(Jellyfin.Data.Entities.User user, bool refreshChannels) { var folders = EmbyTV.EmbyTV.Current.GetRecordingFolders() .SelectMany(i => i.Locations) |
