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]
|
[project]
|
||||||
name = "renamer"
|
name = "renamer"
|
||||||
version = "0.6.11"
|
version = "0.6.12"
|
||||||
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"
|
||||||
|
|||||||
@@ -175,12 +175,14 @@ class RenamerApp(App):
|
|||||||
icons = {
|
icons = {
|
||||||
'mkv': '📹', # Video camera for MKV
|
'mkv': '📹', # Video camera for MKV
|
||||||
'mk3d': '🎬', # Clapper board for 3D
|
'mk3d': '🎬', # Clapper board for 3D
|
||||||
'avi': '🎞️', # Film frames for AVI
|
'avi': '💿', # Film frames for AVI
|
||||||
'mp4': '📹', # Video camera
|
'mp4': '📹', # Video camera
|
||||||
'mov': '📹', # Video camera
|
'mov': '📹', # Video camera
|
||||||
'wmv': '📹', # Video camera
|
'wmv': '📀', # Video camera
|
||||||
'webm': '📹', # Video camera
|
'webm': '📹', # Video camera
|
||||||
'm4v': '📹', # Video camera
|
'm4v': '📹', # Video camera
|
||||||
|
'mpg': '📼', # Video camera
|
||||||
|
'mpeg': '📼', # Video camera
|
||||||
}
|
}
|
||||||
|
|
||||||
return icons.get(ext, '📄') # Default to document icon
|
return icons.get(ext, '📄') # Default to document icon
|
||||||
|
|||||||
@@ -206,6 +206,11 @@ class MediaExtractor:
|
|||||||
("Default", "extract_genres"),
|
("Default", "extract_genres"),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
"production_countries": {
|
||||||
|
"sources": [
|
||||||
|
("TMDB", "extract_production_countries"),
|
||||||
|
],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def get(self, key: str, source: str | None = None):
|
def get(self, key: str, source: str | None = None):
|
||||||
|
|||||||
@@ -165,10 +165,14 @@ class TMDBExtractor:
|
|||||||
year = filename_extractor.extract_year()
|
year = filename_extractor.extract_year()
|
||||||
|
|
||||||
if title:
|
if title:
|
||||||
movie_data = self._search_movie_by_title_year(title, year)
|
search_result = self._search_movie_by_title_year(title, year)
|
||||||
if movie_data:
|
if search_result and search_result.get('id'):
|
||||||
self._movie_db_info = movie_data
|
# Fetch full movie details using the ID from search results
|
||||||
return movie_data
|
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
|
self._movie_db_info = None
|
||||||
return None
|
return None
|
||||||
@@ -250,6 +254,13 @@ class TMDBExtractor:
|
|||||||
return ', '.join(genre['name'] for genre in movie_info['genres'])
|
return ', '.join(genre['name'] for genre in movie_info['genres'])
|
||||||
return None
|
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]:
|
def extract_poster_path(self) -> Optional[str]:
|
||||||
"""Extract TMDB poster path"""
|
"""Extract TMDB poster path"""
|
||||||
movie_info = self._get_movie_info()
|
movie_info = self._get_movie_info()
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ class CatalogFormatter:
|
|||||||
if genres:
|
if genres:
|
||||||
lines.append(f"{TextFormatter.bold('Genres:')} {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
|
||||||
poster_image_path = self.extractor.tmdb_extractor.extract_poster_image_path()
|
poster_image_path = self.extractor.tmdb_extractor.extract_poster_image_path()
|
||||||
if poster_image_path:
|
if poster_image_path:
|
||||||
|
|||||||
@@ -293,18 +293,24 @@ class ConversionService:
|
|||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
cmd,
|
cmd,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
check=False # Don't raise on non-zero exit, check file instead
|
||||||
check=True
|
|
||||||
)
|
)
|
||||||
|
|
||||||
success_msg = f"Converted successfully: {avi_path.name} → {output_path.name}"
|
# Check if conversion succeeded by verifying output file exists
|
||||||
logger.info(success_msg)
|
if output_path.exists() and output_path.stat().st_size > 0:
|
||||||
return True, success_msg
|
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 conversion failed: {error_output[-500:]}" # Last 500 chars
|
||||||
error_msg = f"ffmpeg error: {e.stderr}"
|
logger.error(error_msg)
|
||||||
logger.error(error_msg)
|
return False, error_msg
|
||||||
return False, error_msg
|
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
error_msg = "ffmpeg not found. Please install ffmpeg."
|
error_msg = "ffmpeg not found. Please install ffmpeg."
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class MediaPanelView:
|
|||||||
self._props.tmdb_title,
|
self._props.tmdb_title,
|
||||||
self._props.tmdb_original_title,
|
self._props.tmdb_original_title,
|
||||||
self._props.tmdb_year,
|
self._props.tmdb_year,
|
||||||
|
self._props.tmdb_countries,
|
||||||
self._props.tmdb_genres,
|
self._props.tmdb_genres,
|
||||||
self._props.tmdb_database_info,
|
self._props.tmdb_database_info,
|
||||||
self._props.tmdb_url,
|
self._props.tmdb_url,
|
||||||
|
|||||||
@@ -123,6 +123,15 @@ class MediaPanelProperties:
|
|||||||
"""Get TMDB year formatted with label."""
|
"""Get TMDB year formatted with label."""
|
||||||
return self._extractor.get("year", "TMDB")
|
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
|
@property
|
||||||
@text_decorators.blue()
|
@text_decorators.blue()
|
||||||
@conditional_decorators.wrap("Genres: ")
|
@conditional_decorators.wrap("Genres: ")
|
||||||
|
|||||||
Reference in New Issue
Block a user