fix update session

This commit is contained in:
2025-08-29 01:02:13 -07:00
parent 4cacc648a8
commit f4a2c6012f

View File

@@ -42,6 +42,9 @@ local session_start_time = nil
local video_info = {}
local is_tracking = false
-- Forward declaration for update_session_progress
local update_session_progress
-- Utility functions
local function log(message)
if options.enable_debug_logging then
@@ -200,10 +203,7 @@ local function save_session_to_csv()
tonumber(current_session.duration) or 0,
current_session.start_timestamp or "",
current_session.end_timestamp or current_session.start_timestamp or "",
tonumber(current_session.total_watch_time)
or (
get_current_timestamp and session_start_time and (get_current_timestamp() - session_start_time) or 0
),
tonumber(current_session.total_watch_time) or (get_current_timestamp() and session_start_time and (get_current_timestamp() - session_start_time) or 0),
tonumber(current_session.watch_progress) or 0,
current_session.video_format or "",
current_session.audio_format or "",
@@ -325,6 +325,9 @@ local function end_current_session()
return
end
-- Ensure the latest playback position is saved
update_session_progress()
local end_time = get_current_timestamp()
current_session.end_time = end_time
current_session.end_timestamp = format_timestamp(end_time)
@@ -426,7 +429,7 @@ local function start_new_session()
end
end
local function update_session_progress()
update_session_progress = function()
if not current_session or not is_tracking then
return
end