-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve.py
57 lines (51 loc) · 2.02 KB
/
resolve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
import imp
import os
import json
import config as c
def GetResolve():
scriptModule = None
try:
import fusionscript as scriptModule
except ImportError:
resolvePath = c.getResolvePath()
# Look for an auto importer config path
if resolvePath:
try:
scriptModule = imp.load_dynamic("fusionscript", resolvePath)
except ImportError:
print("[Resolve Importer] Failed to load resolve at config path: " + resolvePath)
pass
if not scriptModule:
# Look for installer based environment variables:
libPath=os.getenv("RESOLVE_SCRIPT_LIB")
if libPath:
try:
scriptModule = imp.load_dynamic("fusionscript", libPath)
except ImportError:
pass
if not scriptModule:
# Look for default install locations:
ext=".so"
if sys.platform.startswith("darwin"):
path = "/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/"
elif sys.platform.startswith("win") or sys.platform.startswith("cygwin"):
ext = ".dll"
path = "C:\\Program Files\\Blackmagic Design\\DaVinci Resolve\\"
elif sys.platform.startswith("linux"):
path = "/opt/resolve/libs/Fusion/"
try:
scriptModule = imp.load_dynamic("fusionscript", path + "fusionscript" + ext)
except ImportError:
pass
if scriptModule:
sys.modules["DaVinciResolveScript"] = scriptModule
import DaVinciResolveScript as bmd
else:
raise ImportError("Could not locate module dependencies")
return bmd.scriptapp("Resolve")
resolve = GetResolve()
projectManager = resolve.GetProjectManager()
project = projectManager.GetCurrentProject()
mediaPool = project.GetMediaPool()
mediaStorage = resolve.GetMediaStorage()