From 4c04188adee1efcc1a11bf8c79024acfa7c898e2 Mon Sep 17 00:00:00 2001 From: Nathan Thomas Date: Sat, 13 Jan 2024 21:54:29 -0800 Subject: [PATCH] Fix #533 and check for repeated URls in rip file (#540) --- streamrip/rip/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/streamrip/rip/cli.py b/streamrip/rip/cli.py index de59fe7..2d70990 100644 --- a/streamrip/rip/cli.py +++ b/streamrip/rip/cli.py @@ -176,11 +176,12 @@ async def file(ctx, path): with ctx.obj["config"] as cfg: async with Main(cfg) as main: async with aiofiles.open(path, "r") as f: + content = await f.read() try: - items: Any = json.loads(await f.read()) + items: Any = json.loads(content) loaded = True except json.JSONDecodeError: - items: Any = [line async for line in f] + items = content.split() loaded = False if loaded: console.print( @@ -190,6 +191,12 @@ async def file(ctx, path): [(i["source"], i["media_type"], i["id"]) for i in items] ) else: + s = set(items) + if len(s) < len(items): + console.print( + f"Found [orange]{len(items)-len(s)}[/orange] repeated URLs!" + ) + items = list(s) console.print( f"Detected list of urls. Loading [yellow]{len(items)}[/yellow] items" )