Fix #533 and check for repeated URls in rip file (#540)

This commit is contained in:
Nathan Thomas 2024-01-13 21:54:29 -08:00 committed by GitHub
parent 1271df5ca7
commit 4c04188ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -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"
)