Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- XFire API
- -- Version 1.0
- -- By JPiolho
- -- Feel free to copy and edit as long you credit the original author
- -- More Info @ http://bit.ly/zoxn6V
- local function trim (s)
- return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
- end
- function getGamingHistory(username)
- if http == nil then return nil end
- local tbl = {}
- local html = http.get("http://www.xfire.com/profile/" .. username)
- if html == nil then return nil end
- html = html:readAll()
- local s = 0
- local e = 0
- while true do
- s,e = string.find(html,"<td class=\"est_stats_rows_gamecol\">",e+1)
- if s == nil or e == nil then break end
- local s2,e2 = string.find(html,">",e+1)
- local s3,e3 = string.find(html,"</a>",e2+1)
- -- Avoid 'Overall Hours'
- if string.sub(html,s2-7,s2) ~= "<strong>" then
- local gamename = string.sub(html,e2+1,s3-1)
- table.insert(tbl,gamename)
- end
- end
- return tbl
- end
- function getGamingRig(username)
- if http == nil then return nil end
- local html = http.get("http://www.xfire.com/profile/" .. username)
- if html == nil then return nil end
- html = html:readAll()
- local tbl = {}
- local s,e
- local es,ee
- s,e = string.find(html,"<table class=\"gaming_rig\">")
- es,ee = string.find(html,"</table>",e)
- local s2,e2
- while true do
- s2,e2 = string.find(html,"<th>",e2)
- if s2 == nil or e2 == nil or s2 > es or e2 > ee then break end
- local s3,e3 = string.find(html,"</th>",e2)
- local key = string.gsub(string.sub(html,e2+1,s3-1),":$","")
- local s4,e4 = string.find(html,"<div class=\"gaming_rig_content\">",e3)
- local s5,e5 = string.find(html,"</div>",e4)
- tbl[key] = string.sub(html,e4+1,s5-1)
- end
- return tbl
- end
- function getTotalPlayHours(username)
- if http == nil then return nil end
- local html = http.get("http://www.xfire.com/profile/" .. username)
- if html == nil then return nil end
- html = html:readAll()
- local s,e
- s,e = string.find(html,"<table class=\"gameplay_hours_overall overlay_box\">")
- local s2,e2 = string.find(html,"<td class=\"est_stats_rows_totalcol\">",e)
- local s3,e3 = string.find(html,"<",e2+1)
- return trim(string.gsub(string.gsub(string.sub(html,e2+1,s3-1),"hours",""),"%.",""))
- end
- function getStatus(username)
- if http == nil then return nil end
- local html = http.get("http://www.xfire.com/profile/" .. username)
- if html == nil then return nil end
- html = html:readAll()
- local s,e
- s,e = string.find(html,"<span class=\"profile_label\">Status</span>")
- local s2,e2 = string.find(html,"<br />",e)
- local s3,e3 = string.find(html,"</p>",e2+1)
- return trim(string.sub(html,e2+1,s3-1))
- end
Advertisement
Add Comment
Please, Sign In to add comment