mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-25 03:26:32 +00:00
encode with qsv
This commit is contained in:
@@ -104,6 +104,11 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
.OrderBy(i => i.Name);
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> GetInstalledChannelIds()
|
||||
{
|
||||
return GetAllChannels().Select(i => GetInternalChannelId(i.Name));
|
||||
}
|
||||
|
||||
public Task<QueryResult<Channel>> GetChannelsInternal(ChannelQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = string.IsNullOrWhiteSpace(query.UserId)
|
||||
@@ -416,20 +421,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
var path = Channel.GetInternalMetadataPath(_config.ApplicationPaths.InternalMetadataPath, id);
|
||||
|
||||
var isNew = false;
|
||||
|
||||
if (!_fileSystem.DirectoryExists(path))
|
||||
{
|
||||
_logger.Debug("Creating directory {0}", path);
|
||||
|
||||
_fileSystem.CreateDirectory(path);
|
||||
|
||||
if (!_fileSystem.DirectoryExists(path))
|
||||
{
|
||||
throw new IOException("Path not created: " + path);
|
||||
}
|
||||
|
||||
isNew = true;
|
||||
}
|
||||
var forceUpdate = false;
|
||||
|
||||
var item = _libraryManager.GetItemById(id) as Channel;
|
||||
var channelId = channelInfo.Name.GetMD5().ToString("N");
|
||||
@@ -441,23 +433,27 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
Name = channelInfo.Name,
|
||||
Id = id,
|
||||
DateCreated = _fileSystem.GetCreationTimeUtc(path),
|
||||
DateModified = _fileSystem.GetLastWriteTimeUtc(path),
|
||||
Path = path,
|
||||
ChannelId = channelId
|
||||
DateModified = _fileSystem.GetLastWriteTimeUtc(path)
|
||||
};
|
||||
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
if (!string.Equals(item.ChannelId, channelId, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.Equals(item.Path, path, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
isNew = true;
|
||||
}
|
||||
item.Path = path;
|
||||
|
||||
if (!string.Equals(item.ChannelId, channelId, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
forceUpdate = true;
|
||||
}
|
||||
item.ChannelId = channelId;
|
||||
|
||||
if (item.ParentId != parentFolderId)
|
||||
{
|
||||
isNew = true;
|
||||
forceUpdate = true;
|
||||
}
|
||||
item.ParentId = parentFolderId;
|
||||
|
||||
@@ -469,13 +465,17 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
{
|
||||
item.Name = channelInfo.Name;
|
||||
}
|
||||
|
||||
await item.RefreshMetadata(new MetadataRefreshOptions(_fileSystem)
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
ForceSave = isNew
|
||||
|
||||
}, cancellationToken);
|
||||
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else if (forceUpdate)
|
||||
{
|
||||
await item.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await item.RefreshMetadata(new MetadataRefreshOptions(_fileSystem), cancellationToken);
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -1281,7 +1281,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
if (!string.Equals(channelItem.ExternalId, info.Id, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
isNew = true;
|
||||
forceUpdate = true;
|
||||
}
|
||||
channelItem.ExternalId = info.Id;
|
||||
|
||||
|
||||
@@ -123,15 +123,15 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
private async Task CleanDatabase(CancellationToken cancellationToken)
|
||||
{
|
||||
var allChannels = await _channelManager.GetChannelsInternal(new ChannelQuery { }, cancellationToken);
|
||||
var installedChannelIds = ((ChannelManager)_channelManager).GetInstalledChannelIds();
|
||||
|
||||
var allIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||
var databaseIds = _libraryManager.GetItemIds(new InternalItemsQuery
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Channel).Name }
|
||||
});
|
||||
|
||||
var invalidIds = allIds
|
||||
.Except(allChannels.Items.Select(i => i.Id).ToList())
|
||||
var invalidIds = databaseIds
|
||||
.Except(installedChannelIds)
|
||||
.ToList();
|
||||
|
||||
foreach (var id in invalidIds)
|
||||
|
||||
@@ -1272,6 +1272,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
public QueryResult<BaseItem> GetItems(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User != null)
|
||||
{
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
var result = ItemRepository.GetItemIdsList(query);
|
||||
|
||||
var items = result.Select(GetItemById).Where(i => i != null).ToArray();
|
||||
@@ -1284,11 +1289,21 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
public QueryResult<BaseItem> QueryItems(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User != null)
|
||||
{
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
return ItemRepository.GetItems(query);
|
||||
}
|
||||
|
||||
public List<Guid> GetItemIds(InternalItemsQuery query)
|
||||
{
|
||||
if (query.User != null)
|
||||
{
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
return ItemRepository.GetItemIdsList(query);
|
||||
}
|
||||
|
||||
@@ -1298,14 +1313,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).Select(i => i.ToString("N")).ToArray();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
AddUserToQuery(query, user);
|
||||
}
|
||||
|
||||
var items = GetItemIds(query).Select(GetItemById);
|
||||
|
||||
return items;
|
||||
return GetItemIds(query).Select(GetItemById);
|
||||
}
|
||||
|
||||
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query, IEnumerable<string> parentIds)
|
||||
@@ -1314,26 +1322,24 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
query.AncestorIds = parents.SelectMany(i => i.GetIdsForAncestorQuery()).Select(i => i.ToString("N")).ToArray();
|
||||
|
||||
if (query.User != null)
|
||||
{
|
||||
AddUserToQuery(query, query.User);
|
||||
}
|
||||
|
||||
return GetItems(query);
|
||||
}
|
||||
|
||||
private void AddUserToQuery(InternalItemsQuery query, User user)
|
||||
{
|
||||
if (query.AncestorIds.Length == 0)
|
||||
if (query.AncestorIds.Length == 0 && !query.ParentId.HasValue && query.ChannelIds.Length == 0)
|
||||
{
|
||||
// Need to filter on user folders
|
||||
// TODO: Need to filter on user folders
|
||||
}
|
||||
|
||||
// TODO: handle blocking by tags
|
||||
|
||||
query.MaxParentalRating = user.Policy.MaxParentalRating;
|
||||
|
||||
// handle blocking by tags
|
||||
|
||||
// handle unrated filter
|
||||
if (user.Policy.MaxParentalRating.HasValue)
|
||||
{
|
||||
query.BlockUnratedItems = user.Policy.BlockUnratedItems;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -107,14 +107,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
private int GetMaxAllowedBitrateForExternalSubtitleStream()
|
||||
{
|
||||
// This is abitrary but at some point it becomes too slow to extract subtitles on the fly
|
||||
// We need to learn more about when this is the case vs. when it isn't
|
||||
if (Environment.ProcessorCount >= 8)
|
||||
{
|
||||
return 10000000;
|
||||
}
|
||||
|
||||
return 4000000;
|
||||
return 20000000;
|
||||
}
|
||||
|
||||
private IEnumerable<MediaStream> GetMediaStreamsForItem(IEnumerable<MediaStream> streams)
|
||||
|
||||
@@ -134,11 +134,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
public async Task RefreshSeriesTimers(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
var timers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
|
||||
var seriesTimers = await GetSeriesTimersAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<ChannelInfo> channels = null;
|
||||
|
||||
foreach (var timer in timers)
|
||||
foreach (var timer in seriesTimers)
|
||||
{
|
||||
List<ProgramInfo> epgData;
|
||||
|
||||
@@ -157,6 +157,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
}
|
||||
await UpdateTimersForSeriesTimer(epgData, timer).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
foreach (var timer in timers.ToList())
|
||||
{
|
||||
if (DateTime.UtcNow > timer.EndDate && !_activeRecordings.ContainsKey(timer.Id))
|
||||
{
|
||||
_timerProvider.Delete(timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<ChannelInfo> _channelCache = null;
|
||||
@@ -828,12 +838,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer)
|
||||
{
|
||||
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
|
||||
|
||||
var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
|
||||
|
||||
if (registration.IsValid)
|
||||
{
|
||||
var newTimers = GetTimersForSeries(seriesTimer, epgData, _recordingProvider.GetAll()).ToList();
|
||||
|
||||
foreach (var timer in newTimers)
|
||||
{
|
||||
_timerProvider.AddOrUpdate(timer);
|
||||
|
||||
@@ -534,7 +534,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<LiveTvChannel> GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken)
|
||||
private async Task<LiveTvChannel> GetChannel(ChannelInfo channelInfo, string serviceName, Guid parentFolderId, CancellationToken cancellationToken)
|
||||
{
|
||||
var isNew = false;
|
||||
|
||||
@@ -560,6 +560,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
}
|
||||
item.ExternalId = channelInfo.Id;
|
||||
|
||||
if (!item.ParentId.Equals(parentFolderId))
|
||||
{
|
||||
isNew = true;
|
||||
}
|
||||
item.ParentId = parentFolderId;
|
||||
|
||||
item.ChannelType = channelInfo.ChannelType;
|
||||
item.ServiceName = serviceName;
|
||||
item.Number = channelInfo.Number;
|
||||
@@ -601,7 +607,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
return item;
|
||||
}
|
||||
|
||||
private async Task<LiveTvProgram> GetProgram(ProgramInfo info, string channelId, ChannelType channelType, string serviceName, CancellationToken cancellationToken)
|
||||
private async Task<LiveTvProgram> GetProgram(ProgramInfo info, LiveTvChannel channel, ChannelType channelType, string serviceName, CancellationToken cancellationToken)
|
||||
{
|
||||
var id = _tvDtoService.GetInternalProgramId(serviceName, info.Id);
|
||||
|
||||
@@ -622,6 +628,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
};
|
||||
}
|
||||
|
||||
if (!item.ParentId.Equals(channel.Id))
|
||||
{
|
||||
forceUpdate = true;
|
||||
}
|
||||
item.ParentId = channel.Id;
|
||||
|
||||
//item.ChannelType = channelType;
|
||||
if (!string.Equals(item.ServiceName, serviceName, StringComparison.Ordinal))
|
||||
{
|
||||
@@ -630,7 +642,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
item.ServiceName = serviceName;
|
||||
|
||||
item.Audio = info.Audio;
|
||||
item.ChannelId = channelId;
|
||||
item.ChannelId = channel.Id.ToString("N");
|
||||
item.CommunityRating = item.CommunityRating ?? info.CommunityRating;
|
||||
item.EndDate = info.EndDate;
|
||||
item.EpisodeTitle = info.EpisodeTitle;
|
||||
@@ -695,7 +707,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
return item;
|
||||
}
|
||||
|
||||
private async Task<Guid> CreateRecordingRecord(RecordingInfo info, string serviceName, CancellationToken cancellationToken)
|
||||
private async Task<Guid> CreateRecordingRecord(RecordingInfo info, string serviceName, Guid parentFolderId, CancellationToken cancellationToken)
|
||||
{
|
||||
var isNew = false;
|
||||
|
||||
@@ -764,6 +776,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
}
|
||||
recording.IsSeries = info.IsSeries;
|
||||
|
||||
if (!item.ParentId.Equals(parentFolderId))
|
||||
{
|
||||
dataChanged = true;
|
||||
}
|
||||
item.ParentId = parentFolderId;
|
||||
|
||||
if (!item.HasImage(ImageType.Primary))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(info.ImagePath))
|
||||
@@ -856,14 +874,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
SortOrder = query.SortOrder ?? SortOrder.Ascending
|
||||
};
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
if (user.Policy.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram))
|
||||
{
|
||||
internalQuery.HasParentalRating = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (query.HasAired.HasValue)
|
||||
{
|
||||
if (query.HasAired.Value)
|
||||
@@ -918,14 +928,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
if (user.Policy.BlockUnratedItems.Contains(UnratedItem.LiveTvProgram))
|
||||
{
|
||||
internalQuery.HasParentalRating = true;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerable<LiveTvProgram> programs = _libraryManager.QueryItems(internalQuery).Items.Cast<LiveTvProgram>();
|
||||
|
||||
var programList = programs.ToList();
|
||||
@@ -1168,6 +1170,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
var list = new List<LiveTvChannel>();
|
||||
|
||||
var numComplete = 0;
|
||||
var folder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
foreach (var channelInfo in allChannelsList)
|
||||
{
|
||||
@@ -1175,7 +1178,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
try
|
||||
{
|
||||
var item = await GetChannel(channelInfo.Item2, channelInfo.Item1, cancellationToken).ConfigureAwait(false);
|
||||
var item = await GetChannel(channelInfo.Item2, channelInfo.Item1, folder.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
list.Add(item);
|
||||
|
||||
@@ -1219,11 +1222,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
var channelPrograms = await service.GetProgramsAsync(currentChannel.ExternalId, start, end, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var channelId = currentChannel.Id.ToString("N");
|
||||
|
||||
foreach (var program in channelPrograms)
|
||||
{
|
||||
var programItem = await GetProgram(program, channelId, currentChannel.ChannelType, service.Name, cancellationToken).ConfigureAwait(false);
|
||||
var programItem = await GetProgram(program, currentChannel, currentChannel.ChannelType, service.Name, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
programs.Add(programItem.Id);
|
||||
}
|
||||
@@ -1349,8 +1350,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
});
|
||||
|
||||
var results = await Task.WhenAll(tasks).ConfigureAwait(false);
|
||||
var folder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false);
|
||||
var parentFolderId = folder.Id;
|
||||
|
||||
var recordingTasks = results.SelectMany(i => i.ToList()).Select(i => CreateRecordingRecord(i.Item1, i.Item2.Name, cancellationToken));
|
||||
var recordingTasks = results.SelectMany(i => i.ToList()).Select(i => CreateRecordingRecord(i.Item1, i.Item2.Name, parentFolderId, cancellationToken));
|
||||
|
||||
var idList = await Task.WhenAll(recordingTasks).ConfigureAwait(false);
|
||||
|
||||
@@ -1660,7 +1663,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
||||
|
||||
}
|
||||
|
||||
await _libraryManager.DeleteItem((BaseItem)recording).ConfigureAwait(false);
|
||||
// This is the responsibility of the live tv service
|
||||
await _libraryManager.DeleteItem((BaseItem)recording, new DeleteOptions
|
||||
{
|
||||
DeleteFileLocation = false
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
_lastRecordingRefreshTime = DateTime.MinValue;
|
||||
}
|
||||
|
||||
@@ -243,6 +243,8 @@ namespace MediaBrowser.Server.Implementations.Localization
|
||||
_allParentalRatings.TryAdd(countryCode, dict);
|
||||
}
|
||||
|
||||
private readonly string[] _unratedValues = {"n/a", "unrated", "not rated"};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rating level.
|
||||
/// </summary>
|
||||
@@ -253,6 +255,11 @@ namespace MediaBrowser.Server.Implementations.Localization
|
||||
throw new ArgumentNullException("rating");
|
||||
}
|
||||
|
||||
if (_unratedValues.Contains(rating, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fairly common for some users to have "Rated R" in their rating field
|
||||
rating = rating.Replace("Rated ", string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using CommonIO;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Persistence
|
||||
@@ -180,7 +181,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
//Limit = limit,
|
||||
|
||||
// These have their own cleanup routines
|
||||
ExcludeItemTypes = new[] { typeof(Person).Name, typeof(Genre).Name, typeof(MusicGenre).Name, typeof(GameGenre).Name, typeof(Studio).Name, typeof(Year).Name }
|
||||
ExcludeItemTypes = new[] { typeof(Person).Name, typeof(Genre).Name, typeof(MusicGenre).Name, typeof(GameGenre).Name, typeof(Studio).Name, typeof(Year).Name, typeof(Channel).Name }
|
||||
});
|
||||
|
||||
var numComplete = 0;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
private IDbCommand _deleteAncestorsCommand;
|
||||
private IDbCommand _saveAncestorCommand;
|
||||
|
||||
private const int LatestSchemaVersion = 25;
|
||||
private const int LatestSchemaVersion = 29;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
|
||||
@@ -219,6 +219,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "Tags", "Text");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "IsFolder", "BIT");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "InheritedParentalRatingValue", "INT");
|
||||
_connection.AddColumn(_logger, "TypedBaseItems", "UnratedType", "Text");
|
||||
|
||||
PrepareStatements();
|
||||
|
||||
@@ -446,7 +447,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
"Audio",
|
||||
"ExternalServiceId",
|
||||
"Tags",
|
||||
"IsFolder"
|
||||
"IsFolder",
|
||||
"UnratedType"
|
||||
};
|
||||
_saveItemCommand = _connection.CreateCommand();
|
||||
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
||||
@@ -714,6 +716,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Tags.ToArray());
|
||||
_saveItemCommand.GetParameter(index++).Value = item.IsFolder;
|
||||
|
||||
_saveItemCommand.GetParameter(index++).Value = item.GetBlockUnratedType().ToString();
|
||||
|
||||
_saveItemCommand.Transaction = transaction;
|
||||
|
||||
_saveItemCommand.ExecuteNonQuery();
|
||||
@@ -1916,17 +1920,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
whereClauses.Add("ParentId NOT NULL AND ParentId NOT IN (select guid from TypedBaseItems)");
|
||||
}
|
||||
}
|
||||
|
||||
if (query.AncestorIds.Length == 1)
|
||||
{
|
||||
whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
|
||||
cmd.Parameters.Add(cmd, "@AncestorId", DbType.Guid).Value = new Guid(query.AncestorIds[0]);
|
||||
}
|
||||
if (query.AncestorIds.Length > 1)
|
||||
{
|
||||
var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + new Guid(i).ToString("N") + "'").ToArray());
|
||||
whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause));
|
||||
}
|
||||
if (query.ExcludeLocationTypes.Length == 1)
|
||||
{
|
||||
whereClauses.Add("LocationType<>@LocationType");
|
||||
@@ -1939,6 +1932,28 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
whereClauses.Add("LocationType not in (" + val + ")");
|
||||
}
|
||||
|
||||
if (query.AncestorIds.Length == 1)
|
||||
{
|
||||
whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");
|
||||
cmd.Parameters.Add(cmd, "@AncestorId", DbType.Guid).Value = new Guid(query.AncestorIds[0]);
|
||||
}
|
||||
if (query.AncestorIds.Length > 1)
|
||||
{
|
||||
var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + new Guid(i).ToString("N") + "'").ToArray());
|
||||
whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause));
|
||||
}
|
||||
|
||||
if (query.BlockUnratedItems.Length == 1)
|
||||
{
|
||||
whereClauses.Add("(InheritedParentalRatingValue > 0 or UnratedType <> @UnratedType)");
|
||||
cmd.Parameters.Add(cmd, "@UnratedType", DbType.String).Value = query.BlockUnratedItems[0].ToString();
|
||||
}
|
||||
if (query.BlockUnratedItems.Length > 1)
|
||||
{
|
||||
var inClause = string.Join(",", query.BlockUnratedItems.Select(i => "'" + i.ToString() + "'").ToArray());
|
||||
whereClauses.Add(string.Format("(InheritedParentalRatingValue > 0 or UnratedType not in ({0}))", inClause));
|
||||
}
|
||||
|
||||
if (addPaging)
|
||||
{
|
||||
if (query.StartIndex.HasValue && query.StartIndex.Value > 0)
|
||||
@@ -1996,55 +2011,55 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||
|
||||
public async Task UpdateInheritedValues(CancellationToken cancellationToken)
|
||||
{
|
||||
await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
//await _writeLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
IDbTransaction transaction = null;
|
||||
//IDbTransaction transaction = null;
|
||||
|
||||
try
|
||||
{
|
||||
transaction = _connection.BeginTransaction();
|
||||
//try
|
||||
//{
|
||||
// transaction = _connection.BeginTransaction();
|
||||
|
||||
using (var cmd = _connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "update TypedBaseItems set InheritedParentalRatingValue = (select Max(ParentalRatingValue, (select COALESCE(MAX(ParentalRatingValue),0) from TypedBaseItems as T where guid in (Select AncestorId from AncestorIds where ItemId=T.guid))))";
|
||||
// using (var cmd = _connection.CreateCommand())
|
||||
// {
|
||||
// cmd.CommandText = "update TypedBaseItems set InheritedParentalRatingValue = (select Max(ParentalRatingValue, (select COALESCE(MAX(ParentalRatingValue),0) from TypedBaseItems as T where guid in (Select AncestorId from AncestorIds where ItemId=T.guid))))";
|
||||
|
||||
cmd.Transaction = transaction;
|
||||
cmd.ExecuteNonQuery();
|
||||
// cmd.Transaction = transaction;
|
||||
// cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
// cmd.ExecuteNonQuery();
|
||||
// }
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
// transaction.Commit();
|
||||
//}
|
||||
//catch (OperationCanceledException)
|
||||
//{
|
||||
// if (transaction != null)
|
||||
// {
|
||||
// transaction.Rollback();
|
||||
// }
|
||||
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Error running query:", e);
|
||||
// throw;
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// _logger.ErrorException("Error running query:", e);
|
||||
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
// if (transaction != null)
|
||||
// {
|
||||
// transaction.Rollback();
|
||||
// }
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (transaction != null)
|
||||
{
|
||||
transaction.Dispose();
|
||||
}
|
||||
// throw;
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// if (transaction != null)
|
||||
// {
|
||||
// transaction.Dispose();
|
||||
// }
|
||||
|
||||
_writeLock.Release();
|
||||
}
|
||||
// _writeLock.Release();
|
||||
//}
|
||||
}
|
||||
|
||||
private static Dictionary<string, string[]> GetTypeMapDictionary()
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
|
||||
// Do the data sync twice so the server knows what was removed from the device
|
||||
await SyncData(provider, dataProvider, serverId, target, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
|
||||
@@ -739,10 +739,10 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
var requiresSaving = false;
|
||||
var removeFromDevice = false;
|
||||
|
||||
var libraryItem = _libraryManager.GetItemById(jobItem.ItemId);
|
||||
|
||||
if (request.LocalItemIds.Contains(jobItem.ItemId, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var libraryItem = _libraryManager.GetItemById(jobItem.ItemId);
|
||||
|
||||
var job = _repo.GetJob(jobItem.JobId);
|
||||
var user = _userManager.GetUserById(job.UserId);
|
||||
|
||||
@@ -845,10 +845,10 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
var requiresSaving = false;
|
||||
var removeFromDevice = false;
|
||||
|
||||
var libraryItem = _libraryManager.GetItemById(jobItem.ItemId);
|
||||
|
||||
if (request.SyncJobItemIds.Contains(jobItem.Id, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var libraryItem = _libraryManager.GetItemById(jobItem.ItemId);
|
||||
|
||||
var job = _repo.GetJob(jobItem.JobId);
|
||||
var user = _userManager.GetUserById(job.UserId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user