Skip to content

Commit

Permalink
chore: Change tqdm and feat: organize item metadata cache structure
Browse files Browse the repository at this point in the history
Co-authored-by: yzqzss <[email protected]>
  • Loading branch information
Ovler-Young and yzqzss committed Nov 19, 2024
1 parent d9d0105 commit 6ed99b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/ia_collection_analyzer/libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import logging
import os
import time
import tqdm

from tqdm import tqdm
import internetarchive as ia


CACHE_DIR = Path("cache")
CACHE_DIR.mkdir(exist_ok=True)
ITEM_CACHE_DIR = CACHE_DIR / "item"
ITEM_CACHE_DIR.mkdir(exist_ok=True)
COLLECTION_TTL = 24 * 3600

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -57,7 +59,7 @@ def get_collection_items(collection_id) -> list:


def get_item_metadata(item_id) -> dict:
cache_key = f"item_metadata_{item_id}"
cache_key = f"item/item_metadata_{item_id}"
cache_filename = get_cache_filename(cache_key)

if os.path.exists(cache_filename):
Expand All @@ -75,7 +77,7 @@ def get_item_metadata(item_id) -> dict:
def get_collection_items_metadata(collection_id) -> list[dict]:
items = get_collection_items(collection_id)
metadatas = []
for item in tqdm.tqdm(items):
for item in tqdm(items):
metadatas.append(get_item_metadata(item))
return metadatas

Expand Down

0 comments on commit 6ed99b1

Please sign in to comment.