Skip to content

Commit ae42872

Browse files
author
arch
committed
update installer
1 parent e632aa2 commit ae42872

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed

contrib/main.lua

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
configFile = ofs.ExtensionDir() .. "/config"
3+
pythonFunscriptGenerator = ofs.ExtensionDir .. "/funscript-editor/funscript-editor.exe"
4+
5+
function funscript_generator()
6+
local tmpFile = ofs.ExtensionDir() .. "/funscript_actions.csv"
7+
local video = player.CurrentVideo()
8+
local script = ofs.Script(ofs.ActiveIdx())
9+
local currentTimeMs = player.CurrentTime() * 1000
10+
11+
print("funscriptGenerator", pythonFunscriptGenerator)
12+
print("tmpFile: ", tmpFile)
13+
print("video: ", video)
14+
print("currentScriptIdx: ", ofs.ActiveIdx())
15+
print("currentTimeMs: ", currentTimeMs)
16+
17+
local next_action = ofs.ClosestActionAfter(script, currentTimeMs)
18+
if next_action and next_action.at < currentTimeMs + 500.0 then
19+
next_action = ofs.ClosestActionAfter(script, next_action.at)
20+
end
21+
22+
if next_action then
23+
print("nextAction: ", next_action.at) -- TODO is this in seconds?
24+
else
25+
print("nextAction: nil")
26+
end
27+
28+
local command = '"'
29+
..pythonFunscriptGenerator
30+
..'" --generator -s '
31+
..( next_action == nil and tostring(currentTimeMs) or tostring(currentTimeMs)..' -e '..tostring(next_action.at) )
32+
..' -i "'
33+
..video
34+
..'" -o "'
35+
..tmpFile
36+
..'"'
37+
38+
39+
print(command)
40+
ofs.SilentCmd(command, false)
41+
42+
local f = io.open(tmpFile)
43+
if not f then
44+
print('lua: funscript generator output file not found')
45+
return
46+
end
47+
48+
script = ofs.Script(ofs.ActiveIdx())
49+
local k = 1
50+
for line in f:lines() do
51+
-- first line is header
52+
if k > 1 then
53+
for at, pos in string.gmatch(line, "(%w+);(%w+)") do
54+
ofs.AddAction(script, at, pos, true)
55+
end
56+
end
57+
k = k + 1
58+
end
59+
f:close()
60+
61+
-- save changes
62+
ofs.Commit(script)
63+
end
64+
65+
66+
67+
function init()
68+
ofs.Bind("funscript_generator", "execute the funcript generator")
69+
end
70+
71+
72+
function update(delta)
73+
74+
end
75+
76+
77+
function gui()
78+
79+
end

contrib/windows_installer.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def download_url(url, output_path):
2424
urllib.request.urlretrieve(url, filename=output_path, reporthook=t.update_to)
2525

2626

27-
# NOTE: this file is currently not working for this installer!
28-
lua_extension_url = "https://raw.githubusercontent.com/michael-mueller-git/Python-Funscript-Editor/main/contrib/OpenFunscripter/extensions/Funscript%20Generator%20Windows/main.lua"
27+
lua_extension_url = "https://raw.githubusercontent.com/michael-mueller-git/Python-Funscript-Editor/main/contrib/main.lua"
2928

3029
if platform.system() != "Windows":
3130
print("ERROR: This installer only work on Windows")
@@ -53,6 +52,13 @@ def download_url(url, output_path):
5352
extension_dir = os.path.join(ofs_extension_dir, "Funscript Generator Windows")
5453
zip_file = os.path.join(extension_dir, "funscript-editor-v" + str(latest) + ".zip")
5554
dest_dir = os.path.join(os.path.dirname(zip_file), "funscript-editor")
55+
version_file = os.path.join(os.path.dirname(zip_file), "funscript-editor", "funscript_editor", "VERSION.txt")
56+
57+
if os.path.exists(version_file):
58+
with open(version_file, 'r') as f:
59+
if str(f.read()).lower() == "v"+str(latest):
60+
print("You have already the latest version installed")
61+
sys.exit()
5662

5763
os.makedirs(os.path.dirname(zip_file), exist_ok = True)
5864
if not os.path.exists(zip_file):

0 commit comments

Comments
 (0)