diff options
Diffstat (limited to 'Emby.Server.Implementations/LiveTv')
16 files changed, 203 insertions, 385 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 81a47bfea..b787e8f0f 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Globalization; @@ -254,27 +254,15 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (requiresRefresh) { - await _libraryManager.ValidateMediaLibrary(new SimpleProgress<Double>(), CancellationToken.None); + await _libraryManager.ValidateMediaLibrary(new SimpleProgress<double>(), CancellationToken.None); } } - public string Name - { - get { return "Emby"; } - } + public string Name => "Emby"; - public string DataPath - { - get { return Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv"); } - } + public string DataPath => Path.Combine(_config.CommonApplicationPaths.DataPath, "livetv"); - private string DefaultRecordingPath - { - get - { - return Path.Combine(DataPath, "recordings"); - } - } + private string DefaultRecordingPath => Path.Combine(DataPath, "recordings"); private string RecordingPath { @@ -288,10 +276,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } } - public string HomePageUrl - { - get { return "https://github.com/jellyfin/jellyfin"; } - } + public string HomePageUrl => "https://github.com/jellyfin/jellyfin"; public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress) { @@ -467,18 +452,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public ChannelInfo GetChannelByNumber(string number) { - ChannelInfo result = null; - - ChannelsByNumber.TryGetValue(number, out result); + ChannelsByNumber.TryGetValue(number, out var result); return result; } public ChannelInfo GetChannelByName(string name) { - ChannelInfo result = null; - - ChannelsByName.TryGetValue(name, out result); + ChannelsByName.TryGetValue(name, out var result); return result; } @@ -491,7 +472,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return GetEpgChannelFromTunerChannel(info, tunerChannel, epgChannels); } - private string GetMappedChannel(string channelId, NameValuePair[] mappings) + private static string GetMappedChannel(string channelId, NameValuePair[] mappings) { foreach (NameValuePair mapping in mappings) { @@ -850,7 +831,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return Task.CompletedTask; } - private void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer) + private static void UpdateExistingTimerWithNewMetadata(TimerInfo existingTimer, TimerInfo updatedTimer) { // Update the program info but retain the status existingTimer.ChannelId = updatedTimer.ChannelId; @@ -980,7 +961,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (string.IsNullOrWhiteSpace(tunerHostId)) { - throw new ArgumentNullException("tunerHostId"); + throw new ArgumentNullException(nameof(tunerHostId)); } return info.EnabledTuners.Contains(tunerHostId, StringComparer.OrdinalIgnoreCase); @@ -1055,7 +1036,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { _logger.LogInformation("Streaming Channel " + channelId); - var result = string.IsNullOrEmpty(streamId) ? + var result = string.IsNullOrEmpty(streamId) ? null : currentLiveStreams.FirstOrDefault(i => string.Equals(i.OriginalStreamId, streamId, StringComparison.OrdinalIgnoreCase)); @@ -1114,7 +1095,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (string.IsNullOrWhiteSpace(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } foreach (var hostInstance in _liveTvManager.TunerHosts) @@ -1198,14 +1179,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return; } - var registration = await _liveTvManager.GetRegistrationInfo("dvr").ConfigureAwait(false); - if (!registration.IsValid) - { - _logger.LogWarning("Emby Premiere required to use Emby DVR."); - OnTimerOutOfDate(timer); - return; - } - var activeRecordingInfo = new ActiveRecordingInfo { CancellationTokenSource = new CancellationTokenSource(), @@ -1342,7 +1315,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (timer == null) { - throw new ArgumentNullException("timer"); + throw new ArgumentNullException(nameof(timer)); } LiveTvProgram programInfo = null; @@ -1795,7 +1768,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } } - private string GetPostProcessArguments(string path, string arguments) + private static string GetPostProcessArguments(string path, string arguments) { return arguments.Replace("{path}", path, StringComparison.OrdinalIgnoreCase); } @@ -2394,80 +2367,68 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var allTimers = GetTimersForSeries(seriesTimer) .ToList(); - var registration = await _liveTvManager.GetRegistrationInfo("seriesrecordings").ConfigureAwait(false); var enabledTimersForSeries = new List<TimerInfo>(); - - if (registration.IsValid) + foreach (var timer in allTimers) { - foreach (var timer in allTimers) + var existingTimer = _timerProvider.GetTimer(timer.Id); + + if (existingTimer == null) { - var existingTimer = _timerProvider.GetTimer(timer.Id); + existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId) + ? null + : _timerProvider.GetTimerByProgramId(timer.ProgramId); + } - if (existingTimer == null) + if (existingTimer == null) + { + if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) { - existingTimer = string.IsNullOrWhiteSpace(timer.ProgramId) - ? null - : _timerProvider.GetTimerByProgramId(timer.ProgramId); + timer.Status = RecordingStatus.Cancelled; } + else + { + enabledTimersForSeries.Add(timer); + } + _timerProvider.Add(timer); + + TimerCreated?.Invoke(this, new GenericEventArgs<TimerInfo>(timer)); + } + // Only update if not currently active - test both new timer and existing in case Id's are different + // Id's could be different if the timer was created manually prior to series timer creation + else if (!_activeRecordings.TryGetValue(timer.Id, out _) && !_activeRecordings.TryGetValue(existingTimer.Id, out _)) + { + UpdateExistingTimerWithNewMetadata(existingTimer, timer); - if (existingTimer == null) + // Needed by ShouldCancelTimerForSeriesTimer + timer.IsManual = existingTimer.IsManual; + + if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) { - if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) - { - timer.Status = RecordingStatus.Cancelled; - } - else - { - enabledTimersForSeries.Add(timer); - } - _timerProvider.Add(timer); + existingTimer.Status = RecordingStatus.Cancelled; + } + else if (!existingTimer.IsManual) + { + existingTimer.Status = RecordingStatus.New; + } - if (TimerCreated != null) - { - TimerCreated(this, new GenericEventArgs<TimerInfo>(timer)); - } + if (existingTimer.Status != RecordingStatus.Cancelled) + { + enabledTimersForSeries.Add(existingTimer); } - else + + if (updateTimerSettings) { - // Only update if not currently active - test both new timer and existing in case Id's are different - // Id's could be different if the timer was created manually prior to series timer creation - ActiveRecordingInfo activeRecordingInfo; - if (!_activeRecordings.TryGetValue(timer.Id, out activeRecordingInfo) && !_activeRecordings.TryGetValue(existingTimer.Id, out activeRecordingInfo)) - { - UpdateExistingTimerWithNewMetadata(existingTimer, timer); - - // Needed by ShouldCancelTimerForSeriesTimer - timer.IsManual = existingTimer.IsManual; - - if (ShouldCancelTimerForSeriesTimer(seriesTimer, timer)) - { - existingTimer.Status = RecordingStatus.Cancelled; - } - else if (!existingTimer.IsManual) - { - existingTimer.Status = RecordingStatus.New; - } - - if (existingTimer.Status != RecordingStatus.Cancelled) - { - enabledTimersForSeries.Add(existingTimer); - } - - if (updateTimerSettings) - { - existingTimer.KeepUntil = seriesTimer.KeepUntil; - existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired; - existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired; - existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds; - existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds; - existingTimer.Priority = seriesTimer.Priority; - } - - existingTimer.SeriesTimerId = seriesTimer.Id; - _timerProvider.Update(existingTimer); - } + existingTimer.KeepUntil = seriesTimer.KeepUntil; + existingTimer.IsPostPaddingRequired = seriesTimer.IsPostPaddingRequired; + existingTimer.IsPrePaddingRequired = seriesTimer.IsPrePaddingRequired; + existingTimer.PostPaddingSeconds = seriesTimer.PostPaddingSeconds; + existingTimer.PrePaddingSeconds = seriesTimer.PrePaddingSeconds; + existingTimer.Priority = seriesTimer.Priority; } + + existingTimer.SeriesTimerId = seriesTimer.Id; + _timerProvider.Update(existingTimer); } } @@ -2501,7 +2462,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (seriesTimer == null) { - throw new ArgumentNullException("seriesTimer"); + throw new ArgumentNullException(nameof(seriesTimer)); } var query = new InternalItemsQuery @@ -2536,9 +2497,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (string.IsNullOrWhiteSpace(channelId) && !parent.ChannelId.Equals(Guid.Empty)) { - LiveTvChannel channel; - - if (!tempChannelCache.TryGetValue(parent.ChannelId, out channel)) + if (!tempChannelCache.TryGetValue(parent.ChannelId, out var channel)) { channel = _libraryManager.GetItemList(new InternalItemsQuery { @@ -2597,9 +2556,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (!programInfo.ChannelId.Equals(Guid.Empty)) { - LiveTvChannel channel; - - if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out channel)) + if (!tempChannelCache.TryGetValue(programInfo.ChannelId, out var channel)) { channel = _libraryManager.GetItemList(new InternalItemsQuery { @@ -2797,15 +2754,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { var configuredDevice = configuredDevices.FirstOrDefault(i => string.Equals(i.DeviceId, device.DeviceId, StringComparison.OrdinalIgnoreCase)); - if (configuredDevice != null) + if (configuredDevice != null && !string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase)) { - if (!string.Equals(device.Url, configuredDevice.Url, StringComparison.OrdinalIgnoreCase)) - { - _logger.LogInformation("Tuner url has changed from {0} to {1}", configuredDevice.Url, device.Url); + _logger.LogInformation("Tuner url has changed from {PreviousUrl} to {NewUrl}", configuredDevice.Url, device.Url); - configuredDevice.Url = device.Url; - await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false); - } + configuredDevice.Url = device.Url; + await _liveTvManager.SaveTunerHost(configuredDevice).ConfigureAwait(false); } } } diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index 4ea83b7ac..292f3621d 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -55,14 +55,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _assemblyInfo = assemblyInfo; } - private bool CopySubtitles - { - get - { - return false; - //return string.Equals(OutputFormat, "mkv", StringComparison.OrdinalIgnoreCase); - } - } + private static bool CopySubtitles => false; public string GetOutputPath(MediaSourceInfo mediaSource, string targetFile) { @@ -214,19 +207,19 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var outputParam = string.Empty; - var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"", - inputTempFile, - targetFile, - videoArgs, - GetAudioArgs(mediaSource), - subtitleArgs, - durationParam, + var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"", + inputTempFile, + targetFile, + videoArgs, + GetAudioArgs(mediaSource), + subtitleArgs, + durationParam, outputParam); return inputModifier + " " + commandLineArgs; } - private string GetAudioArgs(MediaSourceInfo mediaSource) + private static string GetAudioArgs(MediaSourceInfo mediaSource) { var mediaStreams = mediaSource.MediaStreams ?? new List<MediaStream>(); var inputAudioCodec = mediaStreams.Where(i => i.Type == MediaStreamType.Audio).Select(i => i.Codec).FirstOrDefault() ?? string.Empty; @@ -242,7 +235,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV //return "-codec:a:0 aac -strict experimental -ab 320000"; } - private bool EncodeVideo(MediaSourceInfo mediaSource) + private static bool EncodeVideo(MediaSourceInfo mediaSource) { return false; } @@ -383,6 +376,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV } catch (ObjectDisposedException) { + // TODO Investigate and properly fix. // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux } catch (Exception ex) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 9f179dc2c..593f98881 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -68,7 +68,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (newList == null) { - throw new ArgumentNullException("newList"); + throw new ArgumentNullException(nameof(newList)); } var file = _dataPath + ".json"; @@ -85,7 +85,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var list = GetAll().ToList(); @@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { if (item == null) { - throw new ArgumentNullException("item"); + throw new ArgumentNullException(nameof(item)); } var list = GetAll().ToList(); diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs index e4ab34770..bdc6ae009 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Globalization; using System.Linq; @@ -90,7 +90,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV AddOrUpdateSystemTimer(item); } - private bool ShouldStartTimer(TimerInfo item) + private static bool ShouldStartTimer(TimerInfo item) { if (item.Status == RecordingStatus.Completed || item.Status == RecordingStatus.Cancelled) diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index e8ffd0caa..0ba8c8b42 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -1,4 +1,4 @@ -using System.Net; +using System.Net; using MediaBrowser.Common; using MediaBrowser.Common.Net; using MediaBrowser.Controller.LiveTv; @@ -38,12 +38,9 @@ namespace Emby.Server.Implementations.LiveTv.Listings _appHost = appHost; } - private string UserAgent - { - get { return "Emby/" + _appHost.ApplicationVersion; } - } + private string UserAgent => "Emby/" + _appHost.ApplicationVersion; - private List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc) + private static List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc) { List<string> dates = new List<string>(); @@ -63,7 +60,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings { if (string.IsNullOrEmpty(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } // Normalize incoming input @@ -189,7 +186,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - private int GetSizeOrder(ScheduleDirect.ImageData image) + private static int GetSizeOrder(ScheduleDirect.ImageData image) { if (!string.IsNullOrWhiteSpace(image.height)) { @@ -202,7 +199,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return 0; } - private string GetChannelNumber(ScheduleDirect.Map map) + private static string GetChannelNumber(ScheduleDirect.Map map) { var channelNumber = map.logicalChannelNumber; @@ -218,7 +215,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return channelNumber.TrimStart('0'); } - private bool IsMovie(ScheduleDirect.ProgramDetails programInfo) + private static bool IsMovie(ScheduleDirect.ProgramDetails programInfo) { return string.Equals(programInfo.entityType, "movie", StringComparison.OrdinalIgnoreCase); } @@ -390,7 +387,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return info; } - private DateTime GetDate(string value) + private static DateTime GetDate(string value) { var date = DateTime.ParseExact(value, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture); @@ -429,7 +426,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - private double GetAspectRatio(ScheduleDirect.ImageData i) + private static double GetAspectRatio(ScheduleDirect.ImageData i) { int width = 0; int height = 0; @@ -664,7 +661,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false);; + options.RequestHeaders["token"] = await GetToken(providerInfo, options.CancellationToken).ConfigureAwait(false); return await Post(options, false, providerInfo).ConfigureAwait(false); } @@ -765,16 +762,10 @@ namespace Emby.Server.Implementations.LiveTv.Listings } } - public string Name - { - get { return "Schedules Direct"; } - } + public string Name => "Schedules Direct"; public static string TypeName = "SchedulesDirect"; - public string Type - { - get { return TypeName; } - } + public string Type => TypeName; private async Task<bool> HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken) { @@ -951,7 +942,7 @@ namespace Emby.Server.Implementations.LiveTv.Listings return null; } - private string NormalizeName(string value) + private static string NormalizeName(string value) { return value.Replace(" ", string.Empty).Replace("-", string.Empty); } diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs index 4d7c7fef4..2b1ee84a8 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs @@ -36,15 +36,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings _zipClient = zipClient; } - public string Name - { - get { return "XmlTV"; } - } + public string Name => "XmlTV"; - public string Type - { - get { return "xmltv"; } - } + public string Type => "xmltv"; private string GetLanguage(ListingsProviderInfo info) { @@ -78,7 +72,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings { CancellationToken = cancellationToken, Url = path, - Progress = new SimpleProgress<Double>(), + Progress = new SimpleProgress<double>(), DecompressionMethod = CompressionMethod.Gzip, // It's going to come back gzipped regardless of this value @@ -164,7 +158,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings { if (string.IsNullOrWhiteSpace(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } /* @@ -187,7 +181,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings .Select(p => GetProgramInfo(p, info)); } - private ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info) + private static ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info) { string episodeTitle = program.Episode?.Title; @@ -210,9 +204,9 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings IsMovie = program.Categories.Any(c => info.MovieCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), IsNews = program.Categories.Any(c => info.NewsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), IsSports = program.Categories.Any(c => info.SportsCategories.Contains(c, StringComparer.OrdinalIgnoreCase)), - ImageUrl = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null, - HasImage = program.Icon != null && !String.IsNullOrEmpty(program.Icon.Source), - OfficialRating = program.Rating != null && !String.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null, + ImageUrl = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source) ? program.Icon.Source : null, + HasImage = program.Icon != null && !string.IsNullOrEmpty(program.Icon.Source), + OfficialRating = program.Rating != null && !string.IsNullOrEmpty(program.Rating.Value) ? program.Rating.Value : null, CommunityRating = program.StarRating, SeriesId = program.Episode == null ? null : program.Title.GetMD5().ToString("N") }; @@ -246,7 +240,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings } // Construct an id from the channel and start date - programInfo.Id = String.Format("{0}_{1:O}", program.ChannelId, program.StartDate); + programInfo.Id = string.Format("{0}_{1:O}", program.ChannelId, program.StartDate); if (programInfo.IsMovie) { @@ -294,7 +288,7 @@ namespace Jellyfin.Server.Implementations.LiveTv.Listings { Id = c.Id, Name = c.DisplayName, - ImageUrl = c.Icon != null && !String.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null, + ImageUrl = c.Icon != null && !string.IsNullOrEmpty(c.Icon.Source) ? c.Icon.Source : null, Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number }).ToList(); diff --git a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs index 6fe578715..7397d4b60 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common; +using MediaBrowser.Common; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.Dto; @@ -321,6 +321,7 @@ namespace Emby.Server.Implementations.LiveTv } catch (Exception ex) { + _logger.LogDebug(ex, "GetImageCacheTag raised an exception in LiveTvDtoService.FillImages."); } } @@ -331,10 +332,10 @@ namespace Emby.Server.Implementations.LiveTv { try { - dto.ParentBackdropImageTags = new string[] - { - _imageProcessor.GetImageCacheTag(program, image) - }; + dto.ParentBackdropImageTags = new[] + { + _imageProcessor.GetImageCacheTag(program, image) + }; dto.ParentBackdropItemId = program.Id.ToString("N"); } catch (Exception ex) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index a81a0bcbb..c360a6a82 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Configuration; @@ -22,7 +22,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.IO; -using MediaBrowser.Common.Security; using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Events; @@ -51,7 +50,6 @@ namespace Emby.Server.Implementations.LiveTv private readonly ITaskManager _taskManager; private readonly IJsonSerializer _jsonSerializer; private readonly IProviderManager _providerManager; - private readonly ISecurityManager _security; private readonly Func<IChannelManager> _channelManager; private readonly IDtoService _dtoService; @@ -78,7 +76,23 @@ namespace Emby.Server.Implementations.LiveTv private IServerApplicationHost _appHost; private IHttpClient _httpClient; - public LiveTvManager(IServerApplicationHost appHost, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager, IFileSystem fileSystem, ISecurityManager security, Func<IChannelManager> channelManager) + public LiveTvManager( + IServerApplicationHost appHost, + IHttpClient httpClient, + IServerConfigurationManager config, + ILogger logger, + IItemRepository itemRepo, + IImageProcessor imageProcessor, + IUserDataManager userDataManager, + IDtoService dtoService, + IUserManager userManager, + ILibraryManager libraryManager, + ITaskManager taskManager, + ILocalizationManager localization, + IJsonSerializer jsonSerializer, + IProviderManager providerManager, + IFileSystem fileSystem, + Func<IChannelManager> channelManager) { _appHost = appHost; _config = config; @@ -91,7 +105,6 @@ namespace Emby.Server.Implementations.LiveTv _jsonSerializer = jsonSerializer; _providerManager = providerManager; _fileSystem = fileSystem; - _security = security; _dtoService = dtoService; _userDataManager = userDataManager; _channelManager = channelManager; @@ -104,10 +117,7 @@ namespace Emby.Server.Implementations.LiveTv /// Gets the services. /// </summary> /// <value>The services.</value> - public IReadOnlyList<ILiveTvService> Services - { - get { return _services; } - } + public IReadOnlyList<ILiveTvService> Services => _services; private LiveTvOptions GetConfiguration() { @@ -167,15 +177,9 @@ namespace Emby.Server.Implementations.LiveTv }); } - public ITunerHost[] TunerHosts - { - get { return _tunerHosts; } - } + public ITunerHost[] TunerHosts => _tunerHosts; - public IListingsProvider[] ListingProviders - { - get { return _listingProviders; } - } + public IListingsProvider[] ListingProviders => _listingProviders; public List<NameIdPair> GetTunerHostTypes() { @@ -323,7 +327,7 @@ namespace Emby.Server.Implementations.LiveTv return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); } - private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) + private static void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) { // Not all of the plugins are setting this mediaSource.IsInfiniteStream = true; @@ -1418,6 +1422,7 @@ namespace Emby.Server.Implementations.LiveTv if (query.IsInProgress ?? false) { + //TODO Fix The co-variant conversion between Video[] and BaseItem[], this can generate runtime issues. result.Items = result .Items .OfType<Video>() @@ -1993,7 +1998,7 @@ namespace Emby.Server.Implementations.LiveTv Name = program.Name, OfficialRating = program.OfficialRating }; - } + } if (service == null) { @@ -2095,14 +2100,6 @@ namespace Emby.Server.Implementations.LiveTv public async Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken) { - var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false); - - if (!registration.IsValid) - { - _logger.LogInformation("Creating series recordings requires an active Emby Premiere subscription."); - return; - } - var service = GetService(timer.ServiceName); var info = await _tvDtoService.GetSeriesTimerInfo(timer, true, this, cancellationToken).ConfigureAwait(false); @@ -2188,7 +2185,7 @@ namespace Emby.Server.Implementations.LiveTv return Services.Select(GetServiceInfo).ToArray(); } - private LiveTvServiceInfo GetServiceInfo(ILiveTvService service) + private static LiveTvServiceInfo GetServiceInfo(ILiveTvService service) { return new LiveTvServiceInfo { @@ -2245,7 +2242,7 @@ namespace Emby.Server.Implementations.LiveTv return service.ResetTuner(parts[1], cancellationToken); } - private void RemoveFields(DtoOptions options) + private static void RemoveFields(DtoOptions options) { var fields = options.Fields.ToList(); @@ -2444,30 +2441,6 @@ namespace Emby.Server.Implementations.LiveTv } } - public Task<MBRegistrationRecord> GetRegistrationInfo(string feature) - { - if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase)) - { - feature = "embytvseriesrecordings"; - } - - if (string.Equals(feature, "dvr-l", StringComparison.OrdinalIgnoreCase)) - { - var config = GetConfiguration(); - if (config.TunerHosts.Length > 0 && - config.ListingProviders.Count(i => (i.EnableAllTuners || i.EnabledTuners.Length > 0) && string.Equals(i.Type, SchedulesDirect.TypeName, StringComparison.OrdinalIgnoreCase)) > 0) - { - return Task.FromResult(new MBRegistrationRecord - { - IsRegistered = true, - IsValid = true - }); - } - } - - return _security.GetRegistrationStatus(feature); - } - public Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken) { var info = GetConfiguration().ListingProviders.First(i => string.Equals(i.Id, id, StringComparison.OrdinalIgnoreCase)); diff --git a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index 225360159..29196a068 100644 --- a/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/Emby.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -20,20 +20,11 @@ namespace Emby.Server.Implementations.LiveTv _config = config; } - public string Name - { - get { return "Refresh Guide"; } - } + public string Name => "Refresh Guide"; - public string Description - { - get { return "Downloads channel information from live tv services."; } - } + public string Description => "Downloads channel information from live tv services."; - public string Category - { - get { return "Live TV"; } - } + public string Category => "Live TV"; public Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress) { @@ -48,8 +39,8 @@ namespace Emby.Server.Implementations.LiveTv /// <returns>IEnumerable{BaseTaskTrigger}.</returns> public IEnumerable<TaskTriggerInfo> GetDefaultTriggers() { - return new[] { - + return new[] { + // Every so often new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks} }; @@ -60,24 +51,12 @@ namespace Emby.Server.Implementations.LiveTv return _config.GetConfiguration<LiveTvOptions>("livetv"); } - public bool IsHidden - { - get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0; } - } + public bool IsHidden => _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Length == 0; - public bool IsEnabled - { - get { return true; } - } + public bool IsEnabled => true; - public bool IsLogged - { - get { return true; } - } + public bool IsLogged => true; - public string Key - { - get { return "RefreshGuide"; } - } + public string Key => "RefreshGuide"; } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs index ef2010ba6..78514c1d9 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/BaseTunerHost.cs @@ -40,13 +40,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts FileSystem = fileSystem; } - public virtual bool IsSupported - { - get - { - return true; - } - } + public virtual bool IsSupported => true; protected abstract Task<List<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken); public abstract string Type { get; } @@ -140,7 +134,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { if (string.IsNullOrEmpty(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } if (IsValidChannelId(channelId)) @@ -175,7 +169,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts { if (string.IsNullOrEmpty(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } if (!IsValidChannelId(channelId)) @@ -228,18 +222,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts throw new LiveTvConflictException(); } - protected virtual string ChannelIdPrefix - { - get - { - return Type + "_"; - } - } + protected virtual string ChannelIdPrefix => Type + "_"; + protected virtual bool IsValidChannelId(string channelId) { if (string.IsNullOrEmpty(channelId)) { - throw new ArgumentNullException("channelId"); + throw new ArgumentNullException(nameof(channelId)); } return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index be090df0c..3ae47f3ab 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.Dto; @@ -42,28 +42,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun _environment = environment; } - public string Name - { - get { return "HD Homerun"; } - } + public string Name => "HD Homerun"; - public override string Type - { - get { return DeviceType; } - } + public override string Type => DeviceType; - public static string DeviceType - { - get { return "hdhomerun"; } - } + public static string DeviceType => "hdhomerun"; - protected override string ChannelIdPrefix - { - get - { - return "hdhr_"; - } - } + protected override string ChannelIdPrefix => "hdhr_"; private string GetChannelId(TunerHostInfo info, Channels i) { @@ -274,7 +259,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun for (int i = 0; i < model.TunerCount; ++i) { - var name = String.Format("Tuner {0}", i + 1); + var name = string.Format("Tuner {0}", i + 1); var currentChannel = "none"; /// @todo Get current channel and map back to Station Id var isAvailable = await manager.CheckTunerAvailability(ipInfo, i, cancellationToken).ConfigureAwait(false); LiveTvTunerStatus status = isAvailable ? LiveTvTunerStatus.Available : LiveTvTunerStatus.LiveTv; @@ -325,7 +310,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun return await GetTunerInfosHttp(info, cancellationToken).ConfigureAwait(false); } - private string GetApiUrl(TunerHostInfo info) + private static string GetApiUrl(TunerHostInfo info) { var url = info.Url; @@ -359,7 +344,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun return Config.GetConfiguration<EncodingOptions>("encoding"); } - private string GetHdHrIdFromChannelId(string channelId) + private static string GetHdHrIdFromChannelId(string channelId) { return channelId.Split('_')[1]; } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs index 0e84622bd..335fc4cb4 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs @@ -37,10 +37,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { var commands = new List<Tuple<string, string>>(); - if (!String.IsNullOrEmpty(_channel)) + if (!string.IsNullOrEmpty(_channel)) commands.Add(Tuple.Create("channel", _channel)); - if (!String.IsNullOrEmpty(_program)) + if (!string.IsNullOrEmpty(_program)) commands.Add(Tuple.Create("program", _program)); return commands; } @@ -61,11 +61,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { var commands = new List<Tuple<string, string>>(); - if (!String.IsNullOrEmpty(_channel)) + if (!string.IsNullOrEmpty(_channel)) { if (!string.IsNullOrEmpty(_profile) && !string.Equals(_profile, "native", StringComparison.OrdinalIgnoreCase)) { - commands.Add(Tuple.Create("vchannel", String.Format("{0} transcode={1}", _channel, _profile))); + commands.Add(Tuple.Create("vchannel", string.Format("{0} transcode={1}", _channel, _profile))); } else { @@ -123,7 +123,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun } } - private async Task<bool> CheckTunerAvailability(ISocket socket, IpAddressInfo remoteIp, int tuner, CancellationToken cancellationToken) + private static async Task<bool> CheckTunerAvailability(ISocket socket, IpAddressInfo remoteIp, int tuner, CancellationToken cancellationToken) { var ipEndPoint = new IpEndPointInfo(remoteIp, HdHomeRunPort); @@ -164,7 +164,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun continue; _activeTuner = i; - var lockKeyString = String.Format("{0:d}", lockKeyValue); + var lockKeyString = string.Format("{0:d}", lockKeyValue); var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null); await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); @@ -188,7 +188,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun } - var targetValue = String.Format("rtp://{0}:{1}", localIp, localPort); + var targetValue = string.Format("rtp://{0}:{1}", localIp, localPort); var targetMsg = CreateSetMessage(i, "target", targetValue, lockKeyValue); await tcpClient.SendToAsync(targetMsg, 0, targetMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); @@ -262,7 +262,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private static byte[] CreateGetMessage(int tuner, string name) { - var byteName = Encoding.UTF8.GetBytes(String.Format("/tuner{0}/{1}\0", tuner, name)); + var byteName = Encoding.UTF8.GetBytes(string.Format("/tuner{0}/{1}\0", tuner, name)); int messageLength = byteName.Length + 10; // 4 bytes for header + 4 bytes for crc + 2 bytes for tag name and length var message = new byte[messageLength]; @@ -280,10 +280,10 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun return message; } - private static byte[] CreateSetMessage(int tuner, String name, String value, uint? lockkey) + private static byte[] CreateSetMessage(int tuner, string name, string value, uint? lockkey) { - var byteName = Encoding.UTF8.GetBytes(String.Format("/tuner{0}/{1}\0", tuner, name)); - var byteValue = Encoding.UTF8.GetBytes(String.Format("{0}\0", value)); + var byteName = Encoding.UTF8.GetBytes(string.Format("/tuner{0}/{1}\0", tuner, name)); + var byteValue = Encoding.UTF8.GetBytes(string.Format("{0}\0", value)); int messageLength = byteName.Length + byteValue.Length + 12; if (lockkey.HasValue) @@ -360,7 +360,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private static bool ParseReturnMessage(byte[] buf, int numBytes, out string returnVal) { - returnVal = String.Empty; + returnVal = string.Empty; if (numBytes < 4) return false; @@ -411,7 +411,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private class HdHomerunCrc { - private static UInt32[] crc_table = { + private static uint[] crc_table = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, @@ -477,7 +477,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; - public static UInt32 GetCrc32(byte[] bytes, int numBytes) + public static uint GetCrc32(byte[] bytes, int numBytes) { var hash = 0xffffffff; for (var i = 0; i < numBytes; i++) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs index c781bccbb..fd78dfa8e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -38,7 +38,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun EnableStreamSharing = true; } - private Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) + private static Socket CreateSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType) { var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp); @@ -144,7 +144,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun }); } - private void Resolve(TaskCompletionSource<bool> openTaskCompletionSource) + private static void Resolve(TaskCompletionSource<bool> openTaskCompletionSource) { Task.Run(() => { @@ -204,16 +204,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) - throw new ArgumentNullException("buffer"); + throw new ArgumentNullException(nameof(buffer)); if (offset + count < 0) - throw new ArgumentOutOfRangeException("offset + count must not be negative", "offset+count"); + throw new ArgumentOutOfRangeException(nameof(offset), "offset + count must not be negative"); if (offset + count > buffer.Length) - throw new ArgumentException("offset + count must not be greater than the length of buffer", "offset+count"); + throw new ArgumentException("offset + count must not be greater than the length of buffer"); if (disposed) - throw new ObjectDisposedException(typeof(UdpClientStream).ToString()); + throw new ObjectDisposedException(nameof(UdpClientStream)); // This will always receive a 1328 packet size (PacketSize + RtpHeaderSize) // The RTP header will be stripped so see how many reads we need to make to fill the buffer. @@ -238,16 +238,16 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun public override int Read(byte[] buffer, int offset, int count) { if (buffer == null) - throw new ArgumentNullException("buffer"); + throw new ArgumentNullException(nameof(buffer)); if (offset + count < 0) throw new ArgumentOutOfRangeException("offset + count must not be negative", "offset+count"); if (offset + count > buffer.Length) - throw new ArgumentException("offset + count must not be greater than the length of buffer", "offset+count"); + throw new ArgumentException("offset + count must not be greater than the length of buffer"); if (disposed) - throw new ObjectDisposedException(typeof(UdpClientStream).ToString()); + throw new ObjectDisposedException(nameof(UdpClientStream)); // This will always receive a 1328 packet size (PacketSize + RtpHeaderSize) // The RTP header will be stripped so see how many reads we need to make to fill the buffer. @@ -274,49 +274,19 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun disposed = true; } - public override bool CanRead - { - get - { - throw new NotImplementedException(); - } - } + public override bool CanRead => throw new NotImplementedException(); - public override bool CanSeek - { - get - { - throw new NotImplementedException(); - } - } + public override bool CanSeek => throw new NotImplementedException(); - public override bool CanWrite - { - get - { - throw new NotImplementedException(); - } - } + public override bool CanWrite => throw new NotImplementedException(); - public override long Length - { - get - { - throw new NotImplementedException(); - } - } + public override long Length => throw new NotImplementedException(); public override long Position { - get - { - throw new NotImplementedException(); - } + get => throw new NotImplementedException(); - set - { - throw new NotImplementedException(); - } + set => throw new NotImplementedException(); } public override void Flush() diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs index 4a2b4ebb2..b55b02ddc 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs @@ -217,13 +217,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts } } - protected virtual int EmptyReadLimit - { - get - { - return 1000; - } - } + protected virtual int EmptyReadLimit => 1000; private void TrySeek(FileStream stream, long offset) { diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index a54bd1613..ab8731c39 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -39,15 +39,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts _mediaSourceManager = mediaSourceManager; } - public override string Type - { - get { return "m3u"; } - } + public override string Type => "m3u"; - public virtual string Name - { - get { return "M3U Tuner"; } - } + public virtual string Name => "M3U Tuner"; private string GetFullChannelIdPrefix(TunerHostInfo info) { diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs index 208225c1e..f83f95802 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3uParser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -251,7 +251,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return numberString; } - private bool IsValidChannelNumber(string numberString) + private static bool IsValidChannelNumber(string numberString) { if (string.IsNullOrWhiteSpace(numberString) || string.Equals(numberString, "-1", StringComparison.OrdinalIgnoreCase) || @@ -269,7 +269,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return true; } - private string GetChannelName(string extInf, Dictionary<string, string> attributes) + private static string GetChannelName(string extInf, Dictionary<string, string> attributes) { var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; @@ -314,7 +314,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts return name; } - private Dictionary<string, string> ParseExtInf(string line, out string remaining) + private static Dictionary<string, string> ParseExtInf(string line, out string remaining) { var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); |
