-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.py
73 lines (62 loc) · 2.51 KB
/
user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 14 21:06:56 2017
@author: LKW084
"""
from recsys.algorithm.factorize import SVD
from recsys.datamodel.data import Data
from game import Game, get_preference
import json
import urllib
import urllib2
import math
import cStringIO
import matplotlib.pyplot as plt
from operator import itemgetter, attrgetter, methodcaller
def get_user_list():
url='http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?\
key=147CBF377C6B648EC3DC73499CE73D32&steamid=76561197960435530&relationship=friend'
response = urllib2.urlopen(url)
friends_Data = json.loads(response.read().decode('utf-8-sig'))
user_List=[]
user_List.append('76561198119879419')
num=0
for friends in friends_Data['friendslist']['friends']:
user_List.append(friends['steamid'])
num=num+1
#print num
return user_List
class User:
def __init__(self, userid):
url='http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?\
key=147CBF377C6B648EC3DC73499CE73D32&steamids='+user_map[item[0]]
response = urllib2.urlopen(url)
friends_Data = json.loads(response.read().decode('utf-8-sig'))
#print avatar
#urllib.urlretrieve(friends_Data['response']['players'][0]['avatarfull'], "local.jpg")
#image = plt.imread("local.jpg")
#plt.imshow(image)
#plt.show()
#print name
self.name=friends_Data['response']['players'][0]["personaname"]
self.avatar=friends_Data['response']['players'][0]['avatarfull']
def print_avatar(self):
urllib.urlretrieve(sefl.avatar, "local.jpg")
image = plt.imread("local.jpg")
plt.imshow(image)
plt.show()
def recommend_friends(user_map):
for item in svd_r.similar(1):
if item[1]>0.2:
print item[0]
url='http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?\
key=147CBF377C6B648EC3DC73499CE73D32&steamids='+user_map[item[0]]
response = urllib2.urlopen(url)
friends_Data = json.loads(response.read().decode('utf-8-sig'))
#print avatar
urllib.urlretrieve(friends_Data['response']['players'][0]['avatarfull'], "local.jpg")
image = plt.imread("local.jpg")
plt.imshow(image)
plt.show()
#print name
print friends_Data['response']['players'][0]["personaname"]