mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 22:07:13 -04:00
switch recordings to ts when preserving original audio
This commit is contained in:
parent
f378a2c789
commit
383110f9af
@ -194,6 +194,8 @@ namespace MediaBrowser.Providers.TV
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void LibraryUpdateTimerCallback(object state)
|
private async void LibraryUpdateTimerCallback(object state)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (MissingEpisodeProvider.IsRunning)
|
if (MissingEpisodeProvider.IsRunning)
|
||||||
{
|
{
|
||||||
@ -202,7 +204,7 @@ namespace MediaBrowser.Providers.TV
|
|||||||
|
|
||||||
if (_libraryManager.IsScanRunning)
|
if (_libraryManager.IsScanRunning)
|
||||||
{
|
{
|
||||||
return ;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var seriesList = _libraryManager.GetItemList(new InternalItemsQuery()
|
var seriesList = _libraryManager.GetItemList(new InternalItemsQuery()
|
||||||
@ -218,6 +220,11 @@ namespace MediaBrowser.Providers.TV
|
|||||||
await new MissingEpisodeProvider(_logger, _config, _libraryManager, _localization, _fileSystem)
|
await new MissingEpisodeProvider(_logger, _config, _libraryManager, _localization, _fileSystem)
|
||||||
.Run(seriesGroups, false, CancellationToken.None).ConfigureAwait(false);
|
.Run(seriesGroups, false, CancellationToken.None).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error in SeriesPostScanTask", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool FilterItem(BaseItem item)
|
private bool FilterItem(BaseItem item)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||||||
var streams = mediaSource.MediaStreams ?? new List<MediaStream>();
|
var streams = mediaSource.MediaStreams ?? new List<MediaStream>();
|
||||||
if (streams.Any(i => i.Type == MediaStreamType.Audio && (i.Codec ?? string.Empty).IndexOf("aac", StringComparison.OrdinalIgnoreCase) != -1))
|
if (streams.Any(i => i.Type == MediaStreamType.Audio && (i.Codec ?? string.Empty).IndexOf("aac", StringComparison.OrdinalIgnoreCase) != -1))
|
||||||
{
|
{
|
||||||
return Path.ChangeExtension(targetFile, ".mkv");
|
return Path.ChangeExtension(targetFile, ".ts");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
public abstract class BaseSqliteRepository : IDisposable
|
public abstract class BaseSqliteRepository : IDisposable
|
||||||
{
|
{
|
||||||
|
protected readonly SemaphoreSlim WriteLock = new SemaphoreSlim(1, 1);
|
||||||
protected readonly IDbConnector DbConnector;
|
protected readonly IDbConnector DbConnector;
|
||||||
protected ILogger Logger;
|
protected ILogger Logger;
|
||||||
|
|
||||||
@ -19,11 +20,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
Logger = logManager.GetLogger(GetType().Name);
|
Logger = logManager.GetLogger(GetType().Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool EnableConnectionPooling
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual async Task<IDbConnection> CreateConnection(bool isReadOnly = false)
|
protected virtual async Task<IDbConnection> CreateConnection(bool isReadOnly = false)
|
||||||
{
|
{
|
||||||
var connection = await DbConnector.Connect(DbFilePath, false, true).ConfigureAwait(false);
|
var connection = await DbConnector.Connect(DbFilePath, false, true).ConfigureAwait(false);
|
||||||
|
|
||||||
connection.RunQueries(new []
|
connection.RunQueries(new[]
|
||||||
{
|
{
|
||||||
"pragma temp_store = memory"
|
"pragma temp_store = memory"
|
||||||
|
|
||||||
@ -45,12 +51,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task Vacuum(IDbConnection connection)
|
protected async Task Vacuum(IDbConnection connection)
|
||||||
{
|
{
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
|
await WriteLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var cmd = connection.CreateCommand())
|
using (var cmd = connection.CreateCommand())
|
||||||
@ -65,7 +74,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
WriteLock.Release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly object _disposeLock = new object();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
@ -73,6 +88,27 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected virtual void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
|
if (dispose)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (_disposeLock)
|
||||||
|
{
|
||||||
|
WriteLock.Wait();
|
||||||
|
|
||||||
|
CloseConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error disposing database", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void CloseConnection()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,12 +39,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
|
|
||||||
var connectionString = connectionstr.ConnectionString;
|
var connectionString = connectionstr.ConnectionString;
|
||||||
|
|
||||||
if (enablePooling)
|
|
||||||
{
|
|
||||||
connectionString += ";Max Pool Size=100";
|
|
||||||
}
|
|
||||||
|
|
||||||
//logger.Info("Sqlite {0} opening {1}", SQLiteConnection.SQLiteVersion, connectionString);
|
//logger.Info("Sqlite {0} opening {1}", SQLiteConnection.SQLiteVersion, connectionString);
|
||||||
|
SQLiteConnection.SetMemoryStatus(false);
|
||||||
|
|
||||||
var connection = new SQLiteConnection(connectionString);
|
var connection = new SQLiteConnection(connectionString);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,11 +15,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository
|
public class SqliteUserDataRepository : BaseSqliteRepository, IUserDataRepository
|
||||||
{
|
{
|
||||||
|
private IDbConnection _connection;
|
||||||
|
|
||||||
public SqliteUserDataRepository(ILogManager logManager, IApplicationPaths appPaths, IDbConnector connector) : base(logManager, connector)
|
public SqliteUserDataRepository(ILogManager logManager, IApplicationPaths appPaths, IDbConnector connector) : base(logManager, connector)
|
||||||
{
|
{
|
||||||
DbFilePath = Path.Combine(appPaths.DataPath, "userdata_v2.db");
|
DbFilePath = Path.Combine(appPaths.DataPath, "userdata_v2.db");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool EnableConnectionPooling
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the repository
|
/// Gets the name of the repository
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -36,23 +43,27 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
/// Opens the connection to the database
|
/// Opens the connection to the database
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public async Task Initialize(IDbConnector dbConnector)
|
public async Task Initialize()
|
||||||
{
|
|
||||||
using (var connection = await CreateConnection().ConfigureAwait(false))
|
|
||||||
{
|
{
|
||||||
|
_connection = await CreateConnection(false).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
"create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
"create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",
|
||||||
|
|
||||||
"create index if not exists idx_userdata on userdata(key)",
|
"create index if not exists idx_userdata on userdata(key)",
|
||||||
"create unique index if not exists userdataindex on userdata (key, userId)"
|
"create unique index if not exists userdataindex on userdata (key, userId)",
|
||||||
|
|
||||||
|
//pragmas
|
||||||
|
"pragma temp_store = memory",
|
||||||
|
|
||||||
|
"pragma shrink_memory"
|
||||||
};
|
};
|
||||||
|
|
||||||
connection.RunQueries(queries, Logger);
|
_connection.RunQueries(queries, Logger);
|
||||||
|
|
||||||
connection.AddColumn(Logger, "userdata", "AudioStreamIndex", "int");
|
_connection.AddColumn(Logger, "userdata", "AudioStreamIndex", "int");
|
||||||
connection.AddColumn(Logger, "userdata", "SubtitleStreamIndex", "int");
|
_connection.AddColumn(Logger, "userdata", "SubtitleStreamIndex", "int");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -114,15 +125,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (var connection = await CreateConnection().ConfigureAwait(false))
|
await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
{
|
|
||||||
IDbTransaction transaction = null;
|
IDbTransaction transaction = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
transaction = connection.BeginTransaction();
|
transaction = _connection.BeginTransaction();
|
||||||
|
|
||||||
using (var cmd = connection.CreateCommand())
|
using (var cmd = _connection.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)";
|
cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)";
|
||||||
|
|
||||||
@ -170,7 +181,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
transaction.Dispose();
|
transaction.Dispose();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
WriteLock.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,17 +197,17 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
using (var connection = await CreateConnection().ConfigureAwait(false))
|
await WriteLock.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
{
|
|
||||||
IDbTransaction transaction = null;
|
IDbTransaction transaction = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
transaction = connection.BeginTransaction();
|
transaction = _connection.BeginTransaction();
|
||||||
|
|
||||||
foreach (var userItemData in userData)
|
foreach (var userItemData in userData)
|
||||||
{
|
{
|
||||||
using (var cmd = connection.CreateCommand())
|
using (var cmd = _connection.CreateCommand())
|
||||||
{
|
{
|
||||||
cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)";
|
cmd.CommandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)";
|
||||||
|
|
||||||
@ -246,7 +258,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
transaction.Dispose();
|
transaction.Dispose();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
WriteLock.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,9 +285,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
throw new ArgumentNullException("key");
|
throw new ArgumentNullException("key");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var connection = CreateConnection(true).Result)
|
using (var cmd = _connection.CreateCommand())
|
||||||
{
|
|
||||||
using (var cmd = connection.CreateCommand())
|
|
||||||
{
|
{
|
||||||
cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = @key and userId=@userId";
|
cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = @key and userId=@userId";
|
||||||
|
|
||||||
@ -292,7 +303,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public UserItemData GetUserData(Guid userId, List<string> keys)
|
public UserItemData GetUserData(Guid userId, List<string> keys)
|
||||||
{
|
{
|
||||||
@ -305,9 +315,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
throw new ArgumentNullException("keys");
|
throw new ArgumentNullException("keys");
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var connection = CreateConnection(true).Result)
|
using (var cmd = _connection.CreateCommand())
|
||||||
{
|
|
||||||
using (var cmd = connection.CreateCommand())
|
|
||||||
{
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
var excludeIds = new List<string>();
|
var excludeIds = new List<string>();
|
||||||
@ -341,7 +349,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return all user-data associated with the given user
|
/// Return all user-data associated with the given user
|
||||||
@ -355,11 +362,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
throw new ArgumentNullException("userId");
|
throw new ArgumentNullException("userId");
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = new List<UserItemData>();
|
using (var cmd = _connection.CreateCommand())
|
||||||
|
|
||||||
using (var connection = CreateConnection(true).Result)
|
|
||||||
{
|
|
||||||
using (var cmd = connection.CreateCommand())
|
|
||||||
{
|
{
|
||||||
cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@userId";
|
cmd.CommandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@userId";
|
||||||
|
|
||||||
@ -369,15 +372,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
{
|
{
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
list.Add(ReadRow(reader));
|
yield return ReadRow(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read a row from the specified reader into the provided userData object
|
/// Read a row from the specified reader into the provided userData object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -416,5 +416,19 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|||||||
|
|
||||||
return userData;
|
return userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void CloseConnection()
|
||||||
|
{
|
||||||
|
if (_connection != null)
|
||||||
|
{
|
||||||
|
if (_connection.IsOpen())
|
||||||
|
{
|
||||||
|
_connection.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
_connection.Dispose();
|
||||||
|
_connection = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -573,7 +573,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
|
|
||||||
await displayPreferencesRepo.Initialize().ConfigureAwait(false);
|
await displayPreferencesRepo.Initialize().ConfigureAwait(false);
|
||||||
await ConfigureUserDataRepositories().ConfigureAwait(false);
|
await ConfigureUserDataRepositories().ConfigureAwait(false);
|
||||||
await itemRepo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);
|
await itemRepo.Initialize().ConfigureAwait(false);
|
||||||
((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
|
((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
|
||||||
await ConfigureNotificationsRepository().ConfigureAwait(false);
|
await ConfigureNotificationsRepository().ConfigureAwait(false);
|
||||||
progress.Report(100);
|
progress.Report(100);
|
||||||
@ -746,7 +746,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|||||||
{
|
{
|
||||||
var repo = new SqliteUserDataRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
|
var repo = new SqliteUserDataRepository(LogManager, ApplicationPaths, NativeApp.GetDbConnector());
|
||||||
|
|
||||||
await repo.Initialize(NativeApp.GetDbConnector()).ConfigureAwait(false);
|
await repo.Initialize().ConfigureAwait(false);
|
||||||
|
|
||||||
((UserDataManager)UserDataManager).Repository = repo;
|
((UserDataManager)UserDataManager).Repository = repo;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user