Skip to content

Commit

Permalink
Added langcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederik Haarslev committed Sep 20, 2023
1 parent 45f90a0 commit c08843f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pymediainfo==5.1.0
requests==2.31.0
rich==12.6.0
rich==12.6.0
langcodes=3.3.0
28 changes: 14 additions & 14 deletions src/mediacatch_s2t/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit c08843f

Please sign in to comment.