Skip to content

Commit 32d4c74

Browse files
committed
Adding @emojis path replacement, when saving and loading *.osp files. This allows them to be cross-platform paths, and relative/magic paths for OpenShot which always work.
1 parent ad02c73 commit 32d4c74

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/classes/json_data.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def replace_string_to_absolute(self, match):
225225
new_path = json.dumps(new_path, ensure_ascii=False)
226226
return '"%s": %s' % (key, new_path)
227227

228+
elif "@emojis" in path:
229+
new_path = path.replace("@emojis", os.path.join(info.PATH, "emojis", "color", "svg"))
230+
new_path = json.dumps(new_path, ensure_ascii=False)
231+
return '"%s": %s' % (key, new_path)
232+
228233
elif "@assets" in path:
229234
new_path = path.replace("@assets", path_context["new_project_assets"])
230235
new_path = json.dumps(new_path, ensure_ascii=False)
@@ -268,20 +273,28 @@ def replace_string_to_relative(self, match):
268273

269274
# Determine if @transitions path is found
270275
elif os.path.join(info.PATH, "transitions") in folder_path:
271-
# Yes, this is an OpenShot transitions
276+
# Yes, this is an OpenShot transition
272277
folder_path, category_path = os.path.split(folder_path)
273278

274279
# Convert path to @transitions/ path
275280
new_path = os.path.join("@transitions", category_path, file_path).replace("\\", "/")
276281
new_path = json.dumps(new_path, ensure_ascii=False)
277282
return '"%s": %s' % (key, new_path)
278283

284+
# Determine if @emojis path is found
285+
elif os.path.join(info.PATH, "emojis") in folder_path:
286+
# Yes, this is an OpenShot emoji
287+
# Convert path to @emojis/ path
288+
new_path = os.path.join("@emojis", file_path).replace("\\", "/")
289+
new_path = json.dumps(new_path, ensure_ascii=False)
290+
return '"%s": %s' % (key, new_path)
291+
279292
# Determine if @assets path is found
280293
elif path_context["new_project_assets"] in folder_path:
281294
# Yes, this is an OpenShot transitions
282295
folder_path = folder_path.replace(path_context["new_project_assets"], "@assets")
283296

284-
# Convert path to @transitions/ path
297+
# Convert path to @assets/ path
285298
new_path = os.path.join(folder_path, file_path).replace("\\", "/")
286299
new_path = json.dumps(new_path, ensure_ascii=False)
287300
return '"%s": %s' % (key, new_path)

0 commit comments

Comments
 (0)