diff --git a/bin/ffx/audio_layout.py b/bin/ffx/audio_layout.py index 1552365..7ed761b 100644 --- a/bin/ffx/audio_layout.py +++ b/bin/ffx/audio_layout.py @@ -1,3 +1,4 @@ +import click from enum import Enum from .track_type import TrackType @@ -19,7 +20,7 @@ class AudioLayout(Enum): def index(self): """Returns the layout as string""" - return self.value['layout'] + return self.value['index'] @staticmethod def fromIndex(index : int): @@ -28,7 +29,8 @@ class AudioLayout(Enum): except: return AudioLayout.LAYOUT_UNDEFINED - def identify(self, streamObj): + @staticmethod + def identify(streamObj): FFPROBE_LAYOUT_KEY = 'channel_layout' FFPROBE_CHANNELS_KEY = 'channels' @@ -40,7 +42,7 @@ class AudioLayout(Enum): raise Exception('Not an ffprobe audio stream object') if FFPROBE_LAYOUT_KEY in streamObj.keys(): - matchingLayouts = [l for l in AudioLayout if l.value['layout'] == streamObj[FFPROBE_LAYOUT_KEY]] + matchingLayouts = [l for l in AudioLayout if l.label() == streamObj[FFPROBE_LAYOUT_KEY]] if matchingLayouts: return matchingLayouts[0] diff --git a/bin/ffx/file_properties.py b/bin/ffx/file_properties.py index e1b0b12..35bb811 100644 --- a/bin/ffx/file_properties.py +++ b/bin/ffx/file_properties.py @@ -191,7 +191,7 @@ class FileProperties(): def getMediaDescriptor(self): - return MediaDescriptor.fromFfprobe(self.getFormatData(), self.getStreamData(), context = self.context) + return MediaDescriptor.fromFfprobe(self.getFormatData(), self.getStreamData()) def getShowId(self) -> int: diff --git a/bin/ffx/media_descriptor.py b/bin/ffx/media_descriptor.py index 36d2806..dfd3d58 100644 --- a/bin/ffx/media_descriptor.py +++ b/bin/ffx/media_descriptor.py @@ -109,7 +109,7 @@ class MediaDescriptor(): @classmethod - def fromFfprobe(cls, formatData, streamData, context : dict = None): + def fromFfprobe(cls, formatData, streamData): kwargs = {} diff --git a/bin/ffx/media_details_screen.py b/bin/ffx/media_details_screen.py index 81e7e1f..3e41d60 100644 --- a/bin/ffx/media_details_screen.py +++ b/bin/ffx/media_details_screen.py @@ -296,7 +296,7 @@ class MediaDetailsScreen(Screen): row = (td.getIndex(), trackType.label(), typeCounter[trackType], - " ", + td.getAudioLayout().label() if trackType == TrackType.AUDIO else ' ', td.getLanguage().label(), td.getTitle(), 'Yes' if TrackDisposition.DEFAULT in dispoSet else 'No', diff --git a/bin/ffx/pattern_details_screen.py b/bin/ffx/pattern_details_screen.py index 8e143ec..8503893 100644 --- a/bin/ffx/pattern_details_screen.py +++ b/bin/ffx/pattern_details_screen.py @@ -138,7 +138,7 @@ class PatternDetailsScreen(Screen): row = (td.getIndex(), trackType.label(), typeCounter[trackType], - td.getAudioLayout().label(), + td.getAudioLayout().label() if trackType == TrackType.AUDIO else ' ', td.getLanguage().label(), td.getTitle(), 'Yes' if TrackDisposition.DEFAULT in dispoSet else 'No', diff --git a/bin/ffx/track_controller.py b/bin/ffx/track_controller.py index 1df585e..6b90f8f 100644 --- a/bin/ffx/track_controller.py +++ b/bin/ffx/track_controller.py @@ -32,7 +32,8 @@ class TrackController(): track_type = int(trackDescriptor.getType().index()), index = int(trackDescriptor.getIndex()), source_index = int(trackDescriptor.getSourceIndex()), - disposition_flags = int(TrackDisposition.toFlags(trackDescriptor.getDispositionSet()))) + disposition_flags = int(TrackDisposition.toFlags(trackDescriptor.getDispositionSet())), + audio_layout = trackDescriptor.getAudioLayout().index()) s.add(track) s.commit() diff --git a/bin/ffx/track_descriptor.py b/bin/ffx/track_descriptor.py index fe54878..ef375b9 100644 --- a/bin/ffx/track_descriptor.py +++ b/bin/ffx/track_descriptor.py @@ -1,3 +1,5 @@ +import click + from .iso_language import IsoLanguage from .track_type import TrackType from .audio_layout import AudioLayout @@ -150,7 +152,7 @@ class TrackDescriptor(): kwargs[TrackDescriptor.DISPOSITION_SET_KEY] = {t for d in (k for (k,v) in streamObj[TrackDescriptor.FFPROBE_DISPOSITION_KEY].items() if v) if (t := TrackDisposition.find(d)) if t is not None} if TrackDescriptor.FFPROBE_DISPOSITION_KEY in streamObj.keys() else set() kwargs[TrackDescriptor.TAGS_KEY] = streamObj[TrackDescriptor.FFPROBE_TAGS_KEY] if TrackDescriptor.FFPROBE_TAGS_KEY in streamObj.keys() else {} - kwargs[TrackDescriptor.AUDIO_LAYOUT_KEY] = AudioLayout.identify(streamObj) if trackType == TrackType.AUDIO.label() else AudioLayout.LAYOUT_UNDEFINED + kwargs[TrackDescriptor.AUDIO_LAYOUT_KEY] = AudioLayout.identify(streamObj) if trackType == TrackType.AUDIO else AudioLayout.LAYOUT_UNDEFINED return cls(**kwargs) else: