From c08843f9b52a3071bfbd294a589634ccf9b8c995 Mon Sep 17 00:00:00 2001 From: Frederik Haarslev Date: Wed, 20 Sep 2023 13:16:18 +0200 Subject: [PATCH] Added langcodes --- requirements.txt | 4 ++-- src/mediacatch_s2t/uploader.py | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index 98f668a..3a24750 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -pymediainfo==5.1.0 requests==2.31.0 -rich==12.6.0 \ No newline at end of file +rich==12.6.0 +langcodes=3.3.0 \ No newline at end of file diff --git a/src/mediacatch_s2t/uploader.py b/src/mediacatch_s2t/uploader.py index e8d9934..eefcc27 100644 --- a/src/mediacatch_s2t/uploader.py +++ b/src/mediacatch_s2t/uploader.py @@ -108,22 +108,22 @@ def get_duration(self): """ try: probe = self._ffprobe(self.file) - if probe.return_code: - return 0, probe.error - else: - try: - for stream in probe.json['streams']: - if stream['codec_type'] == 'audio': - return int(float(stream['duration']) * 1000), stream - else: - return 0, "The file doesn't have an audio track" - except Exception: - if 'duration' in probe.json['format']: - return int(float(probe.json['format']['duration']) * 1000), probe.json['format'] - else: - return 0, "Duration couldn't be found for audio track" except OSError as e: return 0, 'FFmpeg not installed (sudo apt install ffmpeg)' + if probe.return_code: + return 0, probe.error + else: + try: + for stream in probe.json['streams']: + if stream['codec_type'] == 'audio': + return int(float(stream['duration']) * 1000), stream + else: + return 0, "The file doesn't have an audio track" + except Exception: + if 'duration' in probe.json['format']: + return int(float(probe.json['format']['duration']) * 1000), probe.json['format'] + else: + return 0, "Duration couldn't be found for audio track" def estimated_result_time(self, audio_length=0): """Estimated processing time in seconds"""