Skip to content

Commit 326907e

Browse files
author
arch
committed
improve ofs intigration instructions
1 parent d535ec4 commit 326907e

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

contrib/OpenFunscripter/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ A hacky lua script to use the python funscript generator script in Open Funscrip
44

55
## Installation
66

7-
1. Download the packed Python Funscript Editor from [github release page](https://github.com/michael-mueller-git/Python-Funscript-Editor/releases).
8-
2. Extract the Archiv.
7+
1. Download the latest packed Python Funscript Editor from [github release page](https://github.com/michael-mueller-git/Python-Funscript-Editor/releases).
8+
2. Extract the Archiv to an Path without special character or spaces.
99
3. Copy the `funscript_generator.lua` script to `data/lua` in your OFS directory.
1010
4. Open the `funscript_generator.lua` file and adjust the `Settings.FunscriptGenerator` and `Settings.TmpFile` variable.
11-
5. Launch OFS.
11+
- `Settings.FunscriptGenerator`: point to the extracted Python Funscript Editor program
12+
- `Settings.TmpFile`: specifies a temporary file where to store the result (must be a file not a directory!). The file will be overwritten automatically the next time the generator is started!
13+
5. Now launch OFS.
1214
6. Navigate to `View : Special functions : Custom Functions` and select the `funscript_generator.lua` entry. Click the Button `Bind Script` (This may trigger the funscript generator, just ignore it for now).
1315
7. Navigate to `Options : Keys : Dynamic` and insert a shortcut for the funscript generator.
16+
8. Now you can use the shortcut at any position in the video to start the funscript generator.

contrib/OpenFunscripter/funscript_generator.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Settings = {}
22
Settings.FunscriptGenerator = "C:\\Users\\win10\\Desktop\\funscript-editor\\funscript-editor.exe"
3-
Settings.TmpFile = "C:\\Users\\win10\\AppData\\Local\\Temp\\funscript_actions.csv"
3+
Settings.TmpFile = "C:\\Users\\win10\\AppData\\Local\\Temp\\funscript_actions.csv" -- file where to temporary store the result (must be a file not a directory!)
44
SetSettings(Settings)
55

66
function GetActions(video)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Settings = {}
2+
Settings.PythonScript = "/home/arch/repos/python-funscript-editor/funscript-editor.py"
3+
Settings.TmpFile = "/tmp/funscript_actions.csv"
4+
SetSettings(Settings)
5+
6+
function GetActions(video)
7+
local at = {}
8+
local pos = {}
9+
local command = 'python3 "'..Settings.PythonScript..'" --generator -s '..tostring(CurrentTimeMs)..' -i "'..video..'" -o "'..Settings.TmpFile..'"'
10+
print(command)
11+
os.execute(command)
12+
local f = io.open(Settings.TmpFile)
13+
if not f then
14+
print('lua: funscript generator output file not found')
15+
return at, pos
16+
end
17+
local k = 1
18+
for line in f:lines() do
19+
-- first line is header
20+
if k > 1 then
21+
for k, v in string.gmatch(line, "(%w+);(%w+)") do
22+
at[#at+1] = k
23+
pos[#pos+1] = v
24+
end
25+
end
26+
k = k + 1
27+
end
28+
f:close()
29+
return at, pos
30+
end
31+
32+
print('start funscript generator')
33+
local video = VideoFilePath -- NOTE: do not use special character in the video path!
34+
print('video file: ', video)
35+
local actions = {GetActions(video)}
36+
for i = 1, #actions[1] do
37+
CurrentScript:AddActionUnordered(tonumber(actions[1][i]), tonumber(actions[2][i]), true, 0)
38+
end
39+
print('done')

funscript_editor/ui/minimal.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class MinimalFunscriptGenerator(QtWidgets.QMainWindow):
2525
def __init__(self, video_file, start_time, output_file):
2626
super(MinimalFunscriptGenerator, self).__init__()
2727

28+
if os.path.isdir(output_file):
29+
self.__logger.error("The output TempFile path must be a file not a folder")
30+
self.__show_message("The output TempFile path must be a file not a folder")
31+
sys.exit()
32+
2833
if os.path.exists(output_file):
2934
os.remove(output_file)
3035

@@ -43,13 +48,12 @@ def __init__(self, video_file, start_time, output_file):
4348
logging.info('abort')
4449
sys.exit()
4550

46-
if video_file is None:
51+
if video_file is None or video_file == "":
4752
self.__logger.error("Video file was not specified!")
4853
self.__show_message("Video file was not specified!")
4954
sys.exit()
5055

5156
if not os.path.exists(video_file):
52-
if video_file == "": video_file = "EMPTY"
5357
self.__logger.error("Video file not found: %s", video_file)
5458
self.__show_message("Video file not found ({})".format(video_file))
5559
sys.exit()

0 commit comments

Comments
 (0)