mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Update generate-touch-layouts-ids.py
This commit is contained in:
parent
b1e7e71f86
commit
6f81137cd4
@ -1,28 +1,25 @@
|
|||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
FOLDER = 'touch-layouts'
|
FOLDER = 'touch-layouts'
|
||||||
OUTPUT_FILE = os.path.join(FOLDER, 'ids.json')
|
OUTPUT_FILE = os.path.join(FOLDER, 'ids.json')
|
||||||
|
|
||||||
gameIds = list()
|
product_ids = list()
|
||||||
|
|
||||||
# Get files in folder
|
# Get files in folder
|
||||||
for file in os.listdir(FOLDER):
|
for file in os.listdir(FOLDER):
|
||||||
if not file.endswith('.json') or file == 'ids.json':
|
if not file.endswith('.json') or file == 'ids.json':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get game ID from file name (as int so we can sort the list later)
|
with open(os.path.join(FOLDER, file)) as fp:
|
||||||
gameId = int(file.replace('.json', ''))
|
content = json.load(fp)
|
||||||
gameIds.append(gameId)
|
product_ids.append(content['product_id'])
|
||||||
|
|
||||||
# Sort list of ints
|
# Sort list
|
||||||
gameIds.sort()
|
product_ids.sort()
|
||||||
# Convert int to string
|
|
||||||
gameIds = list(map((lambda x: str(x)), gameIds))
|
|
||||||
|
|
||||||
# Generate output string
|
|
||||||
output = '[\n ' + ',\n '.join(gameIds) + '\n]\n'
|
|
||||||
|
|
||||||
# Write to file
|
# Write to file
|
||||||
|
output = json.dumps(product_ids, separators=(',', ': '), indent=2) + '\n'
|
||||||
with open(OUTPUT_FILE, 'w') as fp:
|
with open(OUTPUT_FILE, 'w') as fp:
|
||||||
fp.write(output)
|
fp.write(output)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user