@@ -346,6 +346,7 @@ def load(self, file_path, clear_thumbnails=True):
346
346
default_project = self ._data
347
347
348
348
try :
349
+ self .quote_json_keys (file_path )
349
350
# Attempt to load v2.X project file
350
351
project_data = self .read_from_file (file_path , path_mode = "absolute" )
351
352
@@ -647,7 +648,7 @@ def read_legacy_project_file(self, file_path):
647
648
# Increment track counter
648
649
track_counter += 1
649
650
650
- except Exception :
651
+ except Exception as ex :
651
652
# Error parsing legacy contents
652
653
msg = "Failed to load legacy project file %(path)s" % {"path" : file_path }
653
654
log .error (msg , exc_info = 1 )
@@ -720,6 +721,21 @@ def upgrade_project_data_structures(self):
720
721
if self ._data .get ("id" ) == "T0" :
721
722
self ._data ["id" ] = self .generate_id ()
722
723
724
+ # Ensure projects can open
725
+ # after PR #4211 introduced a bug
726
+ # which wrote certain projects with invalid JSON.
727
+ def quote_json_keys (self , file_path ):
728
+ import re
729
+
730
+ f = open (file_path )
731
+ txt = f .read ()
732
+ f .close ()
733
+ newText = re .sub ('(\n \s*)(\w*):' , r'\1"\2":' , txt )
734
+ f = open (file_path , 'w' )
735
+ f .write (newText )
736
+ f .close ()
737
+ return
738
+
723
739
def save (self , file_path , move_temp_files = True , make_paths_relative = True ):
724
740
""" Save project file to disk """
725
741
import openshot
0 commit comments