Skip to content

Correctly parse volume and chapter when at start of filename#273

Open
spin-drift wants to merge 1 commit intoSnd-R:masterfrom
spin-drift:parse-leading-volume-chapter
Open

Correctly parse volume and chapter when at start of filename#273
spin-drift wants to merge 1 commit intoSnd-R:masterfrom
spin-drift:parse-leading-volume-chapter

Conversation

@spin-drift
Copy link

Summary

This adjusts volumeRegexes and chapterRegexes to find matches that start at the beginning of a filename. These changes allow for proper reordering of volumes before chapters (and, where possible, locking in chapters) in cases where a Mihon derivative has stripped the series title from the filename.

Problem

Suwayomi-Server (one of many Mihon derivatives) automatically strips the series title from the filename when downloading, but ONLY IF it's an exact match. (I believe it matches using the <Series> in ComicInfo.xml.)

Komf's current regexes do not recognize volumes in the modified filenames, which prevents them from being reordered before chapters in Komga.

Series title in source Original filename Gets downloaded as
Urasakai Picnic Otherside Picnic v01 (2021) (Digital).cbz (same)
Blame! BLAME! Master Edition v01 (2016) (Digital).cbz (same)
Gachi Akuta Gachiakuta v01 (2024) (Digital).cbz (same)
Dandadan Dandadan v01 (2022) (Digital).cbz v01 (2022) (Digital).cbz
Jujutsu Kaisen Modulo Jujutsu Kaisen Modulo 001 (2025) (Digital).cbz 001 (2025) (Digital).cbz

This behavior apparently comes from Mihon (or earlier), and the likelihood of the upstream project changing it appears to be very low. Thus, the attempt to accommodate it in Komf.

Changes

Volume: Replaces ,?\s with (?:^|,?\s) (matches line start OR optional comma and required whitespace)

Chapter: Factors out whitespace from (\sc|\s?ch\.\s|\s?chapter\s|\s?ep\.\s) and replaces with (?:^|\s?)(c|ch\.\s|chapter\s|ep\.\s) (matches line start OR optional whitespace; makes leading whitespace optional for all chapter conventions).

Impact

  • Volumes are always recognized when starting a filename.
  • Chapters are recognized when starting a filename.
  • Small false positive risk for titles that include a number directly after c. (I could not find any such titles.)

Testing

  • Compiled Komf locally with modified regexes.
  • Ran on my Komga collection with no ill effects, and volumes parsed properly.

Other notes

Despite the examples I gave, I did not change anything that would allow Komf to recognize manga chapters in the format ###—whether after a title or not—as the risk of false positives is too high. However, Komga parses leading numbers itself just fine, so IMO only volume handling is essential.

If the changes to chapter regexes are controversial, I'm happy to back off of them, but would strongly prefer allowing the modified volume regex regardless. :)

… filename

This accommodates a long-standing behavior in Mihon derivatives that strips series from filename under certain conditions.
@Eagle1337
Copy link

Eagle1337 commented Feb 8, 2026

this seems to work pretty well from my testing, it still gets tripped up over things like volume 8 extras but it's a lot more accurate at getting chapter numbers in general. I should also add that C001 and such makes komf also order what some rippers use in their file naming for their releases.

@Eagle1337
Copy link

Eagle1337 commented Feb 14, 2026

further testing, it doesn't look like it's grabbing Cxx correctly.
the file naming is:
series name c009 (2026) (Digital)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments