warp-beacon 2.7.16__py3-none-any.whl → 2.7.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- warp_beacon/__version__.py +1 -1
- warp_beacon/scheduler/instagram_human.py +46 -21
- warp_beacon/scraper/instagram/wb_instagrapi.py +122 -6
- {warp_beacon-2.7.16.dist-info → warp_beacon-2.7.17.dist-info}/METADATA +1 -1
- {warp_beacon-2.7.16.dist-info → warp_beacon-2.7.17.dist-info}/RECORD +9 -9
- {warp_beacon-2.7.16.dist-info → warp_beacon-2.7.17.dist-info}/WHEEL +0 -0
- {warp_beacon-2.7.16.dist-info → warp_beacon-2.7.17.dist-info}/entry_points.txt +0 -0
- {warp_beacon-2.7.16.dist-info → warp_beacon-2.7.17.dist-info}/licenses/LICENSE +0 -0
- {warp_beacon-2.7.16.dist-info → warp_beacon-2.7.17.dist-info}/top_level.txt +0 -0
warp_beacon/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
__version__ = "2.7.
|
1
|
+
__version__ = "2.7.17"
|
2
2
|
|
@@ -44,6 +44,7 @@ class InstagramHuman(object):
|
|
44
44
|
#self.scrapler.cl.media_like(media_id)
|
45
45
|
self.scrapler.cl.media_comments(media_id)
|
46
46
|
self.operations_count += 1
|
47
|
+
|
47
48
|
self.random_pause(short=True)
|
48
49
|
except Exception as e:
|
49
50
|
logging.warning("Failed to see comments to media '%s'", media_id, exc_info=e)
|
@@ -70,10 +71,14 @@ class InstagramHuman(object):
|
|
70
71
|
return
|
71
72
|
|
72
73
|
seen = []
|
74
|
+
explore_user = None
|
73
75
|
for m in stories[:random.randint(1, len(stories))]:
|
74
76
|
try:
|
75
77
|
logging.info("Wathing story with pk '%s'", str(m.id))
|
76
78
|
seen.append(str(m.id))
|
79
|
+
if random.random() > 0.9:
|
80
|
+
explore_user = m.user
|
81
|
+
break
|
77
82
|
self.random_pause()
|
78
83
|
except Exception as e:
|
79
84
|
logging.warning("Exception while watching content", exc_info=e)
|
@@ -86,17 +91,22 @@ class InstagramHuman(object):
|
|
86
91
|
except Exception as e:
|
87
92
|
logging.warning("Failed to mark seen watched watch stories!", exc_info=e)
|
88
93
|
|
94
|
+
if explore_user:
|
95
|
+
self.explore_profile(explore_user)
|
96
|
+
|
89
97
|
def watch_content(self, media: list) -> None:
|
90
98
|
if not media:
|
91
99
|
return
|
100
|
+
explore_user = None
|
92
101
|
seen = []
|
93
102
|
for m in media[:random.randint(1, len(media))]:
|
94
103
|
try:
|
95
104
|
logging.info("Watching content with pk '%s'", str(m.id))
|
96
|
-
#content = self.scrapler.cl.media_info_v1(m.pk)
|
97
105
|
seen.append(str(m.id))
|
98
106
|
logging.info("Watched content with id '%s'", str(m.id))
|
99
|
-
|
107
|
+
if random.random() > 0.9:
|
108
|
+
explore_user = m.user
|
109
|
+
break
|
100
110
|
self.random_pause()
|
101
111
|
except Exception as e:
|
102
112
|
logging.warning("Exception while watching content")
|
@@ -107,12 +117,14 @@ class InstagramHuman(object):
|
|
107
117
|
except Exception as e:
|
108
118
|
logging.warning("Failed to mark seen watched videos!", exc_info=e)
|
109
119
|
|
120
|
+
if explore_user:
|
121
|
+
self.explore_profile(explore_user)
|
122
|
+
|
110
123
|
def scroll_content(self, last_pk: int) -> None:
|
111
124
|
timeline_initialized = False
|
112
125
|
if random.random() > 0.5:
|
113
126
|
timeline_initialized = True
|
114
|
-
|
115
|
-
self.scrapler.timeline_cursor = self.browse_timeline()
|
127
|
+
self.browse_timeline()
|
116
128
|
logging.info("Starting to watch related reels with media_pk '%d'", last_pk)
|
117
129
|
media = self.scrapler.download_hndlr(self.scrapler.cl.reels, amount=random.randint(4, 10), last_media_pk=last_pk)
|
118
130
|
self.operations_count += 1
|
@@ -121,8 +133,7 @@ class InstagramHuman(object):
|
|
121
133
|
if random.random() > 0.7:
|
122
134
|
time.sleep(random.uniform(2, 20))
|
123
135
|
if not timeline_initialized:
|
124
|
-
|
125
|
-
self.scrapler.timeline_cursor = self.browse_timeline()
|
136
|
+
self.browse_timeline()
|
126
137
|
logging.info("Starting to explore reels with media_pk '%d'", last_pk)
|
127
138
|
media = self.scrapler.download_hndlr(self.scrapler.cl.explore_reels, amount=random.randint(4, 10), last_media_pk=last_pk)
|
128
139
|
self.operations_count += 1
|
@@ -146,14 +157,14 @@ class InstagramHuman(object):
|
|
146
157
|
logging.info("Starting morning activity simulation")
|
147
158
|
#self.scrapler.timeline_cursor = self.scrapler.download_hndlr(self.scrapler.cl.get_timeline_feed, "pull_to_refresh", self.scrapler.timeline_cursor.get("next_max_id"))
|
148
159
|
#self.operations_count += 1
|
149
|
-
self.
|
160
|
+
self.browse_timeline()
|
150
161
|
time.sleep(random.uniform(3, 7))
|
151
162
|
if random.random() > 0.5:
|
152
163
|
self.check_direct()
|
153
|
-
if random.random() > 0.6:
|
154
|
-
|
155
|
-
|
156
|
-
|
164
|
+
#if random.random() > 0.6:
|
165
|
+
# self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
|
166
|
+
# self.operations_count += 1
|
167
|
+
# self.random_pause()
|
157
168
|
if random.random() > 0.2:
|
158
169
|
logging.info("Simulation updating reels tray feed ...")
|
159
170
|
self.scrapler.download_hndlr(self.scrapler.cl.get_reels_tray_feed, "pull_to_refresh")
|
@@ -200,11 +211,11 @@ class InstagramHuman(object):
|
|
200
211
|
time.sleep(random.uniform(2, 5))
|
201
212
|
if random.random() > 0.5:
|
202
213
|
self.check_direct()
|
203
|
-
if random.random() > 0.6:
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
214
|
+
#if random.random() > 0.6:
|
215
|
+
# logging.info("Checking notifications, tags ...")
|
216
|
+
# self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
|
217
|
+
# self.operations_count += 1
|
218
|
+
# self.random_pause()
|
208
219
|
if random.random() > 0.4:
|
209
220
|
self.watch_stories()
|
210
221
|
self.random_pause()
|
@@ -269,6 +280,20 @@ class InstagramHuman(object):
|
|
269
280
|
logging.warning("Failed to read thread %s", thread.id)
|
270
281
|
logging.exception(e)
|
271
282
|
|
283
|
+
def explore_profile(self, user: UserShort) -> None:
|
284
|
+
try:
|
285
|
+
logging.info("Exploring user profile '%s'", user.username)
|
286
|
+
user_id = self.scrapler.download_hndlr(self.scrapler.cl.user_id_from_username, user.username)
|
287
|
+
self.operations_count += 1
|
288
|
+
if user_id:
|
289
|
+
user_medias = self.scrapler.download_hndlr(self.scrapler.cl.user_medias, user_id, amount=random.randint(5, 15), sleep=random.randint(3, 7))
|
290
|
+
self.operations_count += 1
|
291
|
+
if user_medias:
|
292
|
+
self.random_pause(short=True)
|
293
|
+
self.watch_content(user_medias)
|
294
|
+
except Exception as e:
|
295
|
+
logging.warning("Failed to explore user profile with username '%s'", user.username, exc_info=e)
|
296
|
+
|
272
297
|
def profile_view(self) -> None:
|
273
298
|
try:
|
274
299
|
logging.info("profile_view ...")
|
@@ -302,11 +327,11 @@ class InstagramHuman(object):
|
|
302
327
|
if random.random() > 0.5:
|
303
328
|
self.check_direct()
|
304
329
|
|
305
|
-
if random.random() > 0.3:
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
330
|
+
#if random.random() > 0.3:
|
331
|
+
# logging.info("Checking notifications, tags ...")
|
332
|
+
# self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
|
333
|
+
# self.operations_count += 1
|
334
|
+
# self.random_pause()
|
310
335
|
|
311
336
|
if random.random() > 0.5:
|
312
337
|
logging.info("user_medias with target_user_id = '%s' ...", target_user_id)
|
@@ -1,16 +1,18 @@
|
|
1
1
|
import logging
|
2
|
-
from typing import Callable
|
2
|
+
from typing import Callable, List
|
3
3
|
from copy import deepcopy
|
4
4
|
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
|
5
5
|
from pathlib import Path
|
6
|
+
import time
|
6
7
|
import requests
|
7
8
|
|
8
9
|
from instagrapi import Client
|
9
|
-
from instagrapi.types import Media
|
10
|
+
from instagrapi.types import Media, User
|
10
11
|
from instagrapi.exceptions import (
|
11
|
-
ClientError,
|
12
|
-
ClientLoginRequired,
|
13
|
-
VideoNotDownload
|
12
|
+
#ClientError,
|
13
|
+
#ClientLoginRequired,
|
14
|
+
VideoNotDownload,
|
15
|
+
PrivateError
|
14
16
|
)
|
15
17
|
|
16
18
|
from warp_beacon.scraper.utils import ScraperUtils
|
@@ -190,4 +192,118 @@ class WBClient(Client):
|
|
190
192
|
self._medias_cache[media_pk] = media
|
191
193
|
return deepcopy(
|
192
194
|
self._medias_cache[media_pk]
|
193
|
-
) # return copy of cache (dict changes protection)
|
195
|
+
) # return copy of cache (dict changes protection)
|
196
|
+
|
197
|
+
def user_info_by_username(self, username: str, use_cache: bool = True) -> User:
|
198
|
+
"""
|
199
|
+
Get user object from username
|
200
|
+
|
201
|
+
Parameters
|
202
|
+
----------
|
203
|
+
username: str
|
204
|
+
User name of an instagram account
|
205
|
+
use_cache: bool, optional
|
206
|
+
Whether or not to use information from cache, default value is True
|
207
|
+
|
208
|
+
Returns
|
209
|
+
-------
|
210
|
+
User
|
211
|
+
An object of User type
|
212
|
+
"""
|
213
|
+
username = str(username).lower()
|
214
|
+
if not use_cache or username not in self._usernames_cache:
|
215
|
+
user = self.user_info_by_username_v1(username)
|
216
|
+
self._users_cache[user.pk] = user
|
217
|
+
self._usernames_cache[user.username] = user.pk
|
218
|
+
return self.user_info(self._usernames_cache[username])
|
219
|
+
|
220
|
+
def user_info(self, user_id: str, use_cache: bool = True) -> User:
|
221
|
+
"""
|
222
|
+
Get user object from user id
|
223
|
+
|
224
|
+
Parameters
|
225
|
+
----------
|
226
|
+
user_id: str
|
227
|
+
User id of an instagram account
|
228
|
+
use_cache: bool, optional
|
229
|
+
Whether or not to use information from cache, default value is True
|
230
|
+
|
231
|
+
Returns
|
232
|
+
-------
|
233
|
+
User
|
234
|
+
An object of User type
|
235
|
+
"""
|
236
|
+
user_id = str(user_id)
|
237
|
+
if not use_cache or user_id not in self._users_cache:
|
238
|
+
user = self.user_info_v1(user_id)
|
239
|
+
self._users_cache[user_id] = user
|
240
|
+
self._usernames_cache[user.username] = user.pk
|
241
|
+
return deepcopy(
|
242
|
+
self._users_cache[user_id]
|
243
|
+
) # return copy of cache (dict changes protection)
|
244
|
+
|
245
|
+
def user_medias(self, user_id: str, amount: int = 0, sleep: int = 0) -> List[Media]:
|
246
|
+
"""
|
247
|
+
Get a user's media
|
248
|
+
|
249
|
+
Parameters
|
250
|
+
----------
|
251
|
+
user_id: str
|
252
|
+
amount: int, optional
|
253
|
+
Maximum number of media to return, default is 0 (all medias)
|
254
|
+
sleep: int, optional
|
255
|
+
Timeout between page iterations
|
256
|
+
|
257
|
+
Returns
|
258
|
+
-------
|
259
|
+
List[Media]
|
260
|
+
A list of objects of Media
|
261
|
+
"""
|
262
|
+
amount = int(amount)
|
263
|
+
user_id = int(user_id)
|
264
|
+
sleep = int(sleep)
|
265
|
+
# User may been private, attempt via Private API
|
266
|
+
# (You can check is_private, but there may be other reasons,
|
267
|
+
# it is better to try through a Private API)
|
268
|
+
medias = self.user_medias_v1(user_id, amount, sleep)
|
269
|
+
return medias
|
270
|
+
|
271
|
+
def user_medias_v1(self, user_id: str, amount: int = 0, sleep: int = 0) -> List[Media]:
|
272
|
+
"""
|
273
|
+
Get a user's media by Private Mobile API
|
274
|
+
|
275
|
+
Parameters
|
276
|
+
----------
|
277
|
+
user_id: str
|
278
|
+
amount: int, optional
|
279
|
+
Maximum number of media to return, default is 0 (all medias)
|
280
|
+
|
281
|
+
Returns
|
282
|
+
-------
|
283
|
+
List[Media]
|
284
|
+
A list of objects of Media
|
285
|
+
"""
|
286
|
+
amount = int(amount)
|
287
|
+
user_id = int(user_id)
|
288
|
+
medias = []
|
289
|
+
next_max_id = ""
|
290
|
+
while True:
|
291
|
+
try:
|
292
|
+
medias_page, next_max_id = self.user_medias_paginated_v1(
|
293
|
+
user_id, amount, end_cursor=next_max_id
|
294
|
+
)
|
295
|
+
except PrivateError as e:
|
296
|
+
raise e
|
297
|
+
except Exception as e:
|
298
|
+
self.logger.exception(e)
|
299
|
+
break
|
300
|
+
medias.extend(medias_page)
|
301
|
+
if not next_max_id:
|
302
|
+
break
|
303
|
+
if amount and len(medias) >= amount:
|
304
|
+
break
|
305
|
+
if sleep:
|
306
|
+
time.sleep(sleep)
|
307
|
+
if amount:
|
308
|
+
medias = medias[:amount]
|
309
|
+
return medias
|
@@ -4,7 +4,7 @@ var/warp_beacon/accounts.json,sha256=OsXdncs6h88xrF_AP6_WDCK1waGBn9SR-uYdIeK37GM
|
|
4
4
|
var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
|
5
5
|
var/warp_beacon/proxies.json,sha256=VnjlQDXumOEq72ZFjbh6IqHS1TEHqn8HPYAZqWCeSIA,95
|
6
6
|
warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
|
7
|
-
warp_beacon/__version__.py,sha256=
|
7
|
+
warp_beacon/__version__.py,sha256=9LvXwlPbaoBIl4ZC2lHHNwH7SiPx0wk_JJiO4Elj5yg,24
|
8
8
|
warp_beacon/warp_beacon.py,sha256=ADCR30uGXIsDrt9WoiI9Ghu2QtWs0qZIK6x3pQKM_B4,1109
|
9
9
|
warp_beacon/yt_auth.py,sha256=GUTKqYr_tzDC-07Lx_ahWXSag8EyLxXBUnQbDBIkEmk,6022
|
10
10
|
warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -20,7 +20,7 @@ warp_beacon/mediainfo/audio.py,sha256=ous88kwQj4bDIChN5wnGil5LqTs0IQHH0d-nyrL0-Z
|
|
20
20
|
warp_beacon/mediainfo/silencer.py,sha256=qxMuViOoVwUYb60uCVvqHiGrqByR1_4_rqMT-XdMkwc,1813
|
21
21
|
warp_beacon/mediainfo/video.py,sha256=UBZrhTN5IDI-aYu6tsJEILo9nFkjHhkldGVFmvV7tEI,2480
|
22
22
|
warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
|
-
warp_beacon/scheduler/instagram_human.py,sha256=
|
23
|
+
warp_beacon/scheduler/instagram_human.py,sha256=Rm1St5DFzFYd27TvwJ4-m3N_tkVR5W51Lx0JT9yowF0,11789
|
24
24
|
warp_beacon/scheduler/scheduler.py,sha256=Bf4sGXjX75Dox3q-yzUHhagtzUAj3hl5GzfnZya-_io,4995
|
25
25
|
warp_beacon/scraper/__init__.py,sha256=gQOcBvZNnlxt0Rbbrkl4PLh7eQe2y3igJbx-87hAvrA,20249
|
26
26
|
warp_beacon/scraper/abstract.py,sha256=pWbaTu-gDZgi-iFjqMR_uGzPl5KLv-4gTdJ9w6cD4sk,3802
|
@@ -32,7 +32,7 @@ warp_beacon/scraper/utils.py,sha256=yL-nrdCOAXNZgmIFPurIYFHfPsxHDl8pqif6BYKrzJI,
|
|
32
32
|
warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
warp_beacon/scraper/instagram/captcha.py,sha256=9UYziuqB3Tsat_ET6ex-cnZDbi6yCnsXHSpmE8MuUHk,4651
|
34
34
|
warp_beacon/scraper/instagram/instagram.py,sha256=oVXP6VweJCeffhyDU-GZLa66ESW06GvfuGcW2V6YdQ4,18629
|
35
|
-
warp_beacon/scraper/instagram/wb_instagrapi.py,sha256=
|
35
|
+
warp_beacon/scraper/instagram/wb_instagrapi.py,sha256=DvGehtiaMfNYV9MnAngry1wxQwGdRSPBQgFJDPdRJ7w,8854
|
36
36
|
warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
37
|
warp_beacon/scraper/youtube/abstract.py,sha256=-H1AFMJD9w1GmVDTuJKGsFTrgrctdRcgTTrXM2OhLjE,16236
|
38
38
|
warp_beacon/scraper/youtube/music.py,sha256=5AeSBQyUgVCJT2hoBCV2WvlyuV9US09SYJhmBG_P9F8,2755
|
@@ -52,9 +52,9 @@ warp_beacon/telegram/progress_file_reader.py,sha256=e3equyNKlKs764AD-iE9QRsh3YDH
|
|
52
52
|
warp_beacon/telegram/types.py,sha256=Kvdng6uCF1HRoqQgGW1ZYYPJoVuYkFb-LDvMBbW5Hjk,89
|
53
53
|
warp_beacon/telegram/utils.py,sha256=S1N_JbHM_ExiM5tS0CeYKWIlvaJMlyq85TQNbK_GVds,5029
|
54
54
|
warp_beacon/uploader/__init__.py,sha256=ewvR60k9osJxw_kb5U-TlZkCGR_574biq3w_aR1tjIU,5689
|
55
|
-
warp_beacon-2.7.
|
56
|
-
warp_beacon-2.7.
|
57
|
-
warp_beacon-2.7.
|
58
|
-
warp_beacon-2.7.
|
59
|
-
warp_beacon-2.7.
|
60
|
-
warp_beacon-2.7.
|
55
|
+
warp_beacon-2.7.17.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
56
|
+
warp_beacon-2.7.17.dist-info/METADATA,sha256=7YmBckgrYCXBKh7_uj6rtPGsCqdN8fqitKvYgLffp40,23215
|
57
|
+
warp_beacon-2.7.17.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
58
|
+
warp_beacon-2.7.17.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
|
59
|
+
warp_beacon-2.7.17.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
|
60
|
+
warp_beacon-2.7.17.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|