diff options
author | Jordan <me@jordan.im> | 2023-04-20 21:00:54 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2023-04-20 21:00:54 -0700 |
commit | 2eb1a737ab14ee9f21c36c622a781aedb3a90250 (patch) | |
tree | 8ef93c446e93cc2b09216ef6b230e6b213803bf5 | |
parent | 64f16b6a7684a4054f46b009b1cb5a0c3751c6dd (diff) | |
download | bin-2eb1a737ab14ee9f21c36c622a781aedb3a90250.tar.gz bin-2eb1a737ab14ee9f21c36c622a781aedb3a90250.zip |
ia-storage-usage.py
-rwxr-xr-x | ia-storage-usage.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ia-storage-usage.py b/ia-storage-usage.py new file mode 100755 index 0000000..3df0e9e --- /dev/null +++ b/ia-storage-usage.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from tqdm import tqdm +from internetarchive import get_item +from internetarchive.session import ArchiveSession +from internetarchive.search import Search + +def convert_bytes(size): + for x in ['bytes', 'KB', 'MB', 'GB', 'TB']: + if size < 1024.0: + return "%3.1f%s" % (size, x) + size /= 1024.0 + + return size + +s = ArchiveSession() +search = Search(s, '(uploader:example@domain.com)') + +total = 0 +for result in tqdm(search): + ident = result['identifier'] + size = int(get_item(ident).item_size) + print(f"[{convert_bytes(size)}] {ident}") + + total += size + +print(f"\nTotal size: {convert_bytes(total)}") |