Get save/skip counting back
This commit is contained in:
parent
c1a7a74fda
commit
a87af2e9be
@ -26,6 +26,9 @@ todo...
|
||||
use/prefer public interfaces ? (export functions)
|
||||
"""
|
||||
|
||||
# Note(decentral1se): simple globals counting
|
||||
skipped, saved = 0, 0
|
||||
|
||||
|
||||
async def try_deleting(files):
|
||||
for f in files:
|
||||
@ -188,6 +191,8 @@ async def get_padids(args, info, data, session):
|
||||
|
||||
|
||||
async def handle_pad(args, padid, data, info, session):
|
||||
global skipped, saved
|
||||
|
||||
raw_ext = ".raw.txt"
|
||||
if args.no_raw_ext:
|
||||
raw_ext = ""
|
||||
@ -288,6 +293,7 @@ async def handle_pad(args, padid, data, info, session):
|
||||
|
||||
if skip:
|
||||
print("[ ] {} (skipped, reason: {})".format(padid, reason))
|
||||
skipped += 1
|
||||
return
|
||||
|
||||
if args.output:
|
||||
@ -329,7 +335,8 @@ async def handle_pad(args, padid, data, info, session):
|
||||
padid
|
||||
)
|
||||
)
|
||||
return
|
||||
skipped += 1
|
||||
return False
|
||||
|
||||
##########################################
|
||||
## ENFORCE __PUBLISH__ MAGIC WORD
|
||||
@ -344,7 +351,8 @@ async def handle_pad(args, padid, data, info, session):
|
||||
)
|
||||
)
|
||||
print("[ ] {} (deleted, reason: publish opt-out)".format(padid))
|
||||
return
|
||||
skipped += 1
|
||||
return False
|
||||
|
||||
ver["path"] = p + raw_ext
|
||||
ver["url"] = quote(ver["path"])
|
||||
@ -468,9 +476,13 @@ async def handle_pad(args, padid, data, info, session):
|
||||
await f.write(json.dumps(meta))
|
||||
|
||||
print("[x] {} (saved)".format(padid))
|
||||
saved += 1
|
||||
return
|
||||
|
||||
|
||||
async def handle_pads(args):
|
||||
global skipped, saved
|
||||
|
||||
session = asks.Session(connections=args.connection)
|
||||
info = loadpadinfo(args.padinfo)
|
||||
data = {"apikey": info["apikey"]}
|
||||
@ -488,11 +500,12 @@ async def handle_pads(args):
|
||||
for padid in padids:
|
||||
nursery.start_soon(handle_pad, args, padid, data, info, session)
|
||||
end = time.time()
|
||||
timeit = round(end - start, 2)
|
||||
|
||||
print("=" * 79)
|
||||
print(
|
||||
"Processed {} pads in {} seconds".format(
|
||||
len(padids), round(end - start, 2)
|
||||
"Processed {} :: Skipped {} :: Saved {} :: Time {}s".format(
|
||||
len(padids), skipped, saved, timeit
|
||||
)
|
||||
)
|
||||
print("=" * 79)
|
||||
|
Loading…
Reference in New Issue
Block a user