Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Bugfixes (#221)

Joseph Milazzo308e2b48a08e
diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.cs
index 31e1b89d5..e09166585 100644
--- a/API.Tests/Parser/MangaParserTests.cs
+++ b/API.Tests/Parser/MangaParserTests.cs
@@ -144,6 +144,7 @@ namespace API.Tests.Parser
[InlineData("Noblesse - Episode 406 (52 Pages).7z", "Noblesse")]
[InlineData("X-Men v1 #201 (September 2007).cbz", "X-Men")]
[InlineData("Kodoja #001 (March 2016)", "Kodoja")]
+ [InlineData("Boku No Kokoro No Yabai Yatsu - Chapter 054 I Prayed At The Shrine (V0).cbz", "Boku No Kokoro No Yabai Yatsu")]
public void ParseSeriesTest(string filename, string expected)
{
Assert.Equal(expected, API.Parser.Parser.ParseSeries(filename));
@@ -210,6 +211,7 @@ namespace API.Tests.Parser
[InlineData("X-Men v1 #201 (September 2007).cbz", "201")]
[InlineData("Kodoja #001 (March 2016)", "1")]
[InlineData("Noblesse - Episode 429 (74 Pages).7z", "429")]
+ [InlineData("Boku No Kokoro No Yabai Yatsu - Chapter 054 I Prayed At The Shrine (V0).cbz", "54")]
public void ParseChaptersTest(string filename, string expected)
{
Assert.Equal(expected, API.Parser.Parser.ParseChapter(filename));
diff --git a/API/Controllers/ReaderController.cs b/API/Controllers/ReaderController.cs
index 14fc9aead..484bce7ed 100644
--- a/API/Controllers/ReaderController.cs
+++ b/API/Controllers/ReaderController.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using API.Comparators;
using API.DTOs;
using API.Entities;
using API.Extensions;
@@ -19,6 +20,7 @@ namespace API.Controllers
private readonly ICacheService _cacheService;
private readonly ILogger<ReaderController> _logger;
private readonly IUnitOfWork _unitOfWork;
+ private readonly ChapterSortComparer _chapterSortComparer = new ChapterSortComparer();
public ReaderController(IDirectoryService directoryService, ICacheService cacheService,
ILogger<ReaderController> logger, IUnitOfWork unitOfWork)
@@ -252,9 +254,9 @@ namespace API.Controllers
public async Task<ActionResult<int>> GetNextChapter(int seriesId, int volumeId, int currentChapterId)
{
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
+ //if (user == null) return // TODO: Need to have GetUSerByUsernameAsync checks to throw not authorized (401) if it is null all throughout code
var volumes = await _unitOfWork.SeriesRepository.GetVolumesDtoAsync(seriesId, user.Id);
var currentVolume = await _unitOfWork.SeriesRepository.GetVolumeAsync(volumeId);
-
if (currentVolume.Number == 0)
{
@@ -268,7 +270,7 @@ namespace API.Controllers
if (currentChapterId == chapter.Id) next = true;
}
- var chapterId = GetNextChapterId(currentVolume.Chapters, currentChapterId);
+ var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer), currentChapterId);
if (chapterId > 0) return Ok(chapterId);
}
@@ -276,7 +278,7 @@ namespace API.Controllers
{
if (volume.Number == currentVolume.Number && volume.Chapters.Count > 1)
{
- var chapterId = GetNextChapterId(currentVolume.Chapters, currentChapterId);
+ var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer), currentChapterId);
if (chapterId > 0) return Ok(chapterId);
}
@@ -320,7 +322,7 @@ namespace API.Controllers
if (currentVolume.Number == 0)
{
- var chapterId = GetNextChapterId(currentVolume.Chapters.Reverse(), currentChapterId);
+ var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer).Reverse(), currentChapterId);
if (chapterId > 0) return Ok(chapterId);
}
@@ -328,7 +330,7 @@ namespace API.Controllers
{
if (volume.Number == currentVolume.Number)
{
- var chapterId = GetNextChapterId(currentVolume.Chapters.Reverse(), currentChapterId);
+ var chapterId = GetNextChapterId(currentVolume.Chapters.OrderBy(x => double.Parse(x.Number), _chapterSortComparer).Reverse(), currentChapterId);
if (chapterId > 0) return Ok(chapterId);
}
if (volume.Number == currentVolume.Number - 1)
diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs
index 23f9b70c5..024f11640 100644
--- a/API/Parser/Parser.cs
+++ b/API/Parser/Parser.cs
@@ -88,7 +88,7 @@ namespace API.Parser
RegexOptions.IgnoreCase | RegexOptions.Compiled),
//Tonikaku Cawaii [Volume 11], Darling in the FranXX - Volume 01.cbz
new Regex(
- @"(?<Series>.*)(?: _|-|\[|\() ?v",
+ @"(?<Series>.*)(?: _|-|\[|\()\s?vol(ume)?",
RegexOptions.IgnoreCase | RegexOptions.Compiled),
// Momo The Blood Taker - Chapter 027 Violent Emotion.cbz
new Regex(
diff --git a/API/Program.cs b/API/Program.cs
index db3ad9a1f..b773733b5 100644
--- a/API/Program.cs
+++ b/API/Program.cs
@@ -36,7 +36,7 @@ namespace API
public static async Task Main(string[] args)
{
// Before anything, check if JWT has been generated properly or if user still has default
- if (!Configuration.CheckIfJwtTokenSet(GetAppSettingFilename()))
+ if (!Configuration.CheckIfJwtTokenSet(GetAppSettingFilename()) && Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") != Environments.Development)
{
Console.WriteLine("Generating JWT TokenKey for encrypting user sessions...");
var rBytes = new byte[24];