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
12 changed files with 122 additions and 49 deletions
|
|
@ -102,7 +102,7 @@ public class ReaderController : BaseApiController
|
|||
|
||||
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.");
|
||||
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>
|
||||
/// Returns various information about a Chapter. Side effect: This will cache the chapter images for reading.
|
||||
/// </summary>
|
||||
|
|
@ -183,7 +200,7 @@ public class ReaderController : BaseApiController
|
|||
Pages = dto.Pages,
|
||||
ChapterTitle = dto.ChapterTitle ?? string.Empty,
|
||||
Subtitle = string.Empty,
|
||||
Title = dto.SeriesName
|
||||
Title = dto.SeriesName,
|
||||
};
|
||||
|
||||
if (info.ChapterTitle is {Length: > 0}) {
|
||||
|
|
@ -195,14 +212,14 @@ public class ReaderController : BaseApiController
|
|||
info.Subtitle = info.FileName;
|
||||
} 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
|
||||
{
|
||||
info.Subtitle = "Volume " + info.VolumeNumber;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -673,7 +690,7 @@ public class ReaderController : BaseApiController
|
|||
if (chapter == null) return BadRequest("Could not find cached image. Reload and try again.");
|
||||
|
||||
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");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue