mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-04 12:00:21 +00:00
fix manual import splitext matching invalid extensions, #311
This commit is contained in:
parent
a7aead728c
commit
e51a662da9
@ -217,9 +217,7 @@ class ImportFolderScanner:
|
|||||||
last_base = False
|
last_base = False
|
||||||
|
|
||||||
for file_path in all_files:
|
for file_path in all_files:
|
||||||
base_name_raw, ext = os.path.splitext(file_path)
|
base_name, ext = self._detect_base_name(file_path)
|
||||||
base_name, _ = os.path.splitext(base_name_raw)
|
|
||||||
|
|
||||||
key, file_path = self._detect_type(file_path, ext)
|
key, file_path = self._detect_type(file_path, ext)
|
||||||
if not key or not file_path:
|
if not key or not file_path:
|
||||||
continue
|
continue
|
||||||
@ -239,6 +237,18 @@ class ImportFolderScanner:
|
|||||||
if current_video.get("media"):
|
if current_video.get("media"):
|
||||||
self.to_import.append(current_video)
|
self.to_import.append(current_video)
|
||||||
|
|
||||||
|
def _detect_base_name(self, file_path):
|
||||||
|
"""extract base_name and ext for matching"""
|
||||||
|
base_name_raw, ext = os.path.splitext(file_path)
|
||||||
|
base_name, ext2 = os.path.splitext(base_name_raw)
|
||||||
|
|
||||||
|
if ext2:
|
||||||
|
if ISO639Utils.short2long(ext2.strip(".")) or ext2 == ".info":
|
||||||
|
# valid secondary extension
|
||||||
|
return base_name, ext
|
||||||
|
|
||||||
|
return base_name_raw, ext
|
||||||
|
|
||||||
def _detect_type(self, file_path, ext):
|
def _detect_type(self, file_path, ext):
|
||||||
"""detect metadata type for file"""
|
"""detect metadata type for file"""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user