Skip to content

Commit 815d69d

Browse files
author
arch
committed
fix raw data and always save raw data to cache dir
1 parent 8cbc8eb commit 815d69d

3 files changed

Lines changed: 42 additions & 8 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ build-dir
1616
.flatpak-builder
1717
repo
1818
*.flatpak
19+
funscript_editor/cache

funscript_editor/definitions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
###############
1313

1414
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
15+
CACHE_DIR = os.path.join(ROOT_DIR, 'cache')
1516
CONFIG_DIR = os.path.join(ROOT_DIR, 'config')
1617
UI_DIR = os.path.join(ROOT_DIR, 'ui')
1718
ICON_PATH = os.path.join(CONFIG_DIR, 'icon.png')
1819
DOCS_URL = "https://github.com/michael-mueller-git/Python-Funscript-Editor/tree/{tag}/docs/app/docs"
20+
RAW_TRACKING_DATA_CAHCE_FILE = os.path.join(CACHE_DIR, 'raw_tracking_data.json')
21+
22+
os.makedirs(CACHE_DIR, exist_ok=True)
1923

2024
if os.path.exists(os.path.join(ROOT_DIR, '..', 'docs')):
2125
APP_DOCUMENTATION_DIR = os.path.join(ROOT_DIR, '..', 'docs', 'app', 'site')

funscript_editor/ui/funscript_generator_window.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,45 @@ def __cut_completed(self, cut_values):
178178
def __scaling_completed(self, score):
179179
self.score = score
180180
self.__logger.info('scaling completed')
181+
182+
# 1. Now first save the raw tracking data
183+
184+
print("score", score)
185+
for metric in self.funscripts:
186+
for idx, val in enumerate(self.score[metric]):
187+
print("add", idx, val)
188+
self.funscripts[metric].add_action(
189+
round(val),
190+
FFmpegStream.frame_to_millisec(self.get_absolute_framenumber(idx), self.video_info.fps),
191+
True
192+
)
193+
194+
raw_tracking_data_json_output = {
195+
'version': 1,
196+
'actions': {}
197+
}
198+
199+
for key in self.funscripts:
200+
raw_tracking_data_json_output['actions'][key] = []
201+
for item in self.funscripts[key].get_actions():
202+
print("transfere", item)
203+
raw_tracking_data_json_output['actions'][key].append(item)
204+
205+
os.makedirs(definitions.CACHE_DIR, exist_ok=True)
206+
with open(definitions.RAW_TRACKING_DATA_CAHCE_FILE, 'w') as f:
207+
print("dump", raw_tracking_data_json_output)
208+
json.dump(raw_tracking_data_json_output, f)
209+
210+
# 2. Continue with selected user option on raw data
211+
181212
if not self.raw_output:
213+
self.__logger.info("Post Processing Data")
214+
#NOTE: delete the raw data from funscript
215+
for key in self.funscripts:
216+
self.funscripts[key].clear_actions()
182217
self.__next_postprocessing(None, [], [])
183218
else:
184219
self.__logger.info("Raw Output")
185-
for metric in self.funscripts:
186-
for idx, val in enumerate(self.score[metric]):
187-
self.funscripts[metric].add_action(
188-
round(val),
189-
FFmpegStream.frame_to_millisec(self.get_absolute_framenumber(idx), self.video_info.fps)
190-
)
191-
192220
self.__funscript_generated(self.funscripts, "OK", True)
193221

194222

@@ -199,7 +227,8 @@ def __next_postprocessing(self, last_metric, idx_keep, val_keep):
199227
for idx, val in zip(idx_keep, val_keep):
200228
self.funscripts[last_metric].add_action(
201229
round(val),
202-
FFmpegStream.frame_to_millisec(self.get_absolute_framenumber(idx), self.video_info.fps)
230+
FFmpegStream.frame_to_millisec(self.get_absolute_framenumber(idx), self.video_info.fps),
231+
True
203232
)
204233

205234
found_last = last_metric is None

0 commit comments

Comments
 (0)