Compare commits

2 Commits

7 changed files with 10 additions and 8 deletions

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

Binary file not shown.

View File

@@ -1,6 +1,6 @@
[project]
name = "renamer"
version = "0.5.5"
version = "0.5.7"
description = "Terminal-based media file renamer and metadata viewer"
readme = "README.md"
requires-python = ">=3.11"

View File

@@ -31,6 +31,8 @@ def cached_method(ttl_seconds: int = 3600) -> Callable:
# Use instance identifier (file_path for extractors)
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)
param_str = json.dumps((args, kwargs), sort_keys=True, default=str)

View File

@@ -5,6 +5,7 @@ from .mediainfo_extractor import MediaInfoExtractor
from .fileinfo_extractor import FileInfoExtractor
from .tmdb_extractor import TMDBExtractor
from .default_extractor import DefaultExtractor
import hashlib
class MediaExtractor:
@@ -13,8 +14,8 @@ class MediaExtractor:
@classmethod
def create(cls, file_path: Path, cache=None, ttl_seconds: int = 21600):
"""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:
cache_key = f"extractor_{file_path}"
cached_obj = cache.get_object(cache_key)
if cached_obj:
print(f"Loaded MediaExtractor object from cache for {file_path.name}")
@@ -25,7 +26,6 @@ class MediaExtractor:
# Cache the object
if cache:
cache_key = f"extractor_{file_path}"
cache.set_object(cache_key, instance, ttl_seconds)
print(f"Cached MediaExtractor object for {file_path.name}")

View File

@@ -179,9 +179,9 @@ Do you want to proceed with renaming?
if event.button.id == "rename":
try:
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
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()
except Exception as e:
# Show error
@@ -229,9 +229,9 @@ Do you want to proceed with renaming?
# Trigger rename
try:
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
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()
except Exception as e:
# Show error

2
uv.lock generated
View File

@@ -342,7 +342,7 @@ wheels = [
[[package]]
name = "renamer"
version = "0.5.5"
version = "0.5.7"
source = { editable = "." }
dependencies = [
{ name = "langcodes" },