Compare commits
2 Commits
main
...
mediacatal
| Author | SHA1 | Date | |
|---|---|---|---|
| 67cf6a0c8b | |||
| dff245c37f |
BIN
dist/renamer-0.5.6-py3-none-any.whl
vendored
Normal file
BIN
dist/renamer-0.5.6-py3-none-any.whl
vendored
Normal file
Binary file not shown.
BIN
dist/renamer-0.5.7-py3-none-any.whl
vendored
Normal file
BIN
dist/renamer-0.5.7-py3-none-any.whl
vendored
Normal file
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "renamer"
|
name = "renamer"
|
||||||
version = "0.5.5"
|
version = "0.5.7"
|
||||||
description = "Terminal-based media file renamer and metadata viewer"
|
description = "Terminal-based media file renamer and metadata viewer"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ def cached_method(ttl_seconds: int = 3600) -> Callable:
|
|||||||
|
|
||||||
# Use instance identifier (file_path for extractors)
|
# Use instance identifier (file_path for extractors)
|
||||||
instance_id = getattr(self, 'file_path', str(id(self)))
|
instance_id = getattr(self, 'file_path', str(id(self)))
|
||||||
|
if isinstance(instance_id, Path):
|
||||||
|
instance_id = hashlib.md5(str(instance_id).encode('utf-8')).hexdigest()
|
||||||
|
|
||||||
# Create hash from args and kwargs (excluding self)
|
# Create hash from args and kwargs (excluding self)
|
||||||
param_str = json.dumps((args, kwargs), sort_keys=True, default=str)
|
param_str = json.dumps((args, kwargs), sort_keys=True, default=str)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from .mediainfo_extractor import MediaInfoExtractor
|
|||||||
from .fileinfo_extractor import FileInfoExtractor
|
from .fileinfo_extractor import FileInfoExtractor
|
||||||
from .tmdb_extractor import TMDBExtractor
|
from .tmdb_extractor import TMDBExtractor
|
||||||
from .default_extractor import DefaultExtractor
|
from .default_extractor import DefaultExtractor
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
class MediaExtractor:
|
class MediaExtractor:
|
||||||
@@ -13,8 +14,8 @@ class MediaExtractor:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, file_path: Path, cache=None, ttl_seconds: int = 21600):
|
def create(cls, file_path: Path, cache=None, ttl_seconds: int = 21600):
|
||||||
"""Factory method that returns cached object if available, else creates new."""
|
"""Factory method that returns cached object if available, else creates new."""
|
||||||
|
cache_key = f"extractor_{hashlib.md5(str(file_path).encode('utf-8')).hexdigest()}"
|
||||||
if cache:
|
if cache:
|
||||||
cache_key = f"extractor_{file_path}"
|
|
||||||
cached_obj = cache.get_object(cache_key)
|
cached_obj = cache.get_object(cache_key)
|
||||||
if cached_obj:
|
if cached_obj:
|
||||||
print(f"Loaded MediaExtractor object from cache for {file_path.name}")
|
print(f"Loaded MediaExtractor object from cache for {file_path.name}")
|
||||||
@@ -25,7 +26,6 @@ class MediaExtractor:
|
|||||||
|
|
||||||
# Cache the object
|
# Cache the object
|
||||||
if cache:
|
if cache:
|
||||||
cache_key = f"extractor_{file_path}"
|
|
||||||
cache.set_object(cache_key, instance, ttl_seconds)
|
cache.set_object(cache_key, instance, ttl_seconds)
|
||||||
print(f"Cached MediaExtractor object for {file_path.name}")
|
print(f"Cached MediaExtractor object for {file_path.name}")
|
||||||
|
|
||||||
|
|||||||
@@ -179,9 +179,9 @@ Do you want to proceed with renaming?
|
|||||||
if event.button.id == "rename":
|
if event.button.id == "rename":
|
||||||
try:
|
try:
|
||||||
logging.info(f"Renaming {self.old_path} to {self.new_path}")
|
logging.info(f"Renaming {self.old_path} to {self.new_path}")
|
||||||
self.old_path.rename(self.new_path)
|
self.old_path.rename(self.old_path.with_name(self.new_path)) # type: ignore
|
||||||
# Update the tree node
|
# Update the tree node
|
||||||
self.app.update_renamed_file(self.old_path, self.new_path) # type: ignore
|
self.app.update_renamed_file(self.old_path, self.old_path.with_name(self.new_path)) # type: ignore
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Show error
|
# Show error
|
||||||
@@ -229,9 +229,9 @@ Do you want to proceed with renaming?
|
|||||||
# Trigger rename
|
# Trigger rename
|
||||||
try:
|
try:
|
||||||
logging.info(f"Hotkey renaming {self.old_path} to {self.new_path}")
|
logging.info(f"Hotkey renaming {self.old_path} to {self.new_path}")
|
||||||
self.old_path.rename(self.new_path)
|
self.old_path.rename(self.old_path.with_name(self.new_path)) # type: ignore
|
||||||
# Update the tree node
|
# Update the tree node
|
||||||
self.app.update_renamed_file(self.old_path, self.new_path) # type: ignore
|
self.app.update_renamed_file(self.old_path, self.old_path.with_name(self.new_path)) # type: ignore
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Show error
|
# Show error
|
||||||
|
|||||||
Reference in New Issue
Block a user