mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
update task triggers
This commit is contained in:
parent
ba2574a03b
commit
3799ad5940
@ -312,7 +312,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
|||||||
|
|
||||||
trigger.Triggered -= trigger_Triggered;
|
trigger.Triggered -= trigger_Triggered;
|
||||||
trigger.Triggered += trigger_Triggered;
|
trigger.Triggered += trigger_Triggered;
|
||||||
trigger.Start(isApplicationStartup);
|
trigger.Start(LastExecutionResult, isApplicationStartup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +340,7 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks
|
|||||||
|
|
||||||
await Task.Delay(1000).ConfigureAwait(false);
|
await Task.Delay(1000).ConfigureAwait(false);
|
||||||
|
|
||||||
trigger.Start(false);
|
trigger.Start(LastExecutionResult, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task _currentTask;
|
private Task _currentTask;
|
||||||
|
@ -45,9 +45,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
|||||||
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
|
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
|
||||||
return new ITaskTrigger[] {
|
return new ITaskTrigger[] {
|
||||||
|
|
||||||
// At startup
|
|
||||||
new StartupTrigger {DelayMs = 60000},
|
|
||||||
|
|
||||||
// Every so often
|
// Every so often
|
||||||
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
|
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
|
||||||
};
|
};
|
||||||
|
@ -42,9 +42,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
|
|||||||
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
|
// Until we can vary these default triggers per server and MBT, we need something that makes sense for both
|
||||||
return new ITaskTrigger[] {
|
return new ITaskTrigger[] {
|
||||||
|
|
||||||
// At startup
|
|
||||||
new StartupTrigger {DelayMs = 30000},
|
|
||||||
|
|
||||||
// Every so often
|
// Every so often
|
||||||
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
|
new IntervalTrigger { Interval = TimeSpan.FromHours(24)}
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using MediaBrowser.Model.Events;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using MediaBrowser.Model.Events;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.ScheduledTasks
|
namespace MediaBrowser.Common.ScheduledTasks
|
||||||
{
|
{
|
||||||
@ -32,8 +33,9 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stars waiting for the trigger action
|
/// Stars waiting for the trigger action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="lastResult">The last result.</param>
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
||||||
public void Start(bool isApplicationStartup)
|
public void Start(TaskResult lastResult, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using MediaBrowser.Model.Events;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Tasks;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.ScheduledTasks
|
namespace MediaBrowser.Common.ScheduledTasks
|
||||||
{
|
{
|
||||||
@ -16,8 +17,9 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stars waiting for the trigger action
|
/// Stars waiting for the trigger action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="lastResult">The last result.</param>
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
||||||
void Start(bool isApplicationStartup);
|
void Start(TaskResult lastResult, bool isApplicationStartup);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops waiting for the trigger action
|
/// Stops waiting for the trigger action
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using MediaBrowser.Model.Events;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using MediaBrowser.Model.Events;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.ScheduledTasks
|
namespace MediaBrowser.Common.ScheduledTasks
|
||||||
{
|
{
|
||||||
@ -32,12 +33,27 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stars waiting for the trigger action
|
/// Stars waiting for the trigger action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="lastResult">The last result.</param>
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
||||||
public void Start(bool isApplicationStartup)
|
public void Start(TaskResult lastResult, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
|
||||||
Timer = new Timer(state => OnTriggered(), null, Interval, TimeSpan.FromMilliseconds(-1));
|
var triggerDate = lastResult != null ?
|
||||||
|
lastResult.EndTimeUtc.Add(Interval) :
|
||||||
|
DateTime.UtcNow.Add(Interval);
|
||||||
|
|
||||||
|
if (DateTime.UtcNow > triggerDate)
|
||||||
|
{
|
||||||
|
triggerDate = DateTime.UtcNow;
|
||||||
|
|
||||||
|
if (isApplicationStartup)
|
||||||
|
{
|
||||||
|
triggerDate = triggerDate.AddMinutes(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer = new Timer(state => OnTriggered(), null, triggerDate - DateTime.UtcNow, TimeSpan.FromMilliseconds(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using MediaBrowser.Model.Events;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Model.Events;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.ScheduledTasks
|
namespace MediaBrowser.Common.ScheduledTasks
|
||||||
{
|
{
|
||||||
@ -27,8 +28,9 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stars waiting for the trigger action
|
/// Stars waiting for the trigger action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="lastResult">The last result.</param>
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
||||||
public async void Start(bool isApplicationStartup)
|
public async void Start(TaskResult lastResult, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
if (isApplicationStartup)
|
if (isApplicationStartup)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using MediaBrowser.Model.Tasks;
|
using MediaBrowser.Model.Events;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Model.Events;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.ScheduledTasks
|
namespace MediaBrowser.Common.ScheduledTasks
|
||||||
{
|
{
|
||||||
@ -28,8 +28,9 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stars waiting for the trigger action
|
/// Stars waiting for the trigger action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="lastResult">The last result.</param>
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
||||||
public void Start(bool isApplicationStartup)
|
public void Start(TaskResult lastResult, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
switch (SystemEvent)
|
switch (SystemEvent)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
|
using MediaBrowser.Model.Tasks;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.ScheduledTasks
|
namespace MediaBrowser.Common.ScheduledTasks
|
||||||
{
|
{
|
||||||
@ -38,8 +39,9 @@ namespace MediaBrowser.Common.ScheduledTasks
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stars waiting for the trigger action
|
/// Stars waiting for the trigger action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="lastResult">The last result.</param>
|
||||||
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
/// <param name="isApplicationStartup">if set to <c>true</c> [is application startup].</param>
|
||||||
public void Start(bool isApplicationStartup)
|
public void Start(TaskResult lastResult, bool isApplicationStartup)
|
||||||
{
|
{
|
||||||
DisposeTimer();
|
DisposeTimer();
|
||||||
|
|
||||||
|
@ -1115,6 +1115,18 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return value.Value <= maxAllowedRating.Value;
|
return value.Value <= maxAllowedRating.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int? GetParentalRatingValue()
|
||||||
|
{
|
||||||
|
var rating = CustomRatingForComparison;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(rating))
|
||||||
|
{
|
||||||
|
rating = OfficialRatingForComparison;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LocalizationManager.GetRatingLevel(rating);
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsVisibleViaTags(User user)
|
private bool IsVisibleViaTags(User user)
|
||||||
{
|
{
|
||||||
var hasTags = this as IHasTags;
|
var hasTags = this as IHasTags;
|
||||||
|
@ -94,6 +94,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
public string[] ChannelIds { get; set; }
|
public string[] ChannelIds { get; set; }
|
||||||
|
|
||||||
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
|
internal List<Guid> ItemIdsFromPersonFilters { get; set; }
|
||||||
|
public int? MaxParentalRating { get; set; }
|
||||||
|
|
||||||
public InternalItemsQuery()
|
public InternalItemsQuery()
|
||||||
{
|
{
|
||||||
|
@ -5,12 +5,12 @@ using MediaBrowser.Controller.Providers;
|
|||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Model.Querying;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Library
|
namespace MediaBrowser.Controller.Library
|
||||||
{
|
{
|
||||||
|
@ -42,10 +42,6 @@ namespace MediaBrowser.Server.Implementations.Channels
|
|||||||
{
|
{
|
||||||
return new ITaskTrigger[]
|
return new ITaskTrigger[]
|
||||||
{
|
{
|
||||||
new StartupTrigger{DelayMs = 10000},
|
|
||||||
|
|
||||||
new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep},
|
|
||||||
|
|
||||||
new IntervalTrigger{ Interval = TimeSpan.FromHours(24)}
|
new IntervalTrigger{ Interval = TimeSpan.FromHours(24)}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ using MediaBrowser.Controller.Localization;
|
|||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
@ -772,9 +773,21 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
MaxStartDate = query.MaxStartDate,
|
MaxStartDate = query.MaxStartDate,
|
||||||
ChannelIds = query.ChannelIds,
|
ChannelIds = query.ChannelIds,
|
||||||
IsMovie = query.IsMovie,
|
IsMovie = query.IsMovie,
|
||||||
IsSports = query.IsSports
|
IsSports = query.IsSports,
|
||||||
|
Genres = query.Genres
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
internalQuery.MaxParentalRating = user.Policy.MaxParentalRating;
|
||||||
|
|
||||||
|
if (user.Policy.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram))
|
||||||
|
{
|
||||||
|
internalQuery.HasParentalRating = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (query.HasAired.HasValue)
|
if (query.HasAired.HasValue)
|
||||||
{
|
{
|
||||||
if (query.HasAired.Value)
|
if (query.HasAired.Value)
|
||||||
@ -789,20 +802,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
IEnumerable<LiveTvProgram> programs = _libraryManager.GetItems(internalQuery).Items.Cast<LiveTvProgram>();
|
IEnumerable<LiveTvProgram> programs = _libraryManager.GetItems(internalQuery).Items.Cast<LiveTvProgram>();
|
||||||
|
|
||||||
// Apply genre filter
|
|
||||||
if (query.Genres.Length > 0)
|
|
||||||
{
|
|
||||||
programs = programs.Where(p => p.Genres.Any(g => query.Genres.Contains(g, StringComparer.OrdinalIgnoreCase)));
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId);
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
// Avoid implicitly captured closure
|
|
||||||
var currentUser = user;
|
|
||||||
programs = programs.Where(i => i.IsVisible(currentUser));
|
|
||||||
}
|
|
||||||
|
|
||||||
programs = _libraryManager.Sort(programs, user, query.SortBy, query.SortOrder ?? SortOrder.Ascending)
|
programs = _libraryManager.Sort(programs, user, query.SortBy, query.SortOrder ?? SortOrder.Ascending)
|
||||||
.Cast<LiveTvProgram>();
|
.Cast<LiveTvProgram>();
|
||||||
|
|
||||||
@ -860,13 +859,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<LiveTvProgram> programs = _libraryManager.GetItems(internalQuery).Items.Cast<LiveTvProgram>();
|
|
||||||
|
|
||||||
var user = _userManager.GetUserById(query.UserId);
|
var user = _userManager.GetUserById(query.UserId);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
internalQuery.MaxParentalRating = user.Policy.MaxParentalRating;
|
||||||
|
|
||||||
// Avoid implicitly captured closure
|
if (user.Policy.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram))
|
||||||
var currentUser = user;
|
{
|
||||||
programs = programs.Where(i => i.IsVisible(currentUser));
|
internalQuery.HasParentalRating = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<LiveTvProgram> programs = _libraryManager.GetItems(internalQuery).Items.Cast<LiveTvProgram>();
|
||||||
|
|
||||||
var programList = programs.ToList();
|
var programList = programs.ToList();
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using MediaBrowser.Common.ScheduledTasks;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
using MediaBrowser.Model.Tasks;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -47,11 +46,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
{
|
{
|
||||||
return new ITaskTrigger[]
|
return new ITaskTrigger[]
|
||||||
{
|
{
|
||||||
new StartupTrigger(),
|
new IntervalTrigger{ Interval = TimeSpan.FromHours(12)}
|
||||||
|
|
||||||
new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep},
|
|
||||||
|
|
||||||
new IntervalTrigger{ Interval = TimeSpan.FromHours(4)}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
_connection.AddColumn(_logger, "TypedBaseItems", "PremiereDate", "DATETIME");
|
_connection.AddColumn(_logger, "TypedBaseItems", "PremiereDate", "DATETIME");
|
||||||
_connection.AddColumn(_logger, "TypedBaseItems", "ProductionYear", "INT");
|
_connection.AddColumn(_logger, "TypedBaseItems", "ProductionYear", "INT");
|
||||||
_connection.AddColumn(_logger, "TypedBaseItems", "ParentId", "GUID");
|
_connection.AddColumn(_logger, "TypedBaseItems", "ParentId", "GUID");
|
||||||
|
_connection.AddColumn(_logger, "TypedBaseItems", "Genres", "Text");
|
||||||
|
_connection.AddColumn(_logger, "TypedBaseItems", "ParentalRatingValue", "INT");
|
||||||
|
|
||||||
PrepareStatements();
|
PrepareStatements();
|
||||||
|
|
||||||
@ -197,10 +199,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
"ParentIndexNumber",
|
"ParentIndexNumber",
|
||||||
"PremiereDate",
|
"PremiereDate",
|
||||||
"ProductionYear",
|
"ProductionYear",
|
||||||
"ParentId"
|
"ParentId",
|
||||||
|
"Genres",
|
||||||
|
"ParentalRatingValue"
|
||||||
};
|
};
|
||||||
_saveItemCommand = _connection.CreateCommand();
|
_saveItemCommand = _connection.CreateCommand();
|
||||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22)";
|
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22, @23, @24)";
|
||||||
for (var i = 1; i <= saveColumns.Count; i++)
|
for (var i = 1; i <= saveColumns.Count; i++)
|
||||||
{
|
{
|
||||||
_saveItemCommand.Parameters.Add(_saveItemCommand, "@" + i.ToString(CultureInfo.InvariantCulture));
|
_saveItemCommand.Parameters.Add(_saveItemCommand, "@" + i.ToString(CultureInfo.InvariantCulture));
|
||||||
@ -343,6 +347,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
_saveItemCommand.GetParameter(index++).Value = item.ParentId;
|
_saveItemCommand.GetParameter(index++).Value = item.ParentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());
|
||||||
|
_saveItemCommand.GetParameter(index++).Value = item.GetParentalRatingValue();
|
||||||
|
|
||||||
_saveItemCommand.Transaction = transaction;
|
_saveItemCommand.Transaction = transaction;
|
||||||
|
|
||||||
_saveItemCommand.ExecuteNonQuery();
|
_saveItemCommand.ExecuteNonQuery();
|
||||||
@ -938,6 +945,38 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains + "%";
|
cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (query.Genres.Length > 0)
|
||||||
|
{
|
||||||
|
var genres = new List<string>();
|
||||||
|
var index = 0;
|
||||||
|
foreach (var genre in query.Genres)
|
||||||
|
{
|
||||||
|
genres.Add("Genres like @Genres" + index);
|
||||||
|
cmd.Parameters.Add(cmd, "@Genres" + index, DbType.String).Value = "%" + genre + "%";
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
var genreCaluse = "(" + string.Join(" OR ", genres.ToArray()) + ")";
|
||||||
|
whereClauses.Add(genreCaluse);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.MaxParentalRating.HasValue)
|
||||||
|
{
|
||||||
|
whereClauses.Add("(ParentalRatingValue is NULL OR ParentalRatingValue<=@MaxParentalRating)");
|
||||||
|
cmd.Parameters.Add(cmd, "@MaxParentalRating", DbType.Int32).Value = query.MaxParentalRating.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.HasParentalRating.HasValue)
|
||||||
|
{
|
||||||
|
if (query.HasParentalRating.Value)
|
||||||
|
{
|
||||||
|
whereClauses.Add("ParentalRatingValue NOT NULL");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
whereClauses.Add("ParentalRatingValue IS NULL");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (addPaging)
|
if (addPaging)
|
||||||
{
|
{
|
||||||
if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
|
if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
|
||||||
@ -1021,31 +1060,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
return new[] { value };
|
return new[] { value };
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Guid> GetItemIdsOfType(Type type)
|
|
||||||
{
|
|
||||||
if (type == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException("type");
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckDisposed();
|
|
||||||
|
|
||||||
using (var cmd = _connection.CreateCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandText = "select guid from TypedBaseItems where type = @type";
|
|
||||||
|
|
||||||
cmd.Parameters.Add(cmd, "@type", DbType.String).Value = type.FullName;
|
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
|
|
||||||
{
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
yield return reader.GetGuid(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task DeleteItem(Guid id, CancellationToken cancellationToken)
|
public async Task DeleteItem(Guid id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (id == Guid.Empty)
|
if (id == Guid.Empty)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using MediaBrowser.Common.ScheduledTasks;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Tasks;
|
|
||||||
using MediaBrowser.Server.Implementations.Library;
|
using MediaBrowser.Server.Implementations.Library;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -38,8 +37,6 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
|||||||
|
|
||||||
new StartupTrigger(),
|
new StartupTrigger(),
|
||||||
|
|
||||||
new SystemEventTrigger{ SystemEvent = SystemEvent.WakeFromSleep},
|
|
||||||
|
|
||||||
new IntervalTrigger{ Interval = TimeSpan.FromHours(6)}
|
new IntervalTrigger{ Interval = TimeSpan.FromHours(6)}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
|||||||
{
|
{
|
||||||
return new ITaskTrigger[]
|
return new ITaskTrigger[]
|
||||||
{
|
{
|
||||||
new IntervalTrigger { Interval = TimeSpan.FromHours(3) },
|
new IntervalTrigger { Interval = TimeSpan.FromHours(3) }
|
||||||
new StartupTrigger{ DelayMs = Convert.ToInt32(TimeSpan.FromMinutes(5).TotalMilliseconds)}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,6 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
|||||||
SpecialFolder.TvFavoriteEpisodes,
|
SpecialFolder.TvFavoriteEpisodes,
|
||||||
SpecialFolder.TvFavoriteSeries,
|
SpecialFolder.TvFavoriteSeries,
|
||||||
SpecialFolder.TvGenres,
|
SpecialFolder.TvGenres,
|
||||||
SpecialFolder.TvGenre,
|
|
||||||
SpecialFolder.TvLatest,
|
SpecialFolder.TvLatest,
|
||||||
SpecialFolder.TvNextUp,
|
SpecialFolder.TvNextUp,
|
||||||
SpecialFolder.TvResume,
|
SpecialFolder.TvResume,
|
||||||
@ -152,14 +151,12 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
|||||||
SpecialFolder.MovieCollections,
|
SpecialFolder.MovieCollections,
|
||||||
SpecialFolder.MovieFavorites,
|
SpecialFolder.MovieFavorites,
|
||||||
SpecialFolder.MovieGenres,
|
SpecialFolder.MovieGenres,
|
||||||
SpecialFolder.MovieGenre,
|
|
||||||
SpecialFolder.MovieLatest,
|
SpecialFolder.MovieLatest,
|
||||||
SpecialFolder.MovieMovies,
|
SpecialFolder.MovieMovies,
|
||||||
SpecialFolder.MovieResume,
|
SpecialFolder.MovieResume,
|
||||||
|
|
||||||
SpecialFolder.GameFavorites,
|
SpecialFolder.GameFavorites,
|
||||||
SpecialFolder.GameGenres,
|
SpecialFolder.GameGenres,
|
||||||
SpecialFolder.GameGenre,
|
|
||||||
SpecialFolder.GameSystems,
|
SpecialFolder.GameSystems,
|
||||||
SpecialFolder.LatestGames,
|
SpecialFolder.LatestGames,
|
||||||
SpecialFolder.RecentlyPlayedGames,
|
SpecialFolder.RecentlyPlayedGames,
|
||||||
@ -168,7 +165,6 @@ namespace MediaBrowser.Server.Implementations.UserViews
|
|||||||
SpecialFolder.MusicAlbumArtists,
|
SpecialFolder.MusicAlbumArtists,
|
||||||
SpecialFolder.MusicAlbums,
|
SpecialFolder.MusicAlbums,
|
||||||
SpecialFolder.MusicGenres,
|
SpecialFolder.MusicGenres,
|
||||||
SpecialFolder.MusicGenre,
|
|
||||||
SpecialFolder.MusicLatest,
|
SpecialFolder.MusicLatest,
|
||||||
SpecialFolder.MusicPlaylists,
|
SpecialFolder.MusicPlaylists,
|
||||||
SpecialFolder.MusicSongs,
|
SpecialFolder.MusicSongs,
|
||||||
|
Loading…
Reference in New Issue
Block a user