From 68b8cb72448dd8177000169a159d0cbd7af96c29 Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Sun, 2 Jul 2023 16:32:45 +0300 Subject: [PATCH] check resolution for HLS --- files/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/files/models.py b/files/models.py index c0bd95f..0d57266 100644 --- a/files/models.py +++ b/files/models.py @@ -816,6 +816,7 @@ class Media(models.Model): """ res = {} + valid_resolutions = [240, 360, 480, 720, 1080, 1440, 2160] if self.hls_file: if os.path.exists(self.hls_file): hls_file = self.hls_file @@ -827,11 +828,20 @@ class Media(models.Model): uri = os.path.join(p, iframe_playlist.uri) if os.path.exists(uri): resolution = iframe_playlist.iframe_stream_info.resolution[1] + # most probably video is vertical, getting the first value to + # be the resolution + if resolution not in valid_resolutions: + resolution = iframe_playlist.iframe_stream_info.resolution[0] + res["{}_iframe".format(resolution)] = helpers.url_from_path(uri) for playlist in m3u8_obj.playlists: uri = os.path.join(p, playlist.uri) if os.path.exists(uri): resolution = playlist.stream_info.resolution[1] + # same as above + if resolution not in valid_resolutions: + resolution = playlist.stream_info.resolution[0] + res["{}_playlist".format(resolution)] = helpers.url_from_path(uri) return res