diff --git a/bin/ffx.py b/bin/ffx.py index 25c2c21..96a7d06 100755 --- a/bin/ffx.py +++ b/bin/ffx.py @@ -251,24 +251,23 @@ def help(): @click.argument('filename', nargs=1) def inspect(ctx, filename): -# if 'database' not in ctx.obj.keys(): -# ctx.obj['database'] = databaseContext() - - try: + fp = FileProperties(ctx.obj, filename) + md = fp.getMediaDescriptor() + + click.echo('\nFile properties:\n') + + click.echo(md.getTags()) - fp = FileProperties(ctx.obj, filename) - md = fp.getMediaDescriptor() + for at in md.getAudioTracks(): + click.echo(f"Audio: {at.getLanguage()} {'|'.join([f"{k}={v}" for (k,v) in at.getTags().items()])}") - print(md.getTags()) + for st in md.getSubtitleTracks(): + click.echo(f"Subtitle: {st.getLanguage()} {'|'.join([f"{k}={v}" for (k,v) in st.getTags().items()])}") - for at in md.getAudioTracks(): - print(f"Audio: {at.getLanguage()} {'|'.join([f"{k}={v}" for (k,v) in at.getTags().items()])}") - for st in md.getSubtitleTracks(): - print(f"Subtitle: {st.getLanguage()} {'|'.join([[f"{k}={v}" for (k,v) in st.getTags().items()]])}") + click.echo('\nRecognized pattern:\n') - except Exception as ex: - raise click.ClickException(f"This file does not contain any audiovisual data: {ex}") + click.echo(f"Show Id: {fp.getShowId()}") # for d in sd: # click.echo(f"{d['codec_name']}{' (' + str(d['channels']) + ')' if d['codec_type'] == 'audio' else ''}") diff --git a/bin/ffx/file_properties.py b/bin/ffx/file_properties.py index 9df38d2..b44fe9b 100644 --- a/bin/ffx/file_properties.py +++ b/bin/ffx/file_properties.py @@ -5,6 +5,8 @@ from .pattern_controller import PatternController from .process import executeProcess +from ffx.model.pattern import Pattern + class FileProperties(): @@ -51,10 +53,12 @@ class FileProperties(): file_index += 1 - pc = PatternController(context) - pattern = pc.matchFilename(self.__sourceFilename) + self.__pc = PatternController(context) + + self.__pattern = self.__pc.matchFilename(self.__sourceFilename) + - click.echo(pattern) + # click.echo(pattern) # matchingFileSubtitleDescriptors = sorted([d for d in availableFileSubtitleDescriptors if d['season'] == season and d['episode'] == episode], key=lambda d: d['stream']) if availableFileSubtitleDescriptors else [] # # print(f"season={season} episode={episode} file={file_index}") @@ -213,3 +217,9 @@ class FileProperties(): # formatData = self.getFormatData() # streamData = self.getStreamData() + + + def getShowId(self) -> int: + return self.__pattern.getShowId() if self.__pattern is not None else -1 + + \ No newline at end of file diff --git a/bin/ffx/pattern_controller.py b/bin/ffx/pattern_controller.py index 9446678..3dc74ba 100644 --- a/bin/ffx/pattern_controller.py +++ b/bin/ffx/pattern_controller.py @@ -116,7 +116,7 @@ class PatternController(): s.close() - def matchFilename(self, filename): + def matchFilename(self, filename) -> Pattern: try: s = self.Session()