From 4868ecf97658d2e28d77ab5e964d262d9c5f029e Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 1 Aug 2013 18:07:20 +0800 Subject: [PATCH 1/2] Update steam.py --- plugins/steam.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/plugins/steam.py b/plugins/steam.py index bb660cc..cdefe26 100644 --- a/plugins/steam.py +++ b/plugins/steam.py @@ -110,10 +110,9 @@ def steamcalc(inp, nick='', db=None): return u"%s (%s): %s%s%s%s" % (name, status, worth, timeonsteam, gamesplayed, web.try_isgd(url)) -@hook.regex(*steam_re) -def steam_url(match): +def get_steam_info(url): # we get the soup manually because the steam pages have some odd encoding troubles - page = http.get("http://store.steampowered.com" + match.group(4)) + page = http.get(url) soup = BeautifulSoup(page, 'lxml', from_encoding="utf-8") name = soup.find('div', {'class': 'apphub_AppName'}).text @@ -125,4 +124,18 @@ def steam_url(match): date = details[1].replace(u"Release Date: ", u"") price = soup.find('div', {'class': 'game_purchase_price price'}).text.strip() - return u"{}: {} | Genre: {} | Release date: {} | Price: {}".format(name, desc, genre, date, price) + return u"{}: {} - Genre: {} - Release date: {} - Price: {}".format(name, desc, genre, date, price) + + +@hook.regex(*steam_re) +def steam_url(match): + return get_steam_info("http://store.steampowered.com" + match.group(4)) + + +@hook.command +def steamsearch(inp): + """steamsearch [search] - Search for specified game/trailer/DLC""" + page = http.get("http://store.steampowered.com/search/?term=" + inp) + soup = BeautifulSoup(page, 'lxml', from_encoding="utf-8") + result = soup.find('a', {'class': 'search_result_row'}) + return get_steam_info(result['href']) + " - " + web.isgd(result['href']) From e025103d3971250f8ac4578b3e3ba6b30a944766 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 1 Aug 2013 18:17:41 +0800 Subject: [PATCH 2/2] Update steam.py --- plugins/steam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/steam.py b/plugins/steam.py index cdefe26..8f6e9c8 100644 --- a/plugins/steam.py +++ b/plugins/steam.py @@ -133,8 +133,8 @@ def steam_url(match): @hook.command -def steamsearch(inp): - """steamsearch [search] - Search for specified game/trailer/DLC""" +def steam(inp): + """steam [search] - Search for specified game/trailer/DLC""" page = http.get("http://store.steampowered.com/search/?term=" + inp) soup = BeautifulSoup(page, 'lxml', from_encoding="utf-8") result = soup.find('a', {'class': 'search_result_row'})