mirror of
https://github.com/shadoll/moma.git
synced 2026-08-28 03:27:34 +00:00
feat: Add duration extraction and formatting utilities
This commit is contained in:
@@ -28,6 +28,14 @@ class MediaInfoExtractor:
|
||||
return frame_class
|
||||
return 'Unclassified'
|
||||
|
||||
def extract_duration(self) -> float | None:
|
||||
"""Extract duration from media info in seconds"""
|
||||
if self.media_info:
|
||||
for track in self.media_info.tracks:
|
||||
if track.track_type == 'General':
|
||||
return getattr(track, 'duration', 0) / 1000 if getattr(track, 'duration', None) else None
|
||||
return None
|
||||
|
||||
def extract_frame_class(self) -> str | None:
|
||||
"""Extract frame class from media info (480p, 720p, 1080p, etc.)"""
|
||||
if not self.video_tracks:
|
||||
|
||||
@@ -31,14 +31,6 @@ class MetadataExtractor:
|
||||
return getattr(self.info, 'artist', None) or getattr(self.info, 'get', lambda x, default=None: default)('artist', [None])[0] # type: ignore
|
||||
return None
|
||||
|
||||
def extract_all_metadata(self) -> dict:
|
||||
"""Extract all metadata"""
|
||||
return {
|
||||
'title': self.extract_title(),
|
||||
'duration': self.extract_duration(),
|
||||
'artist': self.extract_artist()
|
||||
}
|
||||
|
||||
def extract_meta_type(self) -> str:
|
||||
"""Extract meta type from metadata"""
|
||||
if self.info:
|
||||
|
||||
Reference in New Issue
Block a user