mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
File Dimension API (#1690)
* Implemented an api for getting file dimensions for a given chapter. This is for CDisplayEx integration. This might be usable in Double Renderer. * Added the cached filename for new API
This commit is contained in:
parent
0961cac65a
commit
e6b18457f2
@ -325,7 +325,7 @@ public class CacheServiceTests
|
|||||||
// Flatten to prepare for how GetFullPath expects
|
// Flatten to prepare for how GetFullPath expects
|
||||||
ds.Flatten($"{CacheDirectory}1/");
|
ds.Flatten($"{CacheDirectory}1/");
|
||||||
|
|
||||||
var path = cs.GetCachedPagePath(c, 11);
|
var path = cs.GetCachedPagePath(c.Id, 11);
|
||||||
Assert.Equal(string.Empty, path);
|
Assert.Equal(string.Empty, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ public class CacheServiceTests
|
|||||||
// Flatten to prepare for how GetFullPath expects
|
// Flatten to prepare for how GetFullPath expects
|
||||||
ds.Flatten($"{CacheDirectory}1/");
|
ds.Flatten($"{CacheDirectory}1/");
|
||||||
|
|
||||||
Assert.Equal(ds.FileSystem.Path.GetFullPath($"{CacheDirectory}/1/000_001.jpg"), ds.FileSystem.Path.GetFullPath(cs.GetCachedPagePath(c, 0)));
|
Assert.Equal(ds.FileSystem.Path.GetFullPath($"{CacheDirectory}/1/000_001.jpg"), ds.FileSystem.Path.GetFullPath(cs.GetCachedPagePath(c.Id, 0)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +425,7 @@ public class CacheServiceTests
|
|||||||
ds.Flatten($"{CacheDirectory}1/");
|
ds.Flatten($"{CacheDirectory}1/");
|
||||||
|
|
||||||
// Remember that we start at 0, so this is the 10th file
|
// Remember that we start at 0, so this is the 10th file
|
||||||
var path = cs.GetCachedPagePath(c, c.Pages);
|
var path = cs.GetCachedPagePath(c.Id, c.Pages);
|
||||||
Assert.Equal(ds.FileSystem.Path.GetFullPath($"{CacheDirectory}/1/000_0{c.Pages}.jpg"), ds.FileSystem.Path.GetFullPath(path));
|
Assert.Equal(ds.FileSystem.Path.GetFullPath($"{CacheDirectory}/1/000_0{c.Pages}.jpg"), ds.FileSystem.Path.GetFullPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ public class CacheServiceTests
|
|||||||
ds.Flatten($"{CacheDirectory}1/");
|
ds.Flatten($"{CacheDirectory}1/");
|
||||||
|
|
||||||
// Remember that we start at 0, so this is the page + 1 file
|
// Remember that we start at 0, so this is the page + 1 file
|
||||||
var path = cs.GetCachedPagePath(c, 10);
|
var path = cs.GetCachedPagePath(c.Id, 10);
|
||||||
Assert.Equal(ds.FileSystem.Path.GetFullPath($"{CacheDirectory}/1/001_001.jpg"), ds.FileSystem.Path.GetFullPath(path));
|
Assert.Equal(ds.FileSystem.Path.GetFullPath($"{CacheDirectory}/1/001_001.jpg"), ds.FileSystem.Path.GetFullPath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2357,7 +2357,7 @@ public class ReaderServiceTests
|
|||||||
public void FormatChapterName_Manga_Chapter()
|
public void FormatChapterName_Manga_Chapter()
|
||||||
{
|
{
|
||||||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||||
var actual = readerService.FormatChapterName(LibraryType.Manga, false, false);
|
var actual = ReaderService.FormatChapterName(LibraryType.Manga, false, false);
|
||||||
Assert.Equal("Chapter", actual);
|
Assert.Equal("Chapter", actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2365,7 +2365,7 @@ public class ReaderServiceTests
|
|||||||
public void FormatChapterName_Book_Chapter_WithTitle()
|
public void FormatChapterName_Book_Chapter_WithTitle()
|
||||||
{
|
{
|
||||||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||||
var actual = readerService.FormatChapterName(LibraryType.Book, false, false);
|
var actual = ReaderService.FormatChapterName(LibraryType.Book, false, false);
|
||||||
Assert.Equal("Book", actual);
|
Assert.Equal("Book", actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2373,7 +2373,7 @@ public class ReaderServiceTests
|
|||||||
public void FormatChapterName_Comic()
|
public void FormatChapterName_Comic()
|
||||||
{
|
{
|
||||||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||||
var actual = readerService.FormatChapterName(LibraryType.Comic, false, false);
|
var actual = ReaderService.FormatChapterName(LibraryType.Comic, false, false);
|
||||||
Assert.Equal("Issue", actual);
|
Assert.Equal("Issue", actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2381,7 +2381,7 @@ public class ReaderServiceTests
|
|||||||
public void FormatChapterName_Comic_WithHash()
|
public void FormatChapterName_Comic_WithHash()
|
||||||
{
|
{
|
||||||
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(), Substitute.For<IEventHub>());
|
||||||
var actual = readerService.FormatChapterName(LibraryType.Comic, true, true);
|
var actual = ReaderService.FormatChapterName(LibraryType.Comic, true, true);
|
||||||
Assert.Equal("Issue #", actual);
|
Assert.Equal("Issue #", actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,7 +824,7 @@ public class OpdsController : BaseApiController
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = _cacheService.GetCachedPagePath(chapter, pageNumber);
|
var path = _cacheService.GetCachedPagePath(chapter.Id, pageNumber);
|
||||||
if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path)) return BadRequest($"No such image for page {pageNumber}");
|
if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path)) return BadRequest($"No such image for page {pageNumber}");
|
||||||
|
|
||||||
var content = await _directoryService.ReadFileAsync(path);
|
var content = await _directoryService.ReadFileAsync(path);
|
||||||
|
@ -102,7 +102,7 @@ public class ReaderController : BaseApiController
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = _cacheService.GetCachedPagePath(chapter, page);
|
var path = _cacheService.GetCachedPagePath(chapter.Id, page);
|
||||||
if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path)) return BadRequest($"No such image for page {page}. Try refreshing to allow re-cache.");
|
if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path)) return BadRequest($"No such image for page {page}. Try refreshing to allow re-cache.");
|
||||||
var format = Path.GetExtension(path).Replace(".", "");
|
var format = Path.GetExtension(path).Replace(".", "");
|
||||||
|
|
||||||
@ -152,6 +152,23 @@ public class ReaderController : BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the file dimensions for all pages in a chapter. If the underlying chapter is PDF, use extractPDF to unpack as images.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This has a side effect of caching the images.
|
||||||
|
/// This will only be populated on archive filetypes and not in bookmark mode</remarks>
|
||||||
|
/// <param name="chapterId"></param>
|
||||||
|
/// <param name="extractPdf"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("file-dimensions")]
|
||||||
|
public async Task<ActionResult<IEnumerable<FileDimensionDto>>> GetFileDimensions(int chapterId, bool extractPdf = false)
|
||||||
|
{
|
||||||
|
if (chapterId <= 0) return null;
|
||||||
|
var chapter = await _cacheService.Ensure(chapterId, extractPdf);
|
||||||
|
if (chapter == null) return BadRequest("Could not find Chapter");
|
||||||
|
return Ok(_cacheService.GetCachedFileDimensions(chapterId));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns various information about a Chapter. Side effect: This will cache the chapter images for reading.
|
/// Returns various information about a Chapter. Side effect: This will cache the chapter images for reading.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -183,7 +200,7 @@ public class ReaderController : BaseApiController
|
|||||||
Pages = dto.Pages,
|
Pages = dto.Pages,
|
||||||
ChapterTitle = dto.ChapterTitle ?? string.Empty,
|
ChapterTitle = dto.ChapterTitle ?? string.Empty,
|
||||||
Subtitle = string.Empty,
|
Subtitle = string.Empty,
|
||||||
Title = dto.SeriesName
|
Title = dto.SeriesName,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (info.ChapterTitle is {Length: > 0}) {
|
if (info.ChapterTitle is {Length: > 0}) {
|
||||||
@ -195,14 +212,14 @@ public class ReaderController : BaseApiController
|
|||||||
info.Subtitle = info.FileName;
|
info.Subtitle = info.FileName;
|
||||||
} else if (!info.IsSpecial && info.VolumeNumber.Equals(Services.Tasks.Scanner.Parser.Parser.DefaultVolume))
|
} else if (!info.IsSpecial && info.VolumeNumber.Equals(Services.Tasks.Scanner.Parser.Parser.DefaultVolume))
|
||||||
{
|
{
|
||||||
info.Subtitle = _readerService.FormatChapterName(info.LibraryType, true, true) + info.ChapterNumber;
|
info.Subtitle = ReaderService.FormatChapterName(info.LibraryType, true, true) + info.ChapterNumber;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info.Subtitle = "Volume " + info.VolumeNumber;
|
info.Subtitle = "Volume " + info.VolumeNumber;
|
||||||
if (!info.ChapterNumber.Equals(Services.Tasks.Scanner.Parser.Parser.DefaultChapter))
|
if (!info.ChapterNumber.Equals(Services.Tasks.Scanner.Parser.Parser.DefaultChapter))
|
||||||
{
|
{
|
||||||
info.Subtitle += " " + _readerService.FormatChapterName(info.LibraryType, true, true) +
|
info.Subtitle += " " + ReaderService.FormatChapterName(info.LibraryType, true, true) +
|
||||||
info.ChapterNumber;
|
info.ChapterNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -673,7 +690,7 @@ public class ReaderController : BaseApiController
|
|||||||
if (chapter == null) return BadRequest("Could not find cached image. Reload and try again.");
|
if (chapter == null) return BadRequest("Could not find cached image. Reload and try again.");
|
||||||
|
|
||||||
bookmarkDto.Page = _readerService.CapPageToChapter(chapter, bookmarkDto.Page);
|
bookmarkDto.Page = _readerService.CapPageToChapter(chapter, bookmarkDto.Page);
|
||||||
var path = _cacheService.GetCachedPagePath(chapter, bookmarkDto.Page);
|
var path = _cacheService.GetCachedPagePath(chapter.Id, bookmarkDto.Page);
|
||||||
|
|
||||||
if (!await _bookmarkService.BookmarkPage(user, bookmarkDto, path)) return BadRequest("Could not save bookmark");
|
if (!await _bookmarkService.BookmarkPage(user, bookmarkDto, path)) return BadRequest("Could not save bookmark");
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using API.Entities.Enums;
|
using System.Collections.Generic;
|
||||||
|
using API.Entities.Enums;
|
||||||
|
|
||||||
namespace API.DTOs.Reader;
|
namespace API.DTOs.Reader;
|
||||||
|
|
||||||
|
13
API/DTOs/Reader/FileDimensionDto.cs
Normal file
13
API/DTOs/Reader/FileDimensionDto.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace API.DTOs.Reader;
|
||||||
|
|
||||||
|
public class FileDimensionDto
|
||||||
|
{
|
||||||
|
public int Width { get; set; }
|
||||||
|
public int Height { get; set; }
|
||||||
|
public int PageNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The filename of the cached file. If this was nested in a subfolder, the foldername will be appended with _
|
||||||
|
/// </summary>
|
||||||
|
/// <example>chapter01_page01.png</example>
|
||||||
|
public string FileName { get; set; } = default!;
|
||||||
|
}
|
@ -3,6 +3,7 @@ using System.Text.RegularExpressions;
|
|||||||
using API.DTOs.ReadingLists;
|
using API.DTOs.ReadingLists;
|
||||||
using API.Entities;
|
using API.Entities;
|
||||||
using API.Entities.Enums;
|
using API.Entities.Enums;
|
||||||
|
using API.Services;
|
||||||
|
|
||||||
namespace API.Helpers;
|
namespace API.Helpers;
|
||||||
|
|
||||||
@ -40,35 +41,9 @@ public static class ReadingListHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (title == string.Empty) {
|
if (title == string.Empty) {
|
||||||
title = FormatChapterName(item.LibraryType, true, true) + chapterNum;
|
title = ReaderService.FormatChapterName(item.LibraryType, true, true) + chapterNum;
|
||||||
}
|
}
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Formats a Chapter name based on the library it's in
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="libraryType"></param>
|
|
||||||
/// <param name="includeHash">For comics only, includes a # which is used for numbering on cards</param>
|
|
||||||
/// <param name="includeSpace">Add a space at the end of the string. if includeHash and includeSpace are true, only hash will be at the end.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private static string FormatChapterName(LibraryType libraryType, bool includeHash = false,
|
|
||||||
bool includeSpace = false)
|
|
||||||
{
|
|
||||||
switch (libraryType)
|
|
||||||
{
|
|
||||||
case LibraryType.Manga:
|
|
||||||
return "Chapter" + (includeSpace ? " " : string.Empty);
|
|
||||||
case LibraryType.Comic:
|
|
||||||
if (includeHash) {
|
|
||||||
return "Issue #";
|
|
||||||
}
|
|
||||||
return "Issue" + (includeSpace ? " " : string.Empty);
|
|
||||||
case LibraryType.Book:
|
|
||||||
return "Book" + (includeSpace ? " " : string.Empty);
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(libraryType), libraryType, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,13 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using API.Comparators;
|
using API.Comparators;
|
||||||
using API.Data;
|
using API.Data;
|
||||||
|
using API.DTOs.Reader;
|
||||||
using API.Entities;
|
using API.Entities;
|
||||||
using API.Entities.Enums;
|
using API.Entities.Enums;
|
||||||
using API.Extensions;
|
using API.Extensions;
|
||||||
using Kavita.Common;
|
using Kavita.Common;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using NetVips;
|
||||||
|
|
||||||
namespace API.Services;
|
namespace API.Services;
|
||||||
|
|
||||||
@ -29,7 +31,8 @@ public interface ICacheService
|
|||||||
/// <param name="chapterIds">Volumes that belong to that library. Assume the library might have been deleted before this invocation.</param>
|
/// <param name="chapterIds">Volumes that belong to that library. Assume the library might have been deleted before this invocation.</param>
|
||||||
void CleanupChapters(IEnumerable<int> chapterIds);
|
void CleanupChapters(IEnumerable<int> chapterIds);
|
||||||
void CleanupBookmarks(IEnumerable<int> seriesIds);
|
void CleanupBookmarks(IEnumerable<int> seriesIds);
|
||||||
string GetCachedPagePath(Chapter chapter, int page);
|
string GetCachedPagePath(int chapterId, int page);
|
||||||
|
IEnumerable<FileDimensionDto> GetCachedFileDimensions(int chapterId);
|
||||||
string GetCachedBookmarkPagePath(int seriesId, int page);
|
string GetCachedBookmarkPagePath(int seriesId, int page);
|
||||||
string GetCachedFile(Chapter chapter);
|
string GetCachedFile(Chapter chapter);
|
||||||
public void ExtractChapterFiles(string extractPath, IReadOnlyList<MangaFile> files, bool extractPdfImages = false);
|
public void ExtractChapterFiles(string extractPath, IReadOnlyList<MangaFile> files, bool extractPdfImages = false);
|
||||||
@ -55,6 +58,35 @@ public class CacheService : ICacheService
|
|||||||
_bookmarkService = bookmarkService;
|
_bookmarkService = bookmarkService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<FileDimensionDto> GetCachedFileDimensions(int chapterId)
|
||||||
|
{
|
||||||
|
var path = GetCachePath(chapterId);
|
||||||
|
var files = _directoryService.GetFilesWithExtension(path, Tasks.Scanner.Parser.Parser.ImageFileExtensions)
|
||||||
|
.OrderByNatural(Path.GetFileNameWithoutExtension)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
if (files.Length == 0)
|
||||||
|
{
|
||||||
|
return ArraySegment<FileDimensionDto>.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dimensions = new List<FileDimensionDto>();
|
||||||
|
for (var i = 0; i < files.Length; i++)
|
||||||
|
{
|
||||||
|
var file = files[i];
|
||||||
|
using var image = Image.NewFromStream(File.OpenRead(file), access: Enums.Access.SequentialUnbuffered);
|
||||||
|
dimensions.Add(new FileDimensionDto()
|
||||||
|
{
|
||||||
|
PageNumber = i,
|
||||||
|
Height = image.Height,
|
||||||
|
Width = image.Width,
|
||||||
|
FileName = file
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
public string GetCachedBookmarkPagePath(int seriesId, int page)
|
public string GetCachedBookmarkPagePath(int seriesId, int page)
|
||||||
{
|
{
|
||||||
// Calculate what chapter the page belongs to
|
// Calculate what chapter the page belongs to
|
||||||
@ -208,13 +240,13 @@ public class CacheService : ICacheService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the absolute path of a cached page.
|
/// Returns the absolute path of a cached page.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="chapter">Chapter entity with Files populated.</param>
|
/// <param name="chapterId">Chapter id with Files populated.</param>
|
||||||
/// <param name="page">Page number to look for</param>
|
/// <param name="page">Page number to look for</param>
|
||||||
/// <returns>Page filepath or empty if no files found.</returns>
|
/// <returns>Page filepath or empty if no files found.</returns>
|
||||||
public string GetCachedPagePath(Chapter chapter, int page)
|
public string GetCachedPagePath(int chapterId, int page)
|
||||||
{
|
{
|
||||||
// Calculate what chapter the page belongs to
|
// Calculate what chapter the page belongs to
|
||||||
var path = GetCachePath(chapter.Id);
|
var path = GetCachePath(chapterId);
|
||||||
// TODO: We can optimize this by extracting and renaming, so we don't need to scan for the files and can do a direct access
|
// TODO: We can optimize this by extracting and renaming, so we don't need to scan for the files and can do a direct access
|
||||||
var files = _directoryService.GetFilesWithExtension(path, Tasks.Scanner.Parser.Parser.ImageFileExtensions)
|
var files = _directoryService.GetFilesWithExtension(path, Tasks.Scanner.Parser.Parser.ImageFileExtensions)
|
||||||
.OrderByNatural(Path.GetFileNameWithoutExtension)
|
.OrderByNatural(Path.GetFileNameWithoutExtension)
|
||||||
|
@ -32,7 +32,6 @@ public interface IReaderService
|
|||||||
Task MarkChaptersUntilAsRead(AppUser user, int seriesId, float chapterNumber);
|
Task MarkChaptersUntilAsRead(AppUser user, int seriesId, float chapterNumber);
|
||||||
Task MarkVolumesUntilAsRead(AppUser user, int seriesId, int volumeNumber);
|
Task MarkVolumesUntilAsRead(AppUser user, int seriesId, int volumeNumber);
|
||||||
HourEstimateRangeDto GetTimeEstimate(long wordCount, int pageCount, bool isEpub);
|
HourEstimateRangeDto GetTimeEstimate(long wordCount, int pageCount, bool isEpub);
|
||||||
string FormatChapterName(LibraryType libraryType, bool includeHash = false, bool includeSpace = false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReaderService : IReaderService
|
public class ReaderService : IReaderService
|
||||||
@ -612,7 +611,7 @@ public class ReaderService : IReaderService
|
|||||||
/// <param name="includeHash">For comics only, includes a # which is used for numbering on cards</param>
|
/// <param name="includeHash">For comics only, includes a # which is used for numbering on cards</param>
|
||||||
/// <param name="includeSpace">Add a space at the end of the string. if includeHash and includeSpace are true, only hash will be at the end.</param>
|
/// <param name="includeSpace">Add a space at the end of the string. if includeHash and includeSpace are true, only hash will be at the end.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string FormatChapterName(LibraryType libraryType, bool includeHash = false, bool includeSpace = false)
|
public static string FormatChapterName(LibraryType libraryType, bool includeHash = false, bool includeSpace = false)
|
||||||
{
|
{
|
||||||
switch(libraryType)
|
switch(libraryType)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ import { ProgressBookmark } from '../_models/readers/progress-bookmark';
|
|||||||
import { SeriesFilter } from '../_models/metadata/series-filter';
|
import { SeriesFilter } from '../_models/metadata/series-filter';
|
||||||
import { UtilityService } from '../shared/_services/utility.service';
|
import { UtilityService } from '../shared/_services/utility.service';
|
||||||
import { FilterUtilitiesService } from '../shared/_services/filter-utilities.service';
|
import { FilterUtilitiesService } from '../shared/_services/filter-utilities.service';
|
||||||
|
import { FileDimension } from '../manga-reader/_models/file-dimension';
|
||||||
|
|
||||||
export const CHAPTER_ID_DOESNT_EXIST = -1;
|
export const CHAPTER_ID_DOESNT_EXIST = -1;
|
||||||
export const CHAPTER_ID_NOT_FETCHED = -2;
|
export const CHAPTER_ID_NOT_FETCHED = -2;
|
||||||
@ -106,6 +107,10 @@ export class ReaderService {
|
|||||||
return this.httpClient.get<ChapterInfo>(this.baseUrl + 'reader/chapter-info?chapterId=' + chapterId);
|
return this.httpClient.get<ChapterInfo>(this.baseUrl + 'reader/chapter-info?chapterId=' + chapterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFileDimensions(chapterId: number) {
|
||||||
|
return this.httpClient.get<Array<FileDimension>>(this.baseUrl + 'reader/file-dimensions?chapterId=' + chapterId);
|
||||||
|
}
|
||||||
|
|
||||||
saveProgress(libraryId: number, seriesId: number, volumeId: number, chapterId: number, page: number, bookScrollId: string | null = null) {
|
saveProgress(libraryId: number, seriesId: number, volumeId: number, chapterId: number, page: number, bookScrollId: string | null = null) {
|
||||||
return this.httpClient.post(this.baseUrl + 'reader/progress', {libraryId, seriesId, volumeId, chapterId, pageNum: page, bookScrollId});
|
return this.httpClient.post(this.baseUrl + 'reader/progress', {libraryId, seriesId, volumeId, chapterId, pageNum: page, bookScrollId});
|
||||||
}
|
}
|
||||||
|
5
UI/Web/src/app/manga-reader/_models/file-dimension.ts
Normal file
5
UI/Web/src/app/manga-reader/_models/file-dimension.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface FileDimension {
|
||||||
|
pageNumber: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
}
|
28
openapi.json
28
openapi.json
@ -7,7 +7,7 @@
|
|||||||
"name": "GPL-3.0",
|
"name": "GPL-3.0",
|
||||||
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
"url": "https://github.com/Kareadita/Kavita/blob/develop/LICENSE"
|
||||||
},
|
},
|
||||||
"version": "0.6.1.9"
|
"version": "0.6.1.10"
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
{
|
{
|
||||||
@ -9829,6 +9829,14 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Series Title",
|
"description": "Series Title",
|
||||||
"nullable": true
|
"nullable": true
|
||||||
|
},
|
||||||
|
"fileDimensions": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/components/schemas/FileDimensionDto"
|
||||||
|
},
|
||||||
|
"description": "A list of images and their dimensions to be used with double page readers",
|
||||||
|
"nullable": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
@ -10231,6 +10239,24 @@
|
|||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "Represents if Test Email Service URL was successful or not and if any error occured"
|
"description": "Represents if Test Email Service URL was successful or not and if any error occured"
|
||||||
},
|
},
|
||||||
|
"FileDimensionDto": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"width": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"height": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
"pageNumber": {
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int32"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
"FileExtensionBreakdownDto": {
|
"FileExtensionBreakdownDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user