Exposed subtitle file size through API

This commit is contained in:
Jack 2023-10-10 10:11:54 +08:00 committed by GitHub
parent 33af93a341
commit 4e7dedc43c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -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 = {

View File

@ -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(
{