The script you've linked gets your entire Steam library as XML. The ID you're looking for is included in the XML.
The script retrieves your library from the following link:
http://steamcommunity.com/id/{0}/games?tab=all&xml=1
where {0}
is your profile ID. To find your profile ID, go to your profile page on Steam, click on "Edit Profile", and the ID will be the number in the "Custom URL" section. Alternatively, you can log in to Steam in your browser, go to your profile page, and get the ID from the URL in your browser's address bar.
The XML contains a steamID
(your profile name), a steamID64
(a unique number), and a list of your games.
Here's an example of a game I own:
<game>
<appID>220</appID>
<name>
<![CDATA[ Half-Life 2 ]]>
</name>
<logo>
<![CDATA[
https://steamcdn-a.akamaihd.net/steam/apps/220/capsule_184x69.jpg
]]>
</logo>
<storeLink>
<![CDATA[ https://steamcommunity.com/app/220 ]]>
</storeLink>
<statsLink>
<![CDATA[
https://steamcommunity.com/id/{steamID64}/stats/HL2
]]>
</statsLink>
<globalStatsLink>
<![CDATA[ https://steamcommunity.com/stats/HL2/achievements/ ]]>
</globalStatsLink>
</game>
Which means that I own a game called "Half-Life 2", whose ID is 220.
Now all we need to do is write the function that'll give us a list of game IDs.
NOTE: The script you've linked is written in Python 2, but I use Python 3. If you have to use Python 2, you'll need to do the conversion yourself, which shouldn't be too hard to do.
def get_ids(username):
tree = ET.parse(get_steam_xml(username))
root = tree.getroot()
if root.find('error') is not None:
print(root.find('error').text)
sys.exit(0)
return {game.find('appID').text: game.find('name').text for game in root.iter('game')}
Or if you want a full standalone script:
import os
import sys
import urllib.request
import xml.etree.ElementTree as ET
def get_steam_xml(username):
xml_url = 'http://steamcommunity.com/id/{}/games?tab=all&xml=1'.format(
username)
return urllib.request.urlopen(xml_url)
def get_ids(username):
tree = ET.parse(get_steam_xml(username))
root = tree.getroot()
if root.find('error') is not None:
print(root.find('error').text)
sys.exit(0)
return {game.find('appID').text: game.find('name').text for game in root.iter('game')}
def main():
username = input('Steam username: ')
path_to_save = input(
'Path to save (leave blank for current directory): ')
if path_to_save == '':
path_to_save = '.'
else:
path_to_save = path_to_save.replace('\\', '/')
if path_to_save[-1:] == '/':
path_to_save = path_to_save[:-1]
if not os.path.isdir(path_to_save):
print('Directory does not exist')
sys.exit(0)
with open(path_to_save + '/ids.txt', 'w', encoding='utf-8') as f:
for id, name in get_ids(username).items():
f.write("{},{}\n".format(id, name))
if __name__ == '__main__':
main()
This creates a "ids.txt" file where each line is in the format: id,name
. Note that a game's name can contain commas. If you need the file in a different format, you'll need to modify the script yourself.