fix convert error, improoved tmdb data retrive
This commit is contained in:
BIN
dist/renamer-0.6.12-py3-none-any.whl
vendored
Normal file
BIN
dist/renamer-0.6.12-py3-none-any.whl
vendored
Normal file
Binary file not shown.
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -165,7 +165,11 @@ class TMDBExtractor:
|
||||
year = filename_extractor.extract_year()
|
||||
|
||||
if title:
|
||||
movie_data = self._search_movie_by_title_year(title, year)
|
||||
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
|
||||
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -293,16 +293,22 @@ 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
|
||||
)
|
||||
|
||||
# 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}"
|
||||
error_msg = f"ffmpeg conversion failed: {error_output[-500:]}" # Last 500 chars
|
||||
logger.error(error_msg)
|
||||
return False, error_msg
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: ")
|
||||
|
||||
Reference in New Issue
Block a user