Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(library): 持续识别标准目录中的 FC2 分片

longmeidao7d934033e13c
diff --git a/scripts/organize_library_dirs.py b/scripts/organize_library_dirs.py
index 6a83c27ca..5cc12748d 100644
--- a/scripts/organize_library_dirs.py
+++ b/scripts/organize_library_dirs.py
@@ -118,10 +118,11 @@ def release_code(row):
strip_promo_markers(row['name']), re.I)
if explicit:
return normalise_code_key('FC2-' + explicit.group(1))
- platform_parent = re.fullmatch(r'FC2(?:[-_ ]?PPV)?',
+ platform_parent = re.fullmatch(r'FC2(?:[-_ ]?PPV)?(?:[-_ ]*(\d{5,}))?',
PureWindowsPath(row.get('path', '')).parent.name, re.I)
platform_part = re.match(r'^(\d{5,})(?=早期購入|本編)', row['name'])
- if platform_parent and platform_part:
+ if (platform_parent and platform_part
+ and platform_parent.group(1) in {None, platform_part.group(1)}):
return normalise_code_key('FC2-' + platform_part.group(1))
short = re.match(r'^@?FC[-_ ]*(\d{5,})(?=[_.-]|$)', row['name'], re.I)
parent = re.match(r'^FC(?:2)?(?:[-_ ]?PPV)?[-_ ]*(\d{5,})(?!\d)',
diff --git a/tests/test_scripts.py b/tests/test_scripts.py
index 81bd60d66..d564969fb 100644
--- a/tests/test_scripts.py
+++ b/tests/test_scripts.py
@@ -249,6 +249,9 @@ class LibraryDirectoryTests(unittest.TestCase):
for name in ('3933828早期購入.mp4', '3933828本編.mp4'):
part = dict(row, name=name, path=str(PureWindowsPath(r'B:\番号\FC2-PPV', name)))
self.assertEqual(self.script.release_code(part), 'FC2-PPV-3933828')
+ canonical = dict(part, path=str(PureWindowsPath(r'B:\日本\FC2\FC2-PPV-3933828', name)))
+ self.assertEqual(self.script.release_code(canonical), 'FC2-PPV-3933828')
+ self.assertEqual(self.script.release_code(dict(canonical, path=str(PureWindowsPath(r'B:\日本\FC2\FC2-PPV-3933829', name)))), '')
self.assertEqual(self.script.release_code(dict(part, studio='Prestige')), '')
self.assertEqual(self.script.release_code(dict(part, path=str(PureWindowsPath(r'B:\unknown', name)))), '')
self.assertEqual(self.script.release_code(dict(row, name='20250105.mp4')), '')