Skip to content

Commit fa0caff

Browse files
author
arch
committed
add ubuntu example integration for OFS
1 parent 4a41e5d commit fa0caff

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Settings = {}
2+
Settings.PythonScript = "/home/ubuntu/Repos/Python-Funscript-Editor/funscript-editor.py"
3+
Settings.TmpFile = "/tmp/funscript_actions.csv"
4+
Settings.CondaEnvName = "funscript-editor"
5+
SetSettings(Settings)
6+
7+
-- Version: 1.4.0
8+
-- Note: I have not thest this script!
9+
function GetActions(video)
10+
local at = {}
11+
local pos = {}
12+
local next_action = CurrentScript:GetClosestActionAfter(CurrentTimeMs)
13+
if next_action and next_action.at < CurrentTimeMs + 500.0 then
14+
next_action = CurrentScript:GetClosestActionAfter(next_action.at)
15+
end
16+
local command = 'bash -i -c \'conda activate '..Settings.CondaEnvName..'; python3 "'..Settings.PythonScript..'" --generator -s '..(next_action == nil and tostring(CurrentTimeMs) or tostring(CurrentTimeMs)..' -e '..tostring(next_action.at))..' -i "'..video..'" -o "'..Settings.TmpFile..'"\''
17+
print(command)
18+
os.execute(command)
19+
local f = io.open(Settings.TmpFile)
20+
if not f then
21+
print('lua: funscript generator output file not found')
22+
return at, pos
23+
end
24+
local k = 1
25+
for line in f:lines() do
26+
-- first line is header
27+
if k > 1 then
28+
for k, v in string.gmatch(line, "(%w+);(%w+)") do
29+
at[#at+1] = k
30+
pos[#pos+1] = v
31+
end
32+
end
33+
k = k + 1
34+
end
35+
f:close()
36+
return at, pos
37+
end
38+
39+
print('start funscript generator')
40+
local video = VideoFilePath -- NOTE: do not use special character in the video path!
41+
print('video file: ', video)
42+
local actions = {GetActions(video)}
43+
for i = 1, #actions[1] do
44+
CurrentScript:AddActionUnordered(tonumber(actions[1][i]), tonumber(actions[2][i]), true, 0)
45+
end
46+
print('done')

0 commit comments

Comments
 (0)