diff --git a/MediaBrowser.Controller/LiveTv/EventArgs.cs b/MediaBrowser.Controller/LiveTv/EventArgs.cs new file mode 100644 index 0000000000..90ea329fe9 --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/EventArgs.cs @@ -0,0 +1,12 @@ +using MediaBrowser.Model.LiveTv; +using System; + +namespace MediaBrowser.Controller.LiveTv +{ + public class RecordingStatusChangedEventArgs : EventArgs + { + public string RecordingId { get; set; } + + public RecordingStatus NewStatus { get; set; } + } +} diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 004f0b4525..7217b6e13c 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -10,6 +10,16 @@ namespace MediaBrowser.Controller.LiveTv /// public interface ILiveTvService { + /// + /// Occurs when [data source changed]. + /// + event EventHandler DataSourceChanged; + + /// + /// Occurs when [recording status changed]. + /// + event EventHandler RecordingStatusChanged; + /// /// Gets the name. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index ec6c88705a..9452700b5e 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -112,6 +112,7 @@ + diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index c5b5311b24..55ca9edc78 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -2,6 +2,7 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Globalization; +using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Notifications; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Querying; @@ -748,6 +749,22 @@ namespace MediaBrowser.Model.ApiClient /// item string GetImageUrl(BaseItemDto item, ImageOptions options); + /// + /// Gets the image URL. + /// + /// The item. + /// The options. + /// System.String. + string GetImageUrl(ChannelInfoDto item, ImageOptions options); + + /// + /// Gets the image URL. + /// + /// The item. + /// The options. + /// System.String. + string GetImageUrl(RecordingInfoDto item, ImageOptions options); + /// /// Gets an image url that can be used to download an image from the api /// @@ -918,5 +935,36 @@ namespace MediaBrowser.Model.ApiClient /// System.String. /// options string GetHlsVideoStreamUrl(VideoStreamOptions options); + + /// + /// Gets the live tv information asynchronous. + /// + /// The cancellation token. + /// Task{LiveTvInfo}. + Task GetLiveTvInfoAsync(CancellationToken cancellationToken); + + /// + /// Gets the live tv channels asynchronous. + /// + /// The query. + /// The cancellation token. + /// Task{LiveTvInfo}. + Task> GetLiveTvChannelsAsync(ChannelQuery query, CancellationToken cancellationToken); + + /// + /// Gets the live tv recordings asynchronous. + /// + /// The query. + /// The cancellation token. + /// Task{QueryResult{RecordingInfoDto}}. + Task> GetLiveTvRecordingsAsync(RecordingQuery query, CancellationToken cancellationToken); + + /// + /// Gets the live tv recording groups asynchronous. + /// + /// The query. + /// The cancellation token. + /// Task{QueryResult{RecordingGroupDto}}. + Task> GetLiveTvRecordingGroupsAsync(RecordingGroupQuery query, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs index c1161f4ec1..4d56d0ae39 100644 --- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs @@ -1,7 +1,7 @@ -using System; -using System.Collections.Generic; -using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; +using System; +using System.Collections.Generic; namespace MediaBrowser.Model.LiveTv { diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index eff919f178..5da6e697db 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common.Extensions; using MediaBrowser.Common.IO; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Drawing; @@ -37,6 +38,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv private readonly IUserDataManager _userDataManager; private readonly ILibraryManager _libraryManager; private readonly IMediaEncoder _mediaEncoder; + private readonly ITaskManager _taskManager; private readonly LiveTvDtoService _tvDtoService; @@ -81,7 +83,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv { _services.AddRange(services); - ActiveService = _services.FirstOrDefault(); + SetActiveService(_services.FirstOrDefault()); + } + + private void SetActiveService(ILiveTvService service) + { + if (ActiveService != null) + { + ActiveService.DataSourceChanged -= service_DataSourceChanged; + } + + ActiveService = service; + + if (service != null) + { + service.DataSourceChanged += service_DataSourceChanged; + } + } + + void service_DataSourceChanged(object sender, EventArgs e) + { + _taskManager.CancelIfRunningAndQueue(); } public Task> GetChannels(ChannelQuery query, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index fe565e0947..1edd79d69d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -42,7 +42,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv { return new ITaskTrigger[] { - new StartupTrigger(), new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep}, diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index e325c9804b..0505b0992d 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.301 + 3.0.302 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 4a8b2f7006..e6ea16efa0 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.301 + 3.0.302 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 9cbcf30a47..2935fb958a 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.301 + 3.0.302 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +