Skip to content

Instantly share code, notes, and snippets.

@chyyran
Created May 22, 2013 02:14
Show Gist options
  • Save chyyran/5624792 to your computer and use it in GitHub Desktop.
Save chyyran/5624792 to your computer and use it in GitHub Desktop.
Starts a steam game from name
#coding=utf-8
__author__ = 'ron975'
"""
This file is part of Snowflake.Core
"""
import jsonrpclib
import json
import sys
import webbrowser
import re
import urllib
def main():
try:
id = steam_id_from_name(sys.argv[1])
except IndexError:
return
print id
webbrowser.open_new('steam://rungameid/{0}'.format(id))
def steam_id_from_name(name):
name = urllib.quote_plus(name)
search = urllib.urlopen("http://store.steampowered.com/search/?category1=998&term="+name)
#print search.read()
stmid = re.findall(r'<a href="http://store.steampowered.com/app/*.+>', search.read())[0]
stmid = stmid.replace('<a href="http://store.steampowered.com/app/','')
stmid = re.findall(r'^.*?(?=/)',stmid)[0]
return stmid
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment