diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 24c91e172f..bb6f74f364 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -186,6 +186,9 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "IsMovie", Description = "Optional filter for movies.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET,POST")]
public bool? IsMovie { get; set; }
+ [ApiMember(Name = "IsSports", Description = "Optional filter for sports.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET,POST")]
+ public bool? IsSports { get; set; }
+
[ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? StartIndex { get; set; }
@@ -218,6 +221,9 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "HasAired", Description = "Optional. Filter by programs that have completed airing, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? HasAired { get; set; }
+ [ApiMember(Name = "IsSports", Description = "Optional filter for sports.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET,POST")]
+ public bool? IsSports { get; set; }
+
[ApiMember(Name = "IsMovie", Description = "Optional filter for movies.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool? IsMovie { get; set; }
}
@@ -422,6 +428,7 @@ namespace MediaBrowser.Api.LiveTv
query.SortBy = (request.SortBy ?? String.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
query.SortOrder = request.SortOrder;
query.IsMovie = request.IsMovie;
+ query.IsSports = request.IsSports;
query.Genres = (request.Genres ?? String.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var result = await _liveTvManager.GetPrograms(query, CancellationToken.None).ConfigureAwait(false);
@@ -437,7 +444,8 @@ namespace MediaBrowser.Api.LiveTv
IsAiring = request.IsAiring,
Limit = request.Limit,
HasAired = request.HasAired,
- IsMovie = request.IsMovie
+ IsMovie = request.IsMovie,
+ IsSports = request.IsSports
};
var result = await _liveTvManager.GetRecommendedPrograms(query, CancellationToken.None).ConfigureAwait(false);
diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.cs
index bbd396c33f..c19ba54bd1 100644
--- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs
+++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs
@@ -53,6 +53,12 @@ namespace MediaBrowser.Model.LiveTv
/// If set to null, all programs will be returned
public bool? IsMovie { get; set; }
+ ///
+ /// Gets or sets a value indicating whether this instance is sports.
+ ///
+ /// null if [is sports] contains no value, true if [is sports]; otherwise, false.
+ public bool? IsSports { get; set; }
+
///
/// Skips over a given number of items within the results. Use for paging.
///
diff --git a/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs b/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs
index 9ba8e0e5fc..4a8ae2365b 100644
--- a/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs
+++ b/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs
@@ -31,5 +31,10 @@
///
/// null if [is movie] contains no value, true if [is movie]; otherwise, false.
public bool? IsMovie { get; set; }
+ ///
+ /// Gets or sets a value indicating whether this instance is sports.
+ ///
+ /// null if [is sports] contains no value, true if [is sports]; otherwise, false.
+ public bool? IsSports { get; set; }
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Model/Querying/ItemSortBy.cs b/MediaBrowser.Model/Querying/ItemSortBy.cs
index fcc7e39a19..9c2926b542 100644
--- a/MediaBrowser.Model/Querying/ItemSortBy.cs
+++ b/MediaBrowser.Model/Querying/ItemSortBy.cs
@@ -43,6 +43,7 @@ namespace MediaBrowser.Model.Querying
/// The premiere date
///
public const string PremiereDate = "PremiereDate";
+ public const string StartDate = "StartDate";
///
/// The sort name
///
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index a39781d6a3..cb9bb77111 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -761,6 +761,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
programs = programs.Where(p => p.IsMovie == query.IsMovie);
}
+ if (query.IsSports.HasValue)
+ {
+ programs = programs.Where(p => p.IsSports == query.IsSports);
+ }
+
programs = _libraryManager.Sort(programs, user, query.SortBy, query.SortOrder ?? SortOrder.Ascending)
.Cast();
@@ -826,6 +831,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
programs = programs.Where(p => p.IsMovie == query.IsMovie.Value);
}
+ if (query.IsSports.HasValue)
+ {
+ programs = programs.Where(p => p.IsSports == query.IsSports.Value);
+ }
+
var programList = programs.ToList();
var genres = programList.SelectMany(i => i.Genres)
@@ -996,6 +1006,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
innerProgress = new ActionableProgress();
innerProgress.RegisterAction(p => progress.Report(90 + (p * .1)));
await CleanDatabaseInternal(progress, cancellationToken).ConfigureAwait(false);
+
+ foreach (var program in _programs.Values
+ .Where(i => (i.StartDate - DateTime.UtcNow).TotalDays <= 1)
+ .ToList())
+ {
+ RefreshIfNeeded(program);
+ }
}
finally
{
diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json
index 3f9a36560d..835e9b3beb 100644
--- a/MediaBrowser.Server.Implementations/Localization/Server/server.json
+++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json
@@ -913,7 +913,7 @@
"OptionDefaultSort": "Default",
"OptionCommunityMostWatchedSort": "Most Watched",
"TabNextUp": "Next Up",
- "PlaceholderUsername": "Username",
+ "PlaceholderUsername": "Username",
"HeaderBecomeProjectSupporter": "Become an Emby Supporter",
"MessageNoMovieSuggestionsAvailable": "No movie suggestions are currently available. Start watching and rating your movies, and then come back to view your recommendations.",
"MessageNoCollectionsAvailable": "Collections allow you to enjoy personalized groupings of Movies, Series, Albums, Books and Games. Click the + button to start creating Collections.",
@@ -1399,6 +1399,7 @@
"LabelEnableInternetMetadataForTvPrograms": "Download internet metadata for:",
"OptionTVMovies": "TV Movies",
"HeaderUpcomingMovies": "Upcoming Movies",
+ "HeaderUpcomingSports": "Upcoming Sports",
"HeaderUpcomingPrograms": "Upcoming Programs",
"ButtonMoreItems": "More...",
"LabelShowLibraryTileNames": "Show library tile names",
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index db2397d2f7..dd770b0c89 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -233,6 +233,7 @@
+
diff --git a/MediaBrowser.Server.Implementations/Sorting/StartDateComparer.cs b/MediaBrowser.Server.Implementations/Sorting/StartDateComparer.cs
new file mode 100644
index 0000000000..7e6f24ec1c
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/Sorting/StartDateComparer.cs
@@ -0,0 +1,47 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Sorting;
+using MediaBrowser.Model.Querying;
+using System;
+
+namespace MediaBrowser.Server.Implementations.Sorting
+{
+ public class StartDateComparer : IBaseItemComparer
+ {
+ ///
+ /// Compares the specified x.
+ ///
+ /// The x.
+ /// The y.
+ /// System.Int32.
+ public int Compare(BaseItem x, BaseItem y)
+ {
+ return GetDate(x).CompareTo(GetDate(y));
+ }
+
+ ///
+ /// Gets the date.
+ ///
+ /// The x.
+ /// DateTime.
+ private DateTime GetDate(BaseItem x)
+ {
+ var hasStartDate = x as LiveTvProgram;
+
+ if (hasStartDate != null)
+ {
+ return hasStartDate.StartDate;
+ }
+ return DateTime.MinValue;
+ }
+
+ ///
+ /// Gets the name.
+ ///
+ /// The name.
+ public string Name
+ {
+ get { return ItemSortBy.StartDate; }
+ }
+ }
+}