Created
February 22, 2018 22:36
-
-
Save Yepoleb/6dbd110ca8caca55573552ab9c8190cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Prints all bonus content changes tracked by GOG DB. | |
Needs a CSV dump in data/ | |
""" | |
import csv | |
CHANGE_SYMBOL = { | |
"add": "+", | |
"del": "-", | |
"change": "~" | |
} | |
with open("data/changerecords.csv") as changerecords_file: | |
changerecords_reader = csv.DictReader(changerecords_file) | |
changerecords = list(changerecords_reader) | |
changerecords.sort(key=lambda x: int(x["id"])) | |
downloads = {} | |
with open("data/downloads.csv") as downloads_file: | |
downloads_reader = csv.DictReader(downloads_file) | |
for download in downloads_reader: | |
dlkey = (download["prod_id"], download["slug"]) | |
downloads[dlkey] = download | |
products = {} | |
with open("data/products.csv") as products_file: | |
products_reader = csv.DictReader(products_file) | |
for product in products_reader: | |
products[product["id"]] = product | |
for changerecord in changerecords: | |
if changerecord["type_prim"] == "download": | |
product = products[changerecord["prod_id"]] | |
download = downloads[(changerecord["prod_id"], changerecord["resource"])] | |
if download["type"] == "bonus_content": | |
symbol = CHANGE_SYMBOL[changerecord["action"]] | |
print( | |
symbol, | |
changerecord["timestamp"].split()[0], # Date part only | |
product["title"], | |
download["name"] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment