Import Keyframes into database (#13771)

* Migrate keyframe data into database

* Clear database table before import to handle failed migrations
This commit is contained in:
Tim Eisele
2025-04-03 02:06:40 +02:00
committed by GitHub
parent 49ac705867
commit 0573999d5e
22 changed files with 2128 additions and 78 deletions
@@ -0,0 +1,32 @@
#pragma warning disable CA2227 // Collection properties should be read only
using System;
using System.Collections.Generic;
namespace Jellyfin.Database.Implementations.Entities;
/// <summary>
/// Keyframe information for a specific file.
/// </summary>
public class KeyframeData
{
/// <summary>
/// Gets or Sets the ItemId.
/// </summary>
public required Guid ItemId { get; set; }
/// <summary>
/// Gets or sets the total duration of the stream in ticks.
/// </summary>
public long TotalDuration { get; set; }
/// <summary>
/// Gets or sets the keyframes in ticks.
/// </summary>
public ICollection<long>? KeyframeTicks { get; set; }
/// <summary>
/// Gets or sets the item reference.
/// </summary>
public BaseItemEntity? Item { get; set; }
}
@@ -157,6 +157,11 @@ public class JellyfinDbContext(DbContextOptions<JellyfinDbContext> options, ILog
/// </summary>
public DbSet<BaseItemTrailerType> BaseItemTrailerTypes => Set<BaseItemTrailerType>();
/// <summary>
/// Gets the <see cref="DbSet{TEntity}"/>.
/// </summary>
public DbSet<KeyframeData> KeyframeData => Set<KeyframeData>();
/*public DbSet<Artwork> Artwork => Set<Artwork>();
public DbSet<Book> Books => Set<Book>();
@@ -0,0 +1,18 @@
using Jellyfin.Database.Implementations.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Jellyfin.Database.Implementations.ModelConfiguration;
/// <summary>
/// KeyframeData Configuration.
/// </summary>
public class KeyframeDataConfiguration : IEntityTypeConfiguration<KeyframeData>
{
/// <inheritdoc/>
public void Configure(EntityTypeBuilder<KeyframeData> builder)
{
builder.HasKey(e => e.ItemId);
builder.HasOne(e => e.Item).WithMany().HasForeignKey(e => e.ItemId);
}
}