@@ -279,17 +279,18 @@ def get_filename(self):
279279 )
280280
281281
282- def getnative (args : Union [List , argparse .Namespace ], src : vapoursynth .VideoNode , scaler : Union [_DefineScaler , None ],
283- first_time : bool = True ) -> Tuple [List , pyplot .plot ]:
282+ async def getnative (args : Union [List , argparse .Namespace ], src : vapoursynth .VideoNode , scaler : Union [_DefineScaler , None ],
283+ first_time : bool = True ) -> Tuple [str , pyplot .plot , GetNative ]:
284284 """
285285 Process your VideoNode with the getnative algorithm and return the result and a plot object
286286
287287 :param args: List of all arguments for argparse or Namespace object from argparse
288288 :param src: VideoNode from vapoursynth
289289 :param scaler: DefineScaler object or None
290290 :param first_time: prevents posting warnings multiple times
291- :return: best resolutions list and plot matplotlib.pyplot
291+ :return: best resolutions string, plot matplotlib.pyplot and GetNative class object
292292 """
293+
293294 if type (args ) == list :
294295 args = parser .parse_args (args )
295296
@@ -338,8 +339,7 @@ def getnative(args: Union[List, argparse.Namespace], src: vapoursynth.VideoNode,
338339 getn = GetNative (src , scaler , args .ar , args .min_h , args .max_h , args .frame , args .mask_out , args .plot_scaling ,
339340 args .plot_format , args .show_plot , args .no_save , args .steps , output_dir )
340341 try :
341- loop = asyncio .get_event_loop ()
342- best_value , plot , resolutions = loop .run_until_complete (getn .run ())
342+ best_value , plot , resolutions = await getn .run ()
343343 except ValueError as err :
344344 raise GetnativeException (f"Error in getnative: { err } " )
345345
@@ -349,7 +349,7 @@ def getnative(args: Union[List, argparse.Namespace], src: vapoursynth.VideoNode,
349349 f"{ best_value } \n "
350350 )
351351
352- return resolutions , plot
352+ return best_value , plot , getn
353353
354354
355355def _getnative ():
@@ -376,11 +376,14 @@ def _getnative():
376376 elif args .mode == "all" :
377377 mode = [s for scaler in common_scaler .values () for s in scaler ]
378378
379+ loop = asyncio .get_event_loop ()
379380 for i , scaler in enumerate (mode ):
380381 if scaler is not None and scaler .plugin is None :
381382 print (f"Warning: No correct descale version found for { scaler } , continuing with next scaler when available." )
382383 continue
383- getnative (args , src , scaler , first_time = True if i == 0 else False )
384+ loop .run_until_complete (
385+ getnative (args , src , scaler , first_time = True if i == 0 else False )
386+ )
384387
385388
386389parser = argparse .ArgumentParser (description = 'Find the native resolution(s) of upscaled material (mostly anime)' )
0 commit comments