public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service) { var dto = new TimerInfoDto { Id = GetInternalTimerId(service.Name, info.Id).ToString("N"), ChannelName = info.ChannelName, Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, ExternalChannelId = info.ChannelId, ExternalSeriesTimerId = info.SeriesTimerId, ServiceName = service.Name, ExternalProgramId = info.ProgramId, Priority = info.Priority }; var duration = info.EndDate - info.StartDate; dto.DurationMs = Convert.ToInt32(duration.TotalMilliseconds); if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } return dto; }
public ExclusiveLiveStream(MediaSourceInfo mediaSource, ILiveTvService liveTvService, string openedId) { MediaSource = mediaSource; EnableStreamSharing = false; _liveTvService = liveTvService; _openedId = openedId; }
private LiveTvServiceInfo GetServiceInfo(ILiveTvService service) { return(new LiveTvServiceInfo { Name = service.Name }); }
public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel) { var dto = new TimerInfoDto { Id = GetInternalTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, KeepUntil = info.KeepUntil, ExternalChannelId = info.ChannelId, ExternalSeriesTimerId = info.SeriesTimerId, ServiceName = service.Name, ExternalProgramId = info.ProgramId, Priority = info.Priority, RunTimeTicks = (info.EndDate - info.StartDate).Ticks, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (program != null) { dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions()); if (info.Status != RecordingStatus.Cancelled && info.Status != RecordingStatus.Error) { dto.ProgramInfo.TimerId = dto.Id; dto.ProgramInfo.Status = info.Status.ToString(); } dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId; if (!string.IsNullOrWhiteSpace(info.SeriesTimerId)) { FillImages(dto.ProgramInfo, info.Name, info.SeriesId); } } if (channel != null) { dto.ChannelName = channel.Name; } return(dto); }
public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel) { var dto = new TimerInfoDto { Id = GetInternalTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, KeepUntil = info.KeepUntil, ExternalChannelId = info.ChannelId, ExternalSeriesTimerId = info.SeriesTimerId, ServiceName = service.Name, ExternalProgramId = info.ProgramId, Priority = info.Priority, RunTimeTicks = (info.EndDate - info.StartDate).Ticks, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (program != null) { dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions()); if (info.Status != RecordingStatus.Cancelled && info.Status != RecordingStatus.Error) { dto.ProgramInfo.TimerId = dto.Id; dto.ProgramInfo.Status = info.Status.ToString(); } dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId; } if (channel != null) { dto.ChannelName = channel.Name; } return dto; }
public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel) { var dto = new TimerInfoDto { Id = GetInternalTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, ExternalChannelId = info.ChannelId, ExternalSeriesTimerId = info.SeriesTimerId, ServiceName = service.Name, ExternalProgramId = info.ProgramId, Priority = info.Priority, RunTimeTicks = (info.EndDate - info.StartDate).Ticks, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (program != null) { dto.ProgramInfo = GetProgramInfoDto(program, channel); dto.ProgramInfo.TimerId = dto.Id; dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId; } if (channel != null) { dto.ChannelName = channel.Name; } return(dto); }
public TimerInfoDto GetTimerInfoDto(TimerInfo info, ILiveTvService service, LiveTvProgram program, LiveTvChannel channel) { var dto = new TimerInfoDto { Id = GetInternalTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, ExternalChannelId = info.ChannelId, ExternalSeriesTimerId = info.SeriesTimerId, ServiceName = service.Name, ExternalProgramId = info.ProgramId, Priority = info.Priority, RunTimeTicks = (info.EndDate - info.StartDate).Ticks }; if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (program != null) { dto.ProgramInfo = GetProgramInfoDto(program, channel); dto.ProgramInfo.TimerId = dto.Id; dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId; } if (channel != null) { dto.ChannelName = channel.Name; } return dto; }
public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvService service, string channelName) { var dto = new SeriesTimerInfoDto { Id = GetInternalSeriesTimerId(info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, Days = info.Days.ToArray(), Priority = info.Priority, RecordAnyChannel = info.RecordAnyChannel, RecordAnyTime = info.RecordAnyTime, SkipEpisodesInLibrary = info.SkipEpisodesInLibrary, KeepUpTo = info.KeepUpTo, KeepUntil = info.KeepUntil, RecordNewOnly = info.RecordNewOnly, ExternalChannelId = info.ChannelId, ExternalProgramId = info.ProgramId, ServiceName = service.Name, ChannelName = channelName, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ChannelId)) { dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(info.ProgramId).ToString("N"); } dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days.ToArray()); FillImages(dto, info.Name, info.SeriesId); return(dto); }
public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvService service, string channelName) { var dto = new SeriesTimerInfoDto { Id = GetInternalSeriesTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, Days = info.Days, Priority = info.Priority, RecordAnyChannel = info.RecordAnyChannel, RecordAnyTime = info.RecordAnyTime, RecordNewOnly = info.RecordNewOnly, ExternalChannelId = info.ChannelId, ExternalProgramId = info.ProgramId, ServiceName = service.Name, ChannelName = channelName, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ChannelId)) { dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days); return dto; }
public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvService service, string channelName) { var dto = new SeriesTimerInfoDto { Id = GetInternalSeriesTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, Days = info.Days, Priority = info.Priority, RecordAnyChannel = info.RecordAnyChannel, RecordAnyTime = info.RecordAnyTime, RecordNewOnly = info.RecordNewOnly, ExternalChannelId = info.ChannelId, ExternalProgramId = info.ProgramId, ServiceName = service.Name, ChannelName = channelName }; if (!string.IsNullOrEmpty(info.ChannelId)) { dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days); return(dto); }
private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) { if (mediaSource.MediaStreams.Count == 0) { if (isVideo) { mediaSource.MediaStreams.AddRange(new List<MediaStream> { new MediaStream { Type = MediaStreamType.Video, // Set the index to -1 because we don't know the exact index of the video stream within the container Index = -1, // Set to true if unknown to enable deinterlacing IsInterlaced = true }, new MediaStream { Type = MediaStreamType.Audio, // Set the index to -1 because we don't know the exact index of the audio stream within the container Index = -1 } }); } else { mediaSource.MediaStreams.AddRange(new List<MediaStream> { new MediaStream { Type = MediaStreamType.Audio, // Set the index to -1 because we don't know the exact index of the audio stream within the container Index = -1 } }); } } // Clean some bad data coming from providers foreach (var stream in mediaSource.MediaStreams) { if (stream.BitRate.HasValue && stream.BitRate <= 0) { stream.BitRate = null; } if (stream.Channels.HasValue && stream.Channels <= 0) { stream.Channels = null; } if (stream.AverageFrameRate.HasValue && stream.AverageFrameRate <= 0) { stream.AverageFrameRate = null; } if (stream.RealFrameRate.HasValue && stream.RealFrameRate <= 0) { stream.RealFrameRate = null; } if (stream.Width.HasValue && stream.Width <= 0) { stream.Width = null; } if (stream.Height.HasValue && stream.Height <= 0) { stream.Height = null; } if (stream.SampleRate.HasValue && stream.SampleRate <= 0) { stream.SampleRate = null; } if (stream.Level.HasValue && stream.Level <= 0) { stream.Level = null; } } var indexes = mediaSource.MediaStreams.Select(i => i.Index).Distinct().ToList(); // If there are duplicate stream indexes, set them all to unknown if (indexes.Count != mediaSource.MediaStreams.Count) { foreach (var stream in mediaSource.MediaStreams) { stream.Index = -1; } } // Set the total bitrate if not already supplied if (!mediaSource.Bitrate.HasValue) { var total = mediaSource.MediaStreams.Select(i => i.BitRate ?? 0).Sum(); if (total > 0) { mediaSource.Bitrate = total; } } if (!(service is EmbyTV.EmbyTV)) { // We can't trust that we'll be able to direct stream it through emby server, no matter what the provider says mediaSource.SupportsDirectStream = false; mediaSource.SupportsTranscoding = true; foreach (var stream in mediaSource.MediaStreams) { if (stream.Type == MediaStreamType.Video && string.IsNullOrWhiteSpace(stream.NalLengthSize)) { stream.NalLengthSize = "0"; } } } }
public RecordingInfoDto GetRecordingInfoDto(ILiveTvRecording recording, LiveTvChannel channel, ILiveTvService service, User user = null) { var info = recording.RecordingInfo; var dto = new RecordingInfoDto { Id = GetInternalRecordingId(service.Name, info.Id).ToString("N"), SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), Type = recording.GetClientTypeName(), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, StatusName = GetStatusName(info.Status), Path = info.Path, Genres = info.Genres, IsRepeat = info.IsRepeat, EpisodeTitle = info.EpisodeTitle, ChannelType = info.ChannelType, MediaType = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video, CommunityRating = GetClientCommunityRating(info.CommunityRating), OfficialRating = info.OfficialRating, Audio = info.Audio, IsHD = info.IsHD, ServiceName = service.Name, IsMovie = info.IsMovie, IsSeries = info.IsSeries, IsSports = info.IsSports, IsLive = info.IsLive, IsNews = info.IsNews, IsKids = info.IsKids, IsPremiere = info.IsPremiere, RunTimeTicks = (info.EndDate - info.StartDate).Ticks, OriginalAirDate = info.OriginalAirDate, MediaSources = recording.GetMediaSources(true).ToList() }; dto.MediaStreams = dto.MediaSources.SelectMany(i => i.MediaStreams).ToList(); if (info.Status == RecordingStatus.InProgress) { var now = DateTime.UtcNow.Ticks; var start = info.StartDate.Ticks; var end = info.EndDate.Ticks; var pct = now - start; pct /= end; pct *= 100; dto.CompletionPercentage = pct; } var imageTag = GetImageTag(recording); if (imageTag != null) { dto.ImageTags[ImageType.Primary] = imageTag; _dtoService.AttachPrimaryImageAspectRatio(dto, recording); } if (user != null) { dto.UserData = _userDataManager.GetUserDataDto(recording, user); dto.PlayAccess = recording.GetPlayAccess(user); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (channel != null) { dto.ChannelName = channel.Name; if (!string.IsNullOrEmpty(channel.PrimaryImagePath)) { dto.ChannelPrimaryImageTag = GetImageTag(channel); } } return dto; }
public RecordingInfoDto GetRecordingInfoDto(ILiveTvRecording recording, LiveTvChannel channel, ILiveTvService service, User user = null) { var info = recording.RecordingInfo; var dto = new RecordingInfoDto { Id = GetInternalRecordingId(service.Name, info.Id).ToString("N"), SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), Type = recording.GetClientTypeName(), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, StatusName = GetStatusName(info.Status), Path = info.Path, Genres = info.Genres, IsRepeat = info.IsRepeat, EpisodeTitle = info.EpisodeTitle, ChannelType = info.ChannelType, MediaType = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video, CommunityRating = GetClientCommunityRating(info.CommunityRating), OfficialRating = info.OfficialRating, Audio = info.Audio, IsHD = info.IsHD, ServiceName = service.Name, IsMovie = info.IsMovie, IsSeries = info.IsSeries, IsSports = info.IsSports, IsLive = info.IsLive, IsNews = info.IsNews, IsKids = info.IsKids, IsPremiere = info.IsPremiere, RunTimeTicks = (info.EndDate - info.StartDate).Ticks, OriginalAirDate = info.OriginalAirDate, MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery { ItemId = recording.Id }).ToList() }; if (info.Status == RecordingStatus.InProgress) { var now = DateTime.UtcNow.Ticks; var start = info.StartDate.Ticks; var end = info.EndDate.Ticks; var pct = now - start; pct /= end; pct *= 100; dto.CompletionPercentage = pct; } var imageTag = GetImageTag(recording); if (imageTag.HasValue) { dto.ImageTags[ImageType.Primary] = imageTag.Value; } if (user != null) { dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, recording.GetUserDataKey())); dto.PlayAccess = recording.GetPlayAccess(user); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (channel != null) { dto.ChannelName = channel.Name; if (!string.IsNullOrEmpty(channel.PrimaryImagePath)) { dto.ChannelPrimaryImageTag = GetImageTag(channel); } } return(dto); }
private async Task<LiveTvServiceInfo> GetServiceInfo(ILiveTvService service, CancellationToken cancellationToken) { var info = new LiveTvServiceInfo { Name = service.Name }; try { var statusInfo = await service.GetStatusInfoAsync(cancellationToken).ConfigureAwait(false); info.Status = statusInfo.Status; info.StatusMessage = statusInfo.StatusMessage; info.Version = statusInfo.Version; info.HasUpdateAvailable = statusInfo.HasUpdateAvailable; info.HomePageUrl = service.HomePageUrl; info.Tuners = statusInfo.Tuners.Select(i => { string channelName = null; if (!string.IsNullOrEmpty(i.ChannelId)) { var internalChannelId = _tvDtoService.GetInternalChannelId(service.Name, i.ChannelId); var channel = GetInternalChannel(internalChannelId); channelName = channel == null ? null : channel.Name; } return _tvDtoService.GetTunerInfoDto(service.Name, i, channelName); }).ToList(); } catch (Exception ex) { _logger.ErrorException("Error getting service status info from {0}", ex, service.Name ?? string.Empty); info.Status = LiveTvServiceStatus.Unavailable; info.StatusMessage = ex.Message; } return info; }
private void SetActiveService(ILiveTvService service) { if (ActiveService != null) { ActiveService.DataSourceChanged -= service_DataSourceChanged; } ActiveService = service; if (service != null) { service.DataSourceChanged += service_DataSourceChanged; } }
private async Task<IEnumerable<Tuple<string, ChannelInfo>>> GetChannels(ILiveTvService service, CancellationToken cancellationToken) { var channels = await service.GetChannelsAsync(cancellationToken).ConfigureAwait(false); return channels.Select(i => new Tuple<string, ChannelInfo>(service.Name, i)); }
public RecordingInfoDto GetRecordingInfoDto(LiveTvRecording recording, LiveTvChannel channel, ILiveTvService service, User user = null) { var info = recording.RecordingInfo; var dto = new RecordingInfoDto { Id = GetInternalRecordingId(service.Name, info.Id).ToString("N"), SeriesTimerId = string.IsNullOrEmpty(info.SeriesTimerId) ? null : GetInternalSeriesTimerId(service.Name, info.SeriesTimerId).ToString("N"), Type = recording.GetClientTypeName(), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"), Status = info.Status, Path = info.Path, Genres = info.Genres, IsRepeat = info.IsRepeat, EpisodeTitle = info.EpisodeTitle, ChannelType = info.ChannelType, MediaType = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video, CommunityRating = GetClientCommunityRating(info.CommunityRating), OfficialRating = info.OfficialRating, Audio = info.Audio, IsHD = info.IsHD, ServiceName = service.Name, Url = info.Url, IsMovie = info.IsMovie, IsSeries = info.IsSeries, IsSports = info.IsSports, IsLive = info.IsLive, IsNews = info.IsNews, IsKids = info.IsKids, IsPremiere = info.IsPremiere, RunTimeTicks = (info.EndDate - info.StartDate).Ticks }; var imageTag = GetImageTag(recording); if (imageTag.HasValue) { dto.ImageTags[ImageType.Primary] = imageTag.Value; } if (user != null) { dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, recording.GetUserDataKey())); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } if (channel != null) { dto.ChannelName = channel.ChannelInfo.Name; } return dto; }
/// <summary> /// Adds the parts. /// </summary> /// <param name="services">The services.</param> public void AddParts(IEnumerable<ILiveTvService> services) { _services.AddRange(services); ActiveService = _services.FirstOrDefault(); }
private async Task<Tuple<List<Guid>, List<Guid>>> RefreshChannelsInternal(ILiveTvService service, IProgress<double> progress, CancellationToken cancellationToken) { progress.Report(10); var allChannels = await GetChannels(service, cancellationToken).ConfigureAwait(false); var allChannelsList = allChannels.ToList(); var list = new List<LiveTvChannel>(); var numComplete = 0; var parentFolder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false); var parentFolderId = parentFolder.Id; foreach (var channelInfo in allChannelsList) { cancellationToken.ThrowIfCancellationRequested(); try { var item = await GetChannel(channelInfo.Item2, channelInfo.Item1, parentFolderId, cancellationToken).ConfigureAwait(false); list.Add(item); } catch (OperationCanceledException) { throw; } catch (Exception ex) { _logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Item2.Name); } numComplete++; double percent = numComplete; percent /= allChannelsList.Count; progress.Report(5 * percent + 10); } progress.Report(15); numComplete = 0; var programs = new List<Guid>(); var channels = new List<Guid>(); var guideDays = GetGuideDays(); _logger.Info("Refreshing guide with {0} days of guide data", guideDays); cancellationToken.ThrowIfCancellationRequested(); foreach (var currentChannel in list) { channels.Add(currentChannel.Id); cancellationToken.ThrowIfCancellationRequested(); try { var start = DateTime.UtcNow.AddHours(-1); var end = start.AddDays(guideDays); var isMovie = false; var isSports = false; var isNews = false; var isKids = false; var iSSeries = false; var channelPrograms = await service.GetProgramsAsync(currentChannel.ExternalId, start, end, cancellationToken).ConfigureAwait(false); var existingPrograms = _libraryManager.GetItemList(new InternalItemsQuery { IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name }, ChannelIds = new string[] { currentChannel.Id.ToString("N") } }).Cast<LiveTvProgram>().ToDictionary(i => i.Id); var newPrograms = new List<LiveTvProgram>(); var updatedPrograms = new List<LiveTvProgram>(); foreach (var program in channelPrograms) { var programTuple = GetProgram(program, existingPrograms, currentChannel, currentChannel.ChannelType, service.Name, cancellationToken); var programItem = programTuple.Item1; if (programTuple.Item2) { newPrograms.Add(programItem); } else if (programTuple.Item3) { updatedPrograms.Add(programItem); } programs.Add(programItem.Id); if (program.IsMovie) { isMovie = true; } if (program.IsSeries) { iSSeries = true; } if (program.IsSports) { isSports = true; } if (program.IsNews) { isNews = true; } if (program.IsKids) { isKids = true; } } _logger.Debug("Channel {0} has {1} new programs and {2} updated programs", currentChannel.Name, newPrograms.Count, updatedPrograms.Count); if (newPrograms.Count > 0) { await _libraryManager.CreateItems(newPrograms, cancellationToken).ConfigureAwait(false); } // TODO: Do this in bulk foreach (var program in updatedPrograms) { await _libraryManager.UpdateItem(program, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false); } foreach (var program in newPrograms) { _providerManager.QueueRefresh(program.Id, new MetadataRefreshOptions(_fileSystem)); } foreach (var program in updatedPrograms) { _providerManager.QueueRefresh(program.Id, new MetadataRefreshOptions(_fileSystem)); } currentChannel.IsMovie = isMovie; currentChannel.IsNews = isNews; currentChannel.IsSports = isSports; currentChannel.IsKids = isKids; currentChannel.IsSeries = iSSeries; await currentChannel.UpdateToRepository(ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) { throw; } catch (Exception ex) { _logger.ErrorException("Error getting programs for channel {0}", ex, currentChannel.Name); } numComplete++; double percent = numComplete; percent /= allChannelsList.Count; progress.Report(80 * percent + 10); } progress.Report(100); return new Tuple<List<Guid>, List<Guid>>(channels, programs); }
public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvService service, string channelName) { var dto = new SeriesTimerInfoDto { Id = GetInternalSeriesTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, Days = info.Days, Priority = info.Priority, RecordAnyChannel = info.RecordAnyChannel, RecordAnyTime = info.RecordAnyTime, SkipEpisodesInLibrary = info.SkipEpisodesInLibrary, KeepUpTo = info.KeepUpTo, KeepUntil = info.KeepUntil, RecordNewOnly = info.RecordNewOnly, ExternalChannelId = info.ChannelId, ExternalProgramId = info.ProgramId, ServiceName = service.Name, ChannelName = channelName, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ChannelId)) { dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days); if (!string.IsNullOrWhiteSpace(info.SeriesId)) { var program = _libraryManager.GetItemList(new InternalItemsQuery { IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name }, ExternalSeriesId = info.SeriesId, Limit = 1, ImageTypes = new ImageType[] { ImageType.Primary } }).FirstOrDefault(); if (program != null) { var image = program.GetImageInfo(ImageType.Primary, 0); if (image != null) { try { dto.ParentPrimaryImageTag = _imageProcessor.GetImageCacheTag(program, image); dto.ParentPrimaryImageItemId = program.Id.ToString("N"); } catch (Exception ex) { } } } } return dto; }
public SeriesTimerInfoDto GetSeriesTimerInfoDto(SeriesTimerInfo info, ILiveTvService service, string channelName) { var dto = new SeriesTimerInfoDto { Id = GetInternalSeriesTimerId(service.Name, info.Id).ToString("N"), Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds, IsPostPaddingRequired = info.IsPostPaddingRequired, IsPrePaddingRequired = info.IsPrePaddingRequired, Days = info.Days, Priority = info.Priority, RecordAnyChannel = info.RecordAnyChannel, RecordAnyTime = info.RecordAnyTime, SkipEpisodesInLibrary = info.SkipEpisodesInLibrary, KeepUpTo = info.KeepUpTo, KeepUntil = info.KeepUntil, RecordNewOnly = info.RecordNewOnly, ExternalChannelId = info.ChannelId, ExternalProgramId = info.ProgramId, ServiceName = service.Name, ChannelName = channelName, ServerId = _appHost.SystemId }; if (!string.IsNullOrEmpty(info.ChannelId)) { dto.ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"); } if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } dto.DayPattern = info.Days == null ? null : GetDayPattern(info.Days); if (!string.IsNullOrWhiteSpace(info.SeriesId)) { var program = _libraryManager.GetItemList(new InternalItemsQuery { IncludeItemTypes = new string[] { typeof(LiveTvProgram).Name }, ExternalSeriesId = info.SeriesId, Limit = 1, ImageTypes = new ImageType[] { ImageType.Primary } }).FirstOrDefault(); if (program != null) { var image = program.GetImageInfo(ImageType.Primary, 0); if (image != null) { try { dto.ParentPrimaryImageTag = _imageProcessor.GetImageCacheTag(program, image); dto.ParentPrimaryImageItemId = program.Id.ToString("N"); } catch (Exception ex) { } } } } return(dto); }
private async Task<Tuple<List<Guid>, List<Guid>>> RefreshChannelsInternal(ILiveTvService service, IProgress<double> progress, CancellationToken cancellationToken) { progress.Report(10); var allChannels = await GetChannels(service, cancellationToken).ConfigureAwait(false); var allChannelsList = allChannels.ToList(); var list = new List<LiveTvChannel>(); var numComplete = 0; var parentFolder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false); var parentFolderId = parentFolder.Id; foreach (var channelInfo in allChannelsList) { cancellationToken.ThrowIfCancellationRequested(); try { var item = await GetChannel(channelInfo.Item2, channelInfo.Item1, parentFolderId, cancellationToken).ConfigureAwait(false); list.Add(item); _libraryManager.RegisterItem(item); } catch (OperationCanceledException) { throw; } catch (Exception ex) { _logger.ErrorException("Error getting channel information for {0}", ex, channelInfo.Item2.Name); } numComplete++; double percent = numComplete; percent /= allChannelsList.Count; progress.Report(5 * percent + 10); } progress.Report(15); numComplete = 0; var programs = new List<Guid>(); var channels = new List<Guid>(); var guideDays = GetGuideDays(list.Count); _logger.Info("Refreshing guide with {0} days of guide data", guideDays); cancellationToken.ThrowIfCancellationRequested(); foreach (var currentChannel in list) { channels.Add(currentChannel.Id); cancellationToken.ThrowIfCancellationRequested(); try { var start = DateTime.UtcNow.AddHours(-1); var end = start.AddDays(guideDays); var channelPrograms = await service.GetProgramsAsync(currentChannel.ExternalId, start, end, cancellationToken).ConfigureAwait(false); foreach (var program in channelPrograms) { var programItem = await GetProgram(program, currentChannel, currentChannel.ChannelType, service.Name, cancellationToken).ConfigureAwait(false); programs.Add(programItem.Id); } } catch (OperationCanceledException) { throw; } catch (Exception ex) { _logger.ErrorException("Error getting programs for channel {0}", ex, currentChannel.Name); } numComplete++; double percent = numComplete; percent /= allChannelsList.Count; progress.Report(80 * percent + 10); } progress.Report(100); return new Tuple<List<Guid>, List<Guid>>(channels, programs); }
public RecordingInfoDto GetRecordingInfoDto(RecordingInfo info, ILiveTvService service, User user = null) { var dto = new RecordingInfoDto { Id = GetInternalRecordingId(service.Name, info.Id).ToString("N"), ChannelName = info.ChannelName, Overview = info.Overview, EndDate = info.EndDate, Name = info.Name, StartDate = info.StartDate, ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, Path = info.Path, Genres = info.Genres, IsRepeat = info.IsRepeat, EpisodeTitle = info.EpisodeTitle, ChannelType = info.ChannelType, MediaType = info.ChannelType == ChannelType.Radio ? MediaType.Audio : MediaType.Video, CommunityRating = info.CommunityRating, OfficialRating = info.OfficialRating, Audio = info.Audio, IsHD = info.IsHD, ServiceName = service.Name, Url = info.Url }; if (user != null) { //dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, info.GetUserDataKey())); } var duration = info.EndDate - info.StartDate; dto.DurationMs = Convert.ToInt32(duration.TotalMilliseconds); if (!string.IsNullOrEmpty(info.ProgramId)) { dto.ProgramId = GetInternalProgramId(service.Name, info.ProgramId).ToString("N"); } return dto; }