re-add date_added field from Grouvee export
This commit is contained in:
parent
1f5760073f
commit
4a16cb8490
4 changed files with 27639 additions and 27103 deletions
|
@ -1,26 +1,29 @@
|
|||
[
|
||||
{
|
||||
"Title": "Death Stranding",
|
||||
"Date Started": "2024-01-25",
|
||||
"Platforms": "PC",
|
||||
"Developers": "Kojima Productions",
|
||||
"Date Released": "2019-11-08",
|
||||
"GiantBomb ID": "54232"
|
||||
},
|
||||
{
|
||||
"Title": "Ancestors: The Humankind Odyssey",
|
||||
"Platform": "PC",
|
||||
"Date Started": "2023-08-08",
|
||||
"Developers": "Panache Digital Games",
|
||||
"Date Released": "2019-08-27",
|
||||
"GiantBomb ID": "49527"
|
||||
},
|
||||
{
|
||||
"Title": "TIS-100",
|
||||
"Platforms": "PC",
|
||||
"Date Started": "2016-12-24",
|
||||
"Developers": "Zachtronics Industries",
|
||||
"Date Released": "2015-07-20",
|
||||
"GiantBomb ID": "49901"
|
||||
}
|
||||
{
|
||||
"Title": "Death Stranding",
|
||||
"Date Started": "2024-01-25",
|
||||
"Platforms": "PC",
|
||||
"Developers": "Kojima Productions",
|
||||
"Date Released": "2019-11-08",
|
||||
"GiantBomb ID": "54232",
|
||||
"date_added": "2019-12-04T21:27:08Z"
|
||||
},
|
||||
{
|
||||
"Title": "Ancestors: The Humankind Odyssey",
|
||||
"Platform": "PC",
|
||||
"Date Started": "2023-08-08",
|
||||
"Developers": "Panache Digital Games",
|
||||
"Date Released": "2019-08-27",
|
||||
"GiantBomb ID": "49527",
|
||||
"date_added": "2020-05-24T18:26:59Z"
|
||||
},
|
||||
{
|
||||
"Title": "TIS-100",
|
||||
"Platforms": "PC",
|
||||
"Date Started": "2016-12-24",
|
||||
"Developers": "Zachtronics Industries",
|
||||
"Date Released": "2015-07-20",
|
||||
"GiantBomb ID": "49901",
|
||||
"date_added": "2020-01-06T12:41:38Z"
|
||||
}
|
||||
]
|
8973
data/games/log.json
8973
data/games/log.json
File diff suppressed because it is too large
Load diff
45649
data/games/wishlist.json
45649
data/games/wishlist.json
File diff suppressed because it is too large
Load diff
61
scripts/add_date_added_to_games.py
Normal file
61
scripts/add_date_added_to_games.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
import json
|
||||
|
||||
with open(f"./scripts/grouvee.json", "r", encoding="utf-8") as log_file:
|
||||
orig_log_items = json.load(log_file)
|
||||
|
||||
for log in ["log", "current", "wishlist"]:
|
||||
print(f"Processing {log}…")
|
||||
|
||||
with open(f"./data/games/{log}.json", "r", encoding="utf-8") as log_file:
|
||||
log_items = json.load(log_file)
|
||||
|
||||
for i, item in enumerate(log_items):
|
||||
print(f"Processing {item['Title']}...")
|
||||
|
||||
if "GiantBomb ID" in item:
|
||||
orig_item = [""]
|
||||
if "" != item["GiantBomb ID"]:
|
||||
orig_item = [
|
||||
orig_item
|
||||
for orig_item in orig_log_items
|
||||
if orig_item["giantbomb_id"] == int(item["GiantBomb ID"])
|
||||
]
|
||||
|
||||
elif "" == item["GiantBomb ID"]:
|
||||
orig_item = [
|
||||
orig_item
|
||||
for orig_item in orig_log_items
|
||||
if orig_item["name"] == item["Title"]
|
||||
]
|
||||
|
||||
if [] == orig_item:
|
||||
print(f"No item {item['Title']} found in original log!")
|
||||
log_items[i] = item
|
||||
break
|
||||
|
||||
elif 1 < len(orig_item):
|
||||
raise Exception(f"Multiple items returned for {item['Title']}!")
|
||||
|
||||
else:
|
||||
orig_item = orig_item[0]
|
||||
|
||||
if "Wish List" in orig_item["shelves"]:
|
||||
item["date_added"] = orig_item["shelves"]["Wish List"]["date_added"]
|
||||
|
||||
elif "Backlog" in orig_item["shelves"]:
|
||||
item["date_added"] = orig_item["shelves"]["Backlog"]["date_added"]
|
||||
|
||||
elif "Played" in orig_item["shelves"] and "log" == log:
|
||||
item["date_added"] = orig_item["shelves"]["Played"]["date_added"]
|
||||
|
||||
else:
|
||||
print(f"No date_added for {item['Title']}!")
|
||||
|
||||
log_items[i] = item
|
||||
|
||||
print(f"Finished processing {item['Title']}.")
|
||||
|
||||
with open(f"./data/games/{log}.json", "w", encoding="utf-8") as log_file:
|
||||
json.dump(log_items, log_file, indent=4)
|
||||
|
||||
print(f"Finished processing {log}.")
|
Loading…
Reference in a new issue