Skip to content

Commit c4bfbb0

Browse files
committed
make it compatible with the discord bot version
1 parent 910a666 commit c4bfbb0

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

getnative/app.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

355355
def _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

386389
parser = argparse.ArgumentParser(description='Find the native resolution(s) of upscaled material (mostly anime)')

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name="getnative",
13-
version='2.2.3',
13+
version='3.0.0',
1414
description='Find the native resolution(s) of upscaled material (mostly anime)',
1515
long_description=long_description,
1616
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)