Merge pull request #13847 from Shadowghost/rework-chapter-management

Rework chapter management
This commit is contained in:
Tim Eisele
2025-04-26 14:01:12 +02:00
committed by GitHub
parent f35b8dd33d
commit df5671263f
15 changed files with 447 additions and 395 deletions

View File

@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Jellyfin.Database.Implementations;
using Jellyfin.Database.Implementations.Entities;
using MediaBrowser.Controller.Chapters;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Model.Dto;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using Microsoft.EntityFrameworkCore;
@@ -31,19 +29,7 @@ public class ChapterRepository : IChapterRepository
_imageProcessor = imageProcessor;
}
/// <inheritdoc cref="IChapterRepository"/>
public ChapterInfo? GetChapter(BaseItemDto baseItem, int index)
{
return GetChapter(baseItem.Id, index);
}
/// <inheritdoc cref="IChapterRepository"/>
public IReadOnlyList<ChapterInfo> GetChapters(BaseItemDto baseItem)
{
return GetChapters(baseItem.Id);
}
/// <inheritdoc cref="IChapterRepository"/>
/// <inheritdoc />
public ChapterInfo? GetChapter(Guid baseItemId, int index)
{
using var context = _dbProvider.CreateDbContext();
@@ -62,7 +48,7 @@ public class ChapterRepository : IChapterRepository
return null;
}
/// <inheritdoc cref="IChapterRepository"/>
/// <inheritdoc />
public IReadOnlyList<ChapterInfo> GetChapters(Guid baseItemId)
{
using var context = _dbProvider.CreateDbContext();
@@ -77,7 +63,7 @@ public class ChapterRepository : IChapterRepository
.ToArray();
}
/// <inheritdoc cref="IChapterRepository"/>
/// <inheritdoc />
public void SaveChapters(Guid itemId, IReadOnlyList<ChapterInfo> chapters)
{
using var context = _dbProvider.CreateDbContext();
@@ -95,6 +81,14 @@ public class ChapterRepository : IChapterRepository
}
}
/// <inheritdoc />
public void DeleteChapters(Guid itemId)
{
using var context = _dbProvider.CreateDbContext();
context.Chapters.Where(c => c.ItemId.Equals(itemId)).ExecuteDelete();
context.SaveChanges();
}
private Chapter Map(ChapterInfo chapterInfo, int index, Guid itemId)
{
return new Chapter()