From c8fa53e62fd1c14645c1fd40835d0c67e4ad4853 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Fri, 12 Jul 2024 03:11:30 +0200 Subject: [PATCH] [media.mpv] Fix for media duration if playback_time is not available. --- platypush/plugins/media/mpv/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/media/mpv/__init__.py b/platypush/plugins/media/mpv/__init__.py index 7a6b02aa68..c5ff2aa275 100644 --- a/platypush/plugins/media/mpv/__init__.py +++ b/platypush/plugins/media/mpv/__init__.py @@ -468,10 +468,12 @@ class MediaMpvPlugin(MediaPlugin): 'audio_channels': getattr(self._player, 'audio_channels', None), 'audio_codec': getattr(self._player, 'audio_codec_name', None), 'delay': getattr(self._player, 'delay', None), - 'duration': getattr(self._player, 'playback_time', 0) - + getattr(self._player, 'playtime_remaining', 0) - if getattr(self._player, 'playtime_remaining', None) - else None, + 'duration': ( + (getattr(self._player, 'playback_time', 0) or 0) + + getattr(self._player, 'playtime_remaining', 0) + if getattr(self._player, 'playtime_remaining', None) + else None + ), 'filename': getattr(self._player, 'filename', None), 'file_size': getattr(self._player, 'file_size', None), 'fullscreen': getattr(self._player, 'fs', None),