warp-beacon 2.7.16__tar.gz → 2.7.18__tar.gz

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.
Files changed (70) hide show
  1. {warp_beacon-2.7.16/warp_beacon.egg-info → warp_beacon-2.7.18}/PKG-INFO +1 -1
  2. warp_beacon-2.7.18/warp_beacon/__version__.py +2 -0
  3. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scheduler/instagram_human.py +46 -21
  4. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/instagram/wb_instagrapi.py +122 -6
  5. {warp_beacon-2.7.16 → warp_beacon-2.7.18/warp_beacon.egg-info}/PKG-INFO +1 -1
  6. warp_beacon-2.7.16/warp_beacon/__version__.py +0 -2
  7. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/LICENSE +0 -0
  8. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/MANIFEST.in +0 -0
  9. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/README.md +0 -0
  10. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/assets/cc-group-black.png +0 -0
  11. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/assets/placeholder.gif +0 -0
  12. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/etc/.gitignore +0 -0
  13. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/etc/accounts.json +0 -0
  14. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/etc/proxies.json +0 -0
  15. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/etc/warp_beacon.conf +0 -0
  16. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/etc/warp_beacon.service +0 -0
  17. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/pyproject.toml +0 -0
  18. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/setup.cfg +0 -0
  19. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/setup.py +0 -0
  20. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/__init__.py +0 -0
  21. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/compress/__init__.py +0 -0
  22. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/compress/video.py +0 -0
  23. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/jobs/__init__.py +0 -0
  24. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/jobs/abstract.py +0 -0
  25. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/jobs/download_job.py +0 -0
  26. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/jobs/types.py +0 -0
  27. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/jobs/upload_job.py +0 -0
  28. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/mediainfo/__init__.py +0 -0
  29. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/mediainfo/abstract.py +0 -0
  30. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/mediainfo/audio.py +0 -0
  31. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/mediainfo/silencer.py +0 -0
  32. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/mediainfo/video.py +0 -0
  33. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scheduler/__init__.py +0 -0
  34. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scheduler/scheduler.py +0 -0
  35. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/__init__.py +0 -0
  36. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/abstract.py +0 -0
  37. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/account_selector.py +0 -0
  38. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/exceptions.py +0 -0
  39. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/fail_handler.py +0 -0
  40. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/instagram/__init__.py +0 -0
  41. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/instagram/captcha.py +0 -0
  42. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/instagram/instagram.py +0 -0
  43. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/link_resolver.py +0 -0
  44. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/utils.py +0 -0
  45. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/youtube/__init__.py +0 -0
  46. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/youtube/abstract.py +0 -0
  47. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/youtube/music.py +0 -0
  48. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/youtube/shorts.py +0 -0
  49. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/scraper/youtube/youtube.py +0 -0
  50. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/storage/__init__.py +0 -0
  51. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/storage/mongo.py +0 -0
  52. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/__init__.py +0 -0
  53. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/bot.py +0 -0
  54. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/caption_shortener.py +0 -0
  55. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/download_status.py +0 -0
  56. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/edit_message.py +0 -0
  57. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/handlers.py +0 -0
  58. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/placeholder_message.py +0 -0
  59. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/progress_bar.py +0 -0
  60. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/progress_file_reader.py +0 -0
  61. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/types.py +0 -0
  62. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/telegram/utils.py +0 -0
  63. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/uploader/__init__.py +0 -0
  64. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/warp_beacon.py +0 -0
  65. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon/yt_auth.py +0 -0
  66. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon.egg-info/SOURCES.txt +0 -0
  67. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon.egg-info/dependency_links.txt +0 -0
  68. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon.egg-info/entry_points.txt +0 -0
  69. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon.egg-info/requires.txt +0 -0
  70. {warp_beacon-2.7.16 → warp_beacon-2.7.18}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.7.16
3
+ Version: 2.7.18
4
4
  Summary: Telegram bot for expanding external media links
5
5
  Home-page: https://github.com/sb0y/warp_beacon
6
6
  Author: Andrey Bagrintsev
@@ -0,0 +1,2 @@
1
+ __version__ = "2.7.18"
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.5:
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
- #self.operations_count += 1
107
+ if random.random() > 0.4:
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
- #self.scrapler.timeline_cursor = self.scrapler.download_hndlr(self.scrapler.cl.get_timeline_feed, reason="cold_start_fetch")
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
- #self.scrapler.timeline_cursor = self.scrapler.download_hndlr(self.scrapler.cl.get_timeline_feed, reason="cold_start_fetch")
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.scrapler.timeline_cursor = self.browse_timeline()
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
- self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
155
- self.operations_count += 1
156
- self.random_pause()
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
- logging.info("Checking notifications, tags ...")
205
- self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
206
- self.operations_count += 1
207
- self.random_pause()
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
- logging.info("Checking notifications, tags ...")
307
- self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
308
- self.operations_count += 1
309
- self.random_pause()
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.7.16
3
+ Version: 2.7.18
4
4
  Summary: Telegram bot for expanding external media links
5
5
  Home-page: https://github.com/sb0y/warp_beacon
6
6
  Author: Andrey Bagrintsev
@@ -1,2 +0,0 @@
1
- __version__ = "2.7.16"
2
-
File without changes
File without changes
File without changes
File without changes
File without changes