Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import mysql.connector
cnx = mysql.connector.connect(user='xx',password='xx',host='127.0.0.1', database='steamdb')
cursor = cnx.cursor()
cursor.execute('''
SELECT
`AppID`
FROM
`appsinfo`
WHERE
`Key` = 286
''')
games = [appid[0] for appid in cursor]
import json
cursor.execute('''
SELECT
`AppID`,
`Name`,
`Value`
FROM
`appsinfo`
JOIN
`apps` USING (`AppID`)
WHERE
`appsinfo`.`AppID` = `apps`.`AppID` AND
`Key` = 50
''')
from collections import defaultdict
exes = defaultdict(list)
for appid, name, data_txt in cursor:
if appid not in games:
continue
data = json.loads(data_txt)
for info in data.get('launch', {}).values():
# Must be runnable
if info.get('executable') is None:
continue
# Bad words
if 'config' in info.get('executable', '').lower() or 'config' in info.get('description', '').lower():
continue
if 'editor' in info.get('executable', '').lower() or 'editor' in info.get('description', '').lower():
continue
if 'website' in info.get('executable', '').lower() or 'website' in info.get('description', '').lower():
continue
if 'cfg' in info.get('executable', '').lower():
continue
if 'settings' in info.get('executable', '').lower() or 'settings' in info.get('description', '').lower():
continue
if 'support' in info.get('executable', '').lower() or 'support' in info.get('description', '').lower():
continue
if info.get('executable', '').lower().endswith('.htm'):
continue
if info.get('executable', '').lower().endswith('.html'):
continue
if info.get('executable', '').lower().endswith('.pdf'):
continue
if info.get('executable', '').lower().endswith('.url'):
continue
if info.get('executable', '').lower().endswith('.txt'):
continue
if info.get('executable', '').lower().endswith('.m3u'):
continue
# Must be Windows
os = info.get('config', {}).get('oslist', 'windows')
if os != 'windows':
continue
exe = info.get('executable').split('/')[-1].split('\\')[-1]
if exe not in exes[name]:
exes[name].append(exe)
cursor.close()
cnx.close()
buf = []
for title, files in exes.items():
for file in files:
buf.append(f'{file}: {title}')
with open('games.txt', 'w', encoding='utf-8') as f:
for line in sorted(buf, key=lambda s: s.lower()):
f.write(f'{line}\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.