fix convert error, improoved tmdb data retrive

This commit is contained in:
sHa
2026-01-03 19:19:47 +00:00
parent 24f31166d3
commit 390e8e8f83
10 changed files with 57 additions and 18 deletions

BIN
dist/renamer-0.6.12-py3-none-any.whl vendored Normal file

Binary file not shown.

View File

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

View File

@@ -175,12 +175,14 @@ class RenamerApp(App):
icons = {
'mkv': '📹', # Video camera for MKV
'mk3d': '🎬', # Clapper board for 3D
'avi': '🎞️', # Film frames for AVI
'avi': '💿', # Film frames for AVI
'mp4': '📹', # Video camera
'mov': '📹', # Video camera
'wmv': '📹', # Video camera
'wmv': '📀', # Video camera
'webm': '📹', # Video camera
'm4v': '📹', # Video camera
'mpg': '📼', # Video camera
'mpeg': '📼', # Video camera
}
return icons.get(ext, '📄') # Default to document icon

View File

@@ -206,6 +206,11 @@ class MediaExtractor:
("Default", "extract_genres"),
],
},
"production_countries": {
"sources": [
("TMDB", "extract_production_countries"),
],
},
}
def get(self, key: str, source: str | None = None):

View File

@@ -165,10 +165,14 @@ class TMDBExtractor:
year = filename_extractor.extract_year()
if title:
movie_data = self._search_movie_by_title_year(title, year)
if movie_data:
self._movie_db_info = movie_data
return movie_data
search_result = self._search_movie_by_title_year(title, year)
if search_result and search_result.get('id'):
# Fetch full movie details using the ID from search results
movie_id = search_result['id']
movie_data = self._get_movie_details(movie_id)
if movie_data:
self._movie_db_info = movie_data
return movie_data
self._movie_db_info = None
return None
@@ -250,6 +254,13 @@ class TMDBExtractor:
return ', '.join(genre['name'] for genre in movie_info['genres'])
return None
def extract_production_countries(self) -> Optional[str]:
"""Extract TMDB production countries"""
movie_info = self._get_movie_info()
if movie_info and movie_info.get('production_countries'):
return ', '.join(country['name'] for country in movie_info['production_countries'])
return None
def extract_poster_path(self) -> Optional[str]:
"""Extract TMDB poster path"""
movie_info = self._get_movie_info()

View File

@@ -49,6 +49,11 @@ class CatalogFormatter:
if genres:
lines.append(f"{TextFormatter.bold('Genres:')} {genres}")
# Countries
countries = self.extractor.get("production_countries", "TMDB")
if countries:
lines.append(f"{TextFormatter.bold('Countries:')} {countries}")
# Poster
poster_image_path = self.extractor.tmdb_extractor.extract_poster_image_path()
if poster_image_path:

View File

@@ -293,18 +293,24 @@ class ConversionService:
result = subprocess.run(
cmd,
capture_output=True,
text=True,
check=True
check=False # Don't raise on non-zero exit, check file instead
)
success_msg = f"Converted successfully: {avi_path.name}{output_path.name}"
logger.info(success_msg)
return True, success_msg
# Check if conversion succeeded by verifying output file exists
if output_path.exists() and output_path.stat().st_size > 0:
success_msg = f"Converted successfully: {avi_path.name}{output_path.name}"
logger.info(success_msg)
return True, success_msg
else:
# Try to decode stderr for error message
try:
error_output = result.stderr.decode('utf-8', errors='replace')
except Exception:
error_output = "Unknown error (could not decode ffmpeg output)"
except subprocess.CalledProcessError as e:
error_msg = f"ffmpeg error: {e.stderr}"
logger.error(error_msg)
return False, error_msg
error_msg = f"ffmpeg conversion failed: {error_output[-500:]}" # Last 500 chars
logger.error(error_msg)
return False, error_msg
except FileNotFoundError:
error_msg = "ffmpeg not found. Please install ffmpeg."

View File

@@ -71,6 +71,7 @@ class MediaPanelView:
self._props.tmdb_title,
self._props.tmdb_original_title,
self._props.tmdb_year,
self._props.tmdb_countries,
self._props.tmdb_genres,
self._props.tmdb_database_info,
self._props.tmdb_url,

View File

@@ -123,6 +123,15 @@ class MediaPanelProperties:
"""Get TMDB year formatted with label."""
return self._extractor.get("year", "TMDB")
@property
@text_decorators.blue()
@conditional_decorators.wrap("Countries: ")
@text_decorators.yellow()
@conditional_decorators.default("<None>")
def tmdb_countries(self) -> str:
"""Get TMDB production countries formatted with label."""
return self._extractor.get("production_countries", "TMDB")
@property
@text_decorators.blue()
@conditional_decorators.wrap("Genres: ")

2
uv.lock generated
View File

@@ -462,7 +462,7 @@ wheels = [
[[package]]
name = "renamer"
version = "0.6.11"
version = "0.6.12"
source = { editable = "." }
dependencies = [
{ name = "langcodes" },