forked from omaidf/instagrapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.py
258 lines (216 loc) · 5.75 KB
/
types.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel, FilePath, HttpUrl
class Resource(BaseModel):
pk: int
video_url: Optional[HttpUrl] # for Video and IGTV
thumbnail_url: HttpUrl
media_type: int
class User(BaseModel):
pk: int
username: str
full_name: str
is_private: bool
profile_pic_url: HttpUrl
is_verified: bool
media_count: int
follower_count: int
following_count: int
biography: Optional[str] = ""
external_url: Optional[HttpUrl]
is_business: bool
class Account(BaseModel):
pk: int
username: str
full_name: str
is_private: bool
profile_pic_url: HttpUrl
is_verified: bool
biography: Optional[str] = ""
external_url: Optional[HttpUrl]
is_business: bool
birthday: Optional[str]
phone_number: Optional[str]
gender: Optional[int]
email: Optional[str]
class UserShort(BaseModel):
pk: int
username: Optional[str]
full_name: Optional[str] = ""
profile_pic_url: Optional[HttpUrl]
# is_private: bool
# is_verified: bool
stories: List = []
class Usertag(BaseModel):
user: UserShort
x: float
y: float
class Location(BaseModel):
pk: Optional[int]
name: str
address: Optional[str] = ""
lng: Optional[float]
lat: Optional[float]
external_id: Optional[int]
external_id_source: Optional[str]
# address_json: Optional[dict] = {}
# profile_pic_url: Optional[HttpUrl]
# directory: Optional[dict] = {}
class Media(BaseModel):
pk: int
id: str
code: str
taken_at: datetime
media_type: int
product_type: Optional[str] = "" # igtv or feed
thumbnail_url: Optional[HttpUrl]
location: Optional[Location] = None
user: UserShort
comment_count: int
like_count: int
has_liked: Optional[bool]
caption_text: str
usertags: List[Usertag]
video_url: Optional[HttpUrl] # for Video and IGTV
view_count: Optional[int] = 0 # for Video and IGTV
video_duration: Optional[float] = 0.0 # for Video and IGTV
title: Optional[str] = ""
resources: List[Resource] = []
class MediaOembed(BaseModel):
title: str
author_name: str
author_url: str
author_id: int
media_id: str
provider_name: str
provider_url: HttpUrl
type: str
width: Optional[int] = None
height: Optional[int] = None
html: str
thumbnail_url: HttpUrl
thumbnail_width: int
thumbnail_height: int
can_view: bool
class Collection(BaseModel):
id: str
name: str
type: str
media_count: int
class Comment(BaseModel):
pk: int
text: str
user: UserShort
created_at_utc: datetime
content_type: str
status: str
has_liked: Optional[bool]
like_count: Optional[int]
class Hashtag(BaseModel):
id: int
name: str
media_count: Optional[int]
profile_pic_url: Optional[HttpUrl]
class StoryMention(BaseModel):
user: UserShort
x: Optional[float]
y: Optional[float]
width: Optional[float]
height: Optional[float]
class StoryHashtag(BaseModel):
hashtag: Hashtag
x: Optional[float]
y: Optional[float]
width: Optional[float]
height: Optional[float]
class StoryLocation(BaseModel):
location: Location
x: Optional[float]
y: Optional[float]
width: Optional[float]
height: Optional[float]
class StorySticker(BaseModel):
id: str
type: Optional[str] = 'gif'
x: float
y: float
z: Optional[int] = 1000005
width: float
height: float
rotation: Optional[float] = 0.0
class StoryBuild(BaseModel):
mentions: List[StoryMention]
path: FilePath
class StoryLink(BaseModel):
webUri: HttpUrl
class Story(BaseModel):
pk: int
id: str
code: str
taken_at: datetime
media_type: int
product_type: Optional[str] = ""
thumbnail_url: Optional[HttpUrl]
user: UserShort
video_url: Optional[HttpUrl] # for Video and IGTV
video_duration: Optional[float] = 0.0 # for Video and IGTV
mentions: List[StoryMention]
links: List[StoryLink]
hashtags: List[StoryHashtag]
locations: List[StoryLocation]
stickers: List[StorySticker]
class DirectMessage(BaseModel):
id: int # e.g. 28597946203914980615241927545176064
user_id: Optional[int]
thread_id: Optional[int]
timestamp: datetime
item_type: Optional[str]
is_shh_mode: Optional[bool]
reactions: Optional[dict]
text: Optional[str]
media_share: Optional[Media]
reel_share: Optional[dict]
story_share: Optional[dict]
felix_share: Optional[dict]
placeholder: Optional[dict]
class DirectThread(BaseModel):
pk: int # thread_v2_id, e.g. 17898572618026348
id: int # thread_id, e.g. 340282366841510300949128268610842297468
messages: List[DirectMessage]
users: List[UserShort]
inviter: UserShort
left_users: List[UserShort]
admin_user_ids: list
last_activity_at: datetime
muted: bool
is_pin: bool
named: bool
canonical: bool
pending: bool
archived: bool
thread_type: str
thread_title: str
folder: int
vc_muted: bool
is_group: bool
mentions_muted: bool
approval_required_for_new_members: bool
input_mode: int
business_thread_folder: int
read_state: int
is_close_friend_thread: bool
assigned_admin_id: int
shh_mode_enabled: bool
last_seen_at: dict
def is_seen(self, user_id: int):
"""Have I seen this thread?
:param user_id: You account user_id
"""
user_id = str(user_id)
own_timestamp = int(self.last_seen_at[user_id]["timestamp"])
timestamps = [
(int(v["timestamp"]) - own_timestamp) > 0
for k, v in self.last_seen_at.items()
if k != user_id
]
return not any(timestamps)