-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shot.py
68 lines (50 loc) · 1.73 KB
/
Shot.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
class Shot:
def __init__(self, shot_id):
self.shot_id = shot_id
self.image_url = ""
self.image = ""
self.description = ""
self.author = ""
self.popularity = {'view': 0, 'like': 0, 'comment': 0}
self.tags = []
def load_tags(self, tag):
self.tags = tag
def load_image_url(self, url):
self.image_url = url
def load_description(self, content):
self.description = content
def add_author(self, author):
self.author = author
def load_image(self, content):
self.image = content
def load_author_avatar(self, content):
self.author.load_avatar(content)
def load_popularity(self, view, like, comment):
self.popularity['view'] = view
self.popularity['like'] = like
self.popularity['comment'] = comment
# Public API
def get_popularity(self):
return self.popularity
def get_image_url(self):
return self.image_url
def get_description(self):
return self.description
def get_author_name(self):
return self.author.get_name()
def get_author_avatar_url(self):
return self.author.get_avatar_url()
def get_image(self):
return self.image
def get_author_avatar(self):
return self.author.get_avatar()
def get_tags(self):
return self.tags
def get_json(self):
return {'shot_id': self.shot_id,
'description': self.get_description(),
'view': self.get_popularity()['view'],
'like': self.get_popularity()['like'],
'comment': self.get_popularity()['comment'],
'author': self.get_author_name(),
'tags': self.get_tags()}