@@ -100,38 +100,44 @@ def __init__(self,
100100
101101 def continue_with_tracking_result (self ):
102102 self .__logger .info ("Use previous tracking result" )
103- if not os .path .exists (definitions .RAW_TRACKING_DATA_CAHCE_FILE ):
104- self .__show_message ("Tracking result not found" )
105- sys .exit ()
103+ try :
104+ if not os .path .exists (definitions .RAW_TRACKING_DATA_CAHCE_FILE ):
105+ self .__show_message ("Tracking result not found" )
106+ sys .exit ()
106107
107- with open (definitions .RAW_TRACKING_DATA_CAHCE_FILE , 'r' ) as fd :
108- cache_content = json .load (fd )
108+ with open (definitions .RAW_TRACKING_DATA_CAHCE_FILE , 'r' ) as fd :
109+ cache_content = json .load (fd )
109110
110- if any (x not in cache_content for x in ["videoFile" , "fps" , "actions" ]):
111- self .__show_message ("Invalid tracking result cache file" )
112- sys .exit ()
113-
114- current_video_filename = os .path .basename (self .video_file )
115- if cache_content ["videoFile" ] != current_video_filename :
116- self .__show_message (f"tracking result for { current_video_filename } not found" )
117- sys .exit ()
111+ if any (x not in cache_content for x in ["videoFile" , "fps" , "actions" ]):
112+ self .__show_message ("Invalid tracking result cache file" )
113+ sys .exit ()
118114
119- if cache_content ["fps" ] != self .video_info .fps :
120- self .__show_message (f"Video propberies has changed" )
121- sys .exit ()
115+ current_video_filename = os .path .basename (self .video_file )
116+ if cache_content ["videoFile" ] != current_video_filename :
117+ self .__show_message (f"tracking result for { current_video_filename } not found" )
118+ sys .exit ()
122119
123- self .funscripts = {metric : Funscript (self .video_info .fps ) \
124- for metric in cache_content ["actions" ]}
120+ if cache_content ["fps" ] != self .video_info .fps :
121+ self .__show_message (f"Video propberies has changed" )
122+ sys .exit ()
125123
126- self .score = {metric : [ \
127- item ["pos" ] \
128- for item in cache_content ["actions" ][metric ] \
129- ] \
130- for metric in cache_content ["actions" ] }
124+ self .funscripts = {metric : Funscript (self .video_info .fps ) \
125+ for metric in cache_content ["actions" ]}
126+
127+ self .score = {metric : [ \
128+ item ["pos" ] \
129+ for item in cache_content ["actions" ][metric ] \
130+ ] \
131+ for metric in cache_content ["actions" ] }
132+
133+ start_time = min ([cache_content ["actions" ][metric ][0 ]["at" ] for metric in cache_content ["actions" ]])
134+ self .start_frame = FFmpegStream .millisec_to_frame (float (start_time ), self .video_info .fps )
135+ self .__logger .info ("Set start frame to %d" , self .start_frame )
136+ except Exception as ex :
137+ self .logger .critical ("The program crashed in continue_with_tracking_result due to a fatal error" , exc_info = ex )
138+ self .__show_message ("Program crashed. Please send logfiles to the developer" )
139+ sys .exit ()
131140
132- start_time = min ([cache_content ["actions" ][metric ][0 ]["at" ] for metric in cache_content ["actions" ]])
133- self .start_frame = FFmpegStream .millisec_to_frame (float (start_time ), self .video_info .fps )
134- self .__logger .info ("Set start frame to %d" , self .start_frame )
135141 self .__next_postprocessing (None , [], [])
136142
137143
0 commit comments