-
Notifications
You must be signed in to change notification settings - Fork 42
/
skin_id_getter.py
77 lines (58 loc) · 2.18 KB
/
skin_id_getter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import re
import io
import os
# Point the script to your CSGO folder and it will get up to date skin IDs and names and output to item_index.txt
SteamPath = 'C:/Program Files (x86)/Steam/steamapps/common/Counter-Strike Global Offensive/'
skindata = {}
with open(os.path.join(SteamPath, 'csgo/scripts/items/items_game.txt'), 'r') as itemfile:
start = False
count = 0
currnum = None
for line in itemfile.readlines():
if start:
number = False
tempdata = {}
if re.match(r'^"\d*"$', line.strip()):
currnum = int(line.strip().replace('"', ''))
skindata[currnum] = {}
number = True
if '{' in line:
count += 1
if '}' in line:
count -= 1
if count == 0:
start = False
continue
if line.strip() == '{' or line.strip() == '}':
continue
if currnum and not number:
try:
first, second = line.strip().replace('"', '').split('\t\t')
skindata[currnum][first] = second
except ValueError:
pass
if line.strip() == '"paint_kits"':
start = True
skindata.pop(0)
skindata.pop(9001)
namedata = {}
with io.open(os.path.join(SteamPath, 'csgo/resource/csgo_english.txt'), 'r', encoding='utf-16-le') as languagefile:
# Steam language files are encoded in utf-16LE
start = False
count = 0
currnum = None
for line in languagefile.readlines():
if line.strip() == '//Recipes':
start = False
break
if start:
if line.strip().startswith('"Paint'):
tag, name = re.split(r'"\s+"', line.strip())
if 'tag' in tag.lower():
namedata['#' + tag.replace('"', '').lower()] = name.replace('"', '')
if line.strip() == '// Paint Kits':
start = True
with io.open('item_index.txt', 'w', encoding="utf-8") as outfile:
for n in sorted(skindata):
tag = skindata[n]['description_tag']
outfile.write("%s: %s\n" % (n, namedata[tag.lower()]))