From 4e7dedc43c1ceb936b093338363a8c6ff46505c1 Mon Sep 17 00:00:00 2001 From: Jack <5182053+phyzical@users.noreply.github.com> Date: Tue, 10 Oct 2023 10:11:54 +0800 Subject: [PATCH] Exposed subtitle file size through API --- bazarr/api/swaggerui.py | 3 ++- bazarr/api/utils.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bazarr/api/swaggerui.py b/bazarr/api/swaggerui.py index b225f1532..e8eb979a2 100644 --- a/bazarr/api/swaggerui.py +++ b/bazarr/api/swaggerui.py @@ -15,7 +15,8 @@ subtitles_model = { "code3": fields.String(), "path": fields.String(), "forced": fields.Boolean(), - "hi": fields.Boolean() + "hi": fields.Boolean(), + "file_size": fields.Integer() } subtitles_language_model = { diff --git a/bazarr/api/utils.py b/bazarr/api/utils.py index 5f47b40b7..a61d50527 100644 --- a/bazarr/api/utils.py +++ b/bazarr/api/utils.py @@ -62,12 +62,14 @@ def postprocess(item): item['subtitles'] = ast.literal_eval(item['subtitles']) for i, subs in enumerate(item['subtitles']): language = subs[0].split(':') + file_size = subs[2] if len(subs) > 2 else 0 item['subtitles'][i] = {"path": path_replace(subs[1]), "name": language_from_alpha2(language[0]), "code2": language[0], "code3": alpha3_from_alpha2(language[0]), "forced": False, - "hi": False} + "hi": False, + "file_size": file_size} if len(language) > 1: item['subtitles'][i].update( {