fix: more patterns
This commit is contained in:
parent
50b33f53d7
commit
9e7f7b4cfc
@@ -33,6 +33,18 @@ readonly class FilenameAnalyzer implements FilenameAnalyzerInterface
|
||||
|
||||
private function extractTitle(string $fileName): string
|
||||
{
|
||||
// Pattern avec tirets complets : titre-volume-42-chapter-100 ou titre-chapitre-100-volume-42
|
||||
$fullDashCombinedPattern = '/^(?P<title>.*?)-(?:volume|chapter|chapitre)-\d+-(?:volume|chapter|chapitre)-\d+/i';
|
||||
if (preg_match($fullDashCombinedPattern, $fileName, $matches)) {
|
||||
return trim($matches['title']);
|
||||
}
|
||||
|
||||
// Pattern avec tirets complets : titre-volume-42 ou titre-chapter-100 ou titre-chapitre-100
|
||||
$fullDashPattern = '/^(?P<title>.*?)-(?:volume|chapter|chapitre)-\d+/i';
|
||||
if (preg_match($fullDashPattern, $fileName, $matches)) {
|
||||
return trim($matches['title']);
|
||||
}
|
||||
|
||||
// Pattern principal : titre suivi de volume/chapitre (inspiré du CbzService)
|
||||
// Supporte: vol, volume, tome, t, ch, chap, chapter, chapitre
|
||||
$titlePattern = '/^(?P<title>.+?)(?:\s*-\s*|\s+)?(?:(?:[Tt]ome|[Vv]ol(?:ume)?\.?|[Cc]h(?:ap(?:itre|ter)?)?|[Tt])\s*\d+)/';
|
||||
@@ -70,6 +82,12 @@ readonly class FilenameAnalyzer implements FilenameAnalyzerInterface
|
||||
return (int) $matches['volume'];
|
||||
}
|
||||
|
||||
// Pattern avec tirets complets pour volume : volume-42
|
||||
$fullDashVolumePattern = '/volume-(?P<volume>\d+)/i';
|
||||
if (preg_match($fullDashVolumePattern, $fileName, $matches)) {
|
||||
return (int) $matches['volume'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -81,6 +99,12 @@ readonly class FilenameAnalyzer implements FilenameAnalyzerInterface
|
||||
return (float) $matches['chapter'];
|
||||
}
|
||||
|
||||
// Pattern avec tirets complets pour chapitre : chapter-100 ou chapitre-100
|
||||
$fullDashChapterPattern = '/(?:chapter|chapitre)-(?P<chapter>\d+(?:\.\d+)?)/i';
|
||||
if (preg_match($fullDashChapterPattern, $fileName, $matches)) {
|
||||
return (float) $matches['chapter'];
|
||||
}
|
||||
|
||||
// Pattern underscore à la fin : _123.cbz
|
||||
$newFormatPattern = '/_ch(?P<chapter>\d+(?:\.\d+)?)(?:\.\w+)?$/i';
|
||||
if (preg_match($newFormatPattern, $fileName, $matches)) {
|
||||
|
||||
Reference in New Issue
Block a user