digidau commited on
Commit
51bccf8
·
verified ·
1 Parent(s): 98291ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -2
app.py CHANGED
@@ -281,6 +281,37 @@ def process(
281
 
282
  preview = json.load(f)
283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  print(
285
  "TOTAL SUBTITLES:",
286
  len(preview)
@@ -316,8 +347,8 @@ def process(
316
  )
317
 
318
  generate_ass(
319
- qvm_json,
320
- subtitle_path,
321
  arabic_font,
322
  arabic_y,
323
  translation_gap,
 
281
 
282
  preview = json.load(f)
283
 
284
+
285
+ if not data:
286
+ raise Exception("No subtitle data")
287
+
288
+ preview_json = (
289
+ "temp/preview_only.json"
290
+ )
291
+
292
+ first = data[0]
293
+
294
+ preview_data = [
295
+ {
296
+ **first,
297
+ "start_time": 0,
298
+ "end_time": 5
299
+ }
300
+ ]
301
+
302
+ with open(
303
+ preview_json,
304
+ "w",
305
+ encoding="utf-8"
306
+ ) as f:
307
+
308
+ json.dump(
309
+ preview_data,
310
+ f,
311
+ ensure_ascii=False,
312
+ indent=2
313
+ )
314
+
315
  print(
316
  "TOTAL SUBTITLES:",
317
  len(preview)
 
347
  )
348
 
349
  generate_ass(
350
+ preview_json,
351
+ preview_ass,
352
  arabic_font,
353
  arabic_y,
354
  translation_gap,