diff --git a/plugins/steam.py b/plugins/steam.py index 6e3bcea..524bf84 100644 --- a/plugins/steam.py +++ b/plugins/steam.py @@ -57,14 +57,23 @@ def steamcalc(inp, nick='', db=None): url = http.prepare_url("http://steamdb.info/calculator/", {"player": inp, "currency": currency if currency else "us"}) soup = http.get_soup(url) + out = u"" + try: - name = soup.findAll('h1', {'class': 'header-title'})[1].text - status = soup.findAll('td')[7].text + out += soup.findAll('h1', {'class': 'header-title'})[1].text.strip() except Exception as e: print e return u"\x02Unable to retrieve info for %s!\x02 Is it a valid SteamCommunity profile username (%s)? " \ "Check if your profile is private, or go here to search: %s" % (inp, web.try_isgd("http://steamcommunity.com/id/%s" % inp), web.try_isgd(url)) + nextone = False + status = "Unknown" + for i in soup.findAll('td'): + if nextone: + status = i.text + break + elif i.text == "Status": + nextone=True if status == "Online": status = "\x033\x02Online\x02\x0f" elif status == "Offline": @@ -75,41 +84,25 @@ def steamcalc(inp, nick='', db=None): status = "\x035\x02Busy\x02\x0f" elif "Looking to" in status: status = "\x036\x02%s\x02\x0f" % status + out += " (%s)" % status - out = "" - - try: - twdata = soup.find('h1', {'class': 'header-title pull-right'}).find('a')['data-text'].split(", ") - money = twdata[0].split("My #Steam account is worth ")[1] - time = twdata[1].split("and I spent ")[1].split(" playing games!")[0] - out += "This account is worth \x02%s\x02, and they've spent \x02%s\x02 playing games! " % (money, time) - except: - pass - - try: - timeonsteam = soup.findAll('i')[1].text[1:-1].split(" ") - timestamp = datetime.strptime(timeonsteam[0]+" "+timeonsteam[1]+" "+timeonsteam[2] + " - " + timeonsteam[4]+" "+timeonsteam[5], "%B %d, %Y - %H:%M:%S UTC") - timeonsteam = timesince.timesince(timestamp) - out += "Their account was created %s ago! " % timeonsteam - except: - pass - - try: - totalgames = soup.find('b').text - notplayed = soup.findAll('b')[1].text - nppercent = soup.findAll('i')[3].text[1:-1] - out += "They have \x02%s games\x02, but \x02%s of them haven't been played\x02! That's \x02%s\x02! " % (totalgames, notplayed, nppercent) - except: - pass + for i in soup.findAll('div', {'class': 'panel'}): + if str(i.find('div', {'class': 'panel-heading'})) == '