2024-03-10 18:49:39 +00:00
|
|
|
import json
|
|
|
|
|
from rec.query import detail_query
|
2024-03-11 14:43:53 +00:00
|
|
|
from tqdm import tqdm
|
2024-03-10 18:49:39 +00:00
|
|
|
|
2024-03-11 14:43:53 +00:00
|
|
|
from data_access import Listing
|
2024-03-10 18:49:39 +00:00
|
|
|
|
2024-11-23 22:57:22 +00:00
|
|
|
incremental = True
|
|
|
|
|
|
|
|
|
|
|
2024-04-01 20:28:37 +02:00
|
|
|
listings = Listing.get_all_listings()
|
|
|
|
|
filtered_listings = []
|
|
|
|
|
for listing in listings:
|
2025-02-16 03:02:21 +00:00
|
|
|
# We introduced last_seen later, so not all entries have it.
|
|
|
|
|
# If it doesnt exist then its on the platform anymore. So skip
|
|
|
|
|
last_seen = listing.last_seen
|
|
|
|
|
if last_seen is None:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if not incremental and last_seen <= 1:
|
2024-11-23 22:57:22 +00:00
|
|
|
filtered_listings.append(listing)
|
|
|
|
|
|
|
|
|
|
if incremental and not listing.path_detail_json().exists():
|
2024-04-01 20:28:37 +02:00
|
|
|
filtered_listings.append(listing)
|
2024-04-05 11:38:55 +01:00
|
|
|
|
2024-04-01 20:28:37 +02:00
|
|
|
for listing in tqdm(filtered_listings):
|
2024-03-10 18:49:39 +00:00
|
|
|
try:
|
2024-03-11 14:43:53 +00:00
|
|
|
d = detail_query(listing.identifier)
|
2024-03-25 20:48:48 +00:00
|
|
|
with open(listing.path_detail_json(), "w") as f:
|
2024-03-11 14:43:53 +00:00
|
|
|
json.dump(d, f)
|
2024-05-06 18:54:55 +01:00
|
|
|
except Exception as e:
|
|
|
|
|
print(e)
|