warp-beacon 2.6.87__py3-none-any.whl → 2.6.88__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.
@@ -1,2 +1,2 @@
1
- __version__ = "2.6.87"
1
+ __version__ = "2.6.88"
2
2
 
@@ -17,7 +17,9 @@ class InstagramHuman(object):
17
17
  self.operations_count = 0
18
18
 
19
19
  def watch_content(self, media: list) -> None:
20
- for m in media[:random.randint(1, 15)]:
20
+ if not media:
21
+ return
22
+ for m in media[:random.randint(1, len(media))]:
21
23
  try:
22
24
  logging.info("Wathing content with pk '%s'", str(m.pk))
23
25
  content = self.scrapler.cl.media_info_v1(m.pk)
@@ -30,7 +32,7 @@ class InstagramHuman(object):
30
32
 
31
33
  def scroll_content(self, last_pk: int) -> None:
32
34
  timeline_initialized = False
33
- if random.random() > 0.7:
35
+ if random.random() > 0.5:
34
36
  timeline_initialized = True
35
37
  self.scrapler.timeline_cursor = self.scrapler.download_hndlr(self.scrapler.cl.get_timeline_feed, reason="cold_start_fetch")
36
38
  logging.info("Starting to watch related reels with media_pk '%d'", last_pk)
@@ -38,7 +40,7 @@ class InstagramHuman(object):
38
40
  self.operations_count += 1
39
41
  self.watch_content(media)
40
42
 
41
- if random.random() > 0.9:
43
+ if random.random() > 0.7:
42
44
  time.sleep(random.uniform(2, 20))
43
45
  if not timeline_initialized:
44
46
  self.scrapler.timeline_cursor = self.scrapler.download_hndlr(self.scrapler.cl.get_timeline_feed, reason="cold_start_fetch")
@@ -75,7 +77,7 @@ class InstagramHuman(object):
75
77
  self.scrapler.download_hndlr(self.scrapler.cl.notification_like_and_comment_on_photo_user_tagged, "everyone")
76
78
  self.operations_count += 1
77
79
  self.random_pause()
78
- if random.random() > 0.5:
80
+ if random.random() > 0.2:
79
81
  logging.info("Simulation updating reels tray feed ...")
80
82
  self.scrapler.download_hndlr(self.scrapler.cl.get_reels_tray_feed, "pull_to_refresh")
81
83
  self.operations_count += 1
@@ -98,7 +100,7 @@ class InstagramHuman(object):
98
100
  self.random_pause()
99
101
  if random.random() > 0.4:
100
102
  logging.info("Watching reels ...")
101
- reels = self.scrapler.download_hndlr(self.scrapler.cl.reels)
103
+ reels = self.scrapler.download_hndlr(self.scrapler.cl.reels, amount=random.randint(4, 15))
102
104
  self.operations_count += 1
103
105
  self.watch_content(reels)
104
106
  self.random_pause()
@@ -126,11 +128,11 @@ class InstagramHuman(object):
126
128
  self.random_pause()
127
129
  if random.random() > 0.4:
128
130
  logging.info("Watching reels ...")
129
- reels = self.scrapler.download_hndlr(self.scrapler.cl.reels)
131
+ reels = self.scrapler.download_hndlr(self.scrapler.cl.reels, amount=random.randint(4, 15))
130
132
  self.operations_count += 1
131
133
  self.watch_content(reels)
132
134
  self.random_pause()
133
- if random.random() > 0.6:
135
+ if random.random() > 0.4:
134
136
  logging.info("Simulation profile view ...")
135
137
  self.profile_view()
136
138
  self.random_pause()
@@ -145,9 +147,9 @@ class InstagramHuman(object):
145
147
  self.scrapler.download_hndlr(self.scrapler.cl.direct_active_presence)
146
148
  self.operations_count += 1
147
149
  self.random_pause(short=True)
148
- if random.random() > 0.8:
150
+ if random.random() > 0.5:
149
151
  logging.info("Watching reels ...")
150
- reels = self.scrapler.download_hndlr(self.scrapler.cl.reels)
152
+ reels = self.scrapler.download_hndlr(self.scrapler.cl.reels, amount=random.randint(4, 15))
151
153
  self.operations_count += 1
152
154
  self.watch_content(reels)
153
155
  self.random_pause()
@@ -179,14 +181,14 @@ class InstagramHuman(object):
179
181
  #self.scrapler.download_hndlr(self.scrapler.cl.user_info, target_user_id)
180
182
  self.scrapler.download_hndlr(self.scrapler.cl.user_info_v1, target_user_id)
181
183
  self.operations_count += 1
182
- time.sleep(random.uniform(2, 5))
184
+ self.random_pause()
183
185
  elif isinstance(random_friend, str):
184
186
  target_user_id = self.scrapler.download_hndlr(self.scrapler.cl.user_id_from_username, random_friend)
185
187
  logging.info("user_info with target_user_id = '%s' ...", target_user_id)
186
188
  #self.scrapler.download_hndlr(self.scrapler.cl.user_info, target_user_id)
187
189
  self.scrapler.download_hndlr(self.scrapler.cl.user_info_v1, target_user_id)
188
190
  self.operations_count += 1
189
- time.sleep(random.uniform(2, 5))
191
+ self.random_pause()
190
192
 
191
193
  if random.random() > 0.5:
192
194
  logging.info("Checking direct ...")
@@ -202,7 +204,7 @@ class InstagramHuman(object):
202
204
 
203
205
  if random.random() > 0.5:
204
206
  logging.info("user_medias with target_user_id = '%s' ...", target_user_id)
205
- self.scrapler.download_hndlr(self.scrapler.cl.user_medias_v1, target_user_id, amount=random.randint(1, 5))
207
+ self.scrapler.download_hndlr(self.scrapler.cl.user_medias_v1, target_user_id, amount=random.randint(1, 10))
206
208
  self.operations_count += 1
207
209
  self.random_pause()
208
210
  except Exception as e:
@@ -126,7 +126,7 @@ class IGScheduler(object):
126
126
 
127
127
  def handle_time_planning(self) -> None:
128
128
  if int(self.state.get("remaining", 0)) <= 0:
129
- self.state["remaining"] = randrange(9292, 26200)
129
+ self.state["remaining"] = randrange(5292, 12253)
130
130
 
131
131
  def do_work(self) -> None:
132
132
  logging.info("Scheduler thread started ...")
@@ -130,7 +130,7 @@ class AsyncDownloader(object):
130
130
  proxy = selector.get_current_proxy()
131
131
  if job.job_origin is Origin.INSTAGRAM:
132
132
  from warp_beacon.scraper.instagram.instagram import InstagramScraper
133
- if not job.scroll_content and selector.get_ig_request_count() >= int(os.environ.get("IG_REQUESTS_PER_ACCOUNT", default="10")):
133
+ if not job.scroll_content and selector.get_ig_request_count() >= int(os.environ.get("IG_REQUESTS_PER_ACCOUNT", default="20")):
134
134
  logging.info("The account request limit has been reached. Selecting the next account.")
135
135
  selector.reset_ig_request_count()
136
136
  selector.next()
@@ -164,7 +164,7 @@ class AsyncDownloader(object):
164
164
  break
165
165
  if job.session_validation and job.job_origin in (Origin.INSTAGRAM, Origin.YOUTUBE):
166
166
  if job.job_origin is Origin.INSTAGRAM:
167
- if selector.get_ig_request_count() >= int(os.environ.get("IG_REQUESTS_PER_ACCOUNT", default="10")):
167
+ if selector.get_ig_request_count() >= int(os.environ.get("IG_REQUESTS_PER_ACCOUNT", default="20")):
168
168
  logging.info("The account request limit has been reached. Selecting the next account.")
169
169
  selector.reset_ig_request_count()
170
170
  selector.next()
@@ -4,10 +4,10 @@ from fake_useragent import UserAgent
4
4
 
5
5
  class ScraperUtils(object):
6
6
  @staticmethod
7
- def get_ua_dict() -> dict:
7
+ def get_ua_dict(browsers: list = ['Facebook', 'Android'], platforms: list = ['mobile', 'tablet'], os: list =['Android', 'iOS']) -> dict:
8
8
  random_client = None
9
9
  try:
10
- ua = UserAgent(browsers=['Facebook', 'Android'], platforms=['mobile', 'tablet'], os=['Android', 'iOS'])
10
+ ua = UserAgent(browsers=browsers, platforms=platforms, os=os)
11
11
  random_client = ua.getRandom
12
12
  logging.info("Select random UA: %s", random_client)
13
13
  except Exception as e:
@@ -16,5 +16,5 @@ class ScraperUtils(object):
16
16
  return random_client
17
17
 
18
18
  @staticmethod
19
- def get_ua() -> str:
20
- return ScraperUtils.get_ua_dict()["useragent"]
19
+ def get_ua(browsers: list = ['Facebook', 'Android'], platforms: list = ['mobile', 'tablet'], os: list =['Android', 'iOS']) -> str:
20
+ return ScraperUtils.get_ua_dict(browsers=browsers, platforms=platforms, os=os)["useragent"]
@@ -29,6 +29,7 @@ from warp_beacon.scraper.abstract import ScraperAbstract
29
29
  from warp_beacon.scraper.exceptions import (BadProxy, TimeOut, Unavailable,
30
30
  extract_exception_message)
31
31
  from warp_beacon.yt_auth import YtAuth
32
+ from warp_beacon.scraper.utils import ScraperUtils
32
33
 
33
34
  class YoutubeAbstract(ScraperAbstract):
34
35
  DOWNLOAD_DIR = "/tmp"
@@ -226,7 +227,10 @@ class YoutubeAbstract(ScraperAbstract):
226
227
  return ret_val
227
228
 
228
229
  def yt_on_progress(self, stream: Stream, chunk: bytes, bytes_remaining: int) -> None:
229
- total_size = stream.filesize or stream.filesize_approx
230
+ total_size = int(stream.filesize or stream.filesize_approx or 0)
231
+ if not total_size:
232
+ logging.warning("[Download worker]: total_size is '%d'", total_size)
233
+ return
230
234
  bytes_downloaded = total_size - bytes_remaining
231
235
  percentage_of_completion = bytes_downloaded / (total_size or 1) * 100
232
236
  if total_size == 0 or percentage_of_completion >= self._download_progress_threshold:
@@ -286,6 +290,28 @@ class YoutubeAbstract(ScraperAbstract):
286
290
  yt_opts["proxies"] = self.build_proxies(proxy_dsn)
287
291
  return YouTube(**yt_opts)
288
292
 
293
+ def yt_dlp_on_progress(self, params: dict) -> None:
294
+ if params.get("status", "") == "downloading":
295
+ total_size = int(params.get("total_bytes") or params.get("total_bytes_estimate") or 0)
296
+ if not total_size or total_size < 0:
297
+ logging.warning("[Download worker][yt_dlp]: total_size is '%d'", total_size)
298
+ return
299
+ bytes_downloaded = int(params.get("downloaded_bytes", 0))
300
+ percentage_of_completion = bytes_downloaded / (total_size or 1) * 100
301
+ if total_size == 0 or percentage_of_completion >= self._download_progress_threshold:
302
+ msg = {
303
+ "action": "report_download_status",
304
+ "current": bytes_downloaded,
305
+ "total": total_size,
306
+ "message_id": self.job.placeholder_message_id,
307
+ "chat_id": self.job.chat_id,
308
+ "completed": percentage_of_completion >= 100
309
+ }
310
+ self.status_pipe.send(msg)
311
+ logging.debug("[Download worker][yt_dlp] Downloaded %d%%", percentage_of_completion)
312
+ if total_size > 0:
313
+ self._download_progress_threshold += 20
314
+
289
315
  def build_yt_dlp(self, timeout: int = 60) -> yt_dlp.YoutubeDL:
290
316
  auth_data = {}
291
317
  with open(self.YT_SESSION_FILE % self.account_index, 'r', encoding="utf-8") as f:
@@ -297,9 +323,24 @@ class YoutubeAbstract(ScraperAbstract):
297
323
  'format': 'bestvideo+bestaudio/best',
298
324
  'merge_output_format': 'mp4',
299
325
  'noplaylist': True,
300
- 'tv_auth': auth_data
326
+ 'progress_hooks': [self.yt_dlp_on_progress],
327
+ 'http_headers': {
328
+ "Accept-Language": "en-US,en;q=0.9",
329
+ 'User-Agent': ScraperUtils.get_ua(
330
+ browsers=["Google", "Chrome", "Firefox"],
331
+ os=["Windows", "Linux", "Ubuntu", "Chrome OS", "Mac OS X"],
332
+ platforms=["desktop"]
333
+ )
334
+ }
301
335
  }
302
336
 
337
+ if auth_data and auth_data.get("access_token", None):
338
+ ydl_opts["http_headers"]["Authorization"] = f'Bearer {auth_data["access_token"]}'
339
+
340
+ yt_dlp_cookies_file = os.environ.get("YT_DLP_COOKIES_FILE", default="/var/warp_beacon/yt_dlp_cookies.txt")
341
+ if yt_dlp_cookies_file and os.path.exists(yt_dlp_cookies_file):
342
+ ydl_opts['cookiefile'] = yt_dlp_cookies_file
343
+
303
344
  if self.proxy:
304
345
  proxy_dsn = self.proxy.get("dsn", "")
305
346
  logging.info("Using proxy DSN '%s'", proxy_dsn)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.87
3
+ Version: 2.6.88
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
@@ -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=FgjYXoAFmDQi-ZsqKjg6shGTSafYxf_8wotLCLckBXA,24
7
+ warp_beacon/__version__.py,sha256=LBpQqsZ-TT6c9n00IAHECMU-8pg2jKcbCReuRuJTohg,24
8
8
  warp_beacon/warp_beacon.py,sha256=ED43vNzdjDUJ_9qLCbri0bjWLWEJ69BENGj9i7G6AvM,342
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,21 +20,21 @@ 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=4Cik8bX9QYb3rtJ51matR78xxg8mXpaO9d5tGYVsIlE,8208
24
- warp_beacon/scheduler/scheduler.py,sha256=cr3oKANu_iOw4vCLzr8Mh0HdZIqYx3I8i4ohfoQkw2U,4995
25
- warp_beacon/scraper/__init__.py,sha256=2-h_HGb7Gp5H2-qyfONaubTOv1lzR4SWfjLV7iX9cP0,20103
23
+ warp_beacon/scheduler/instagram_human.py,sha256=JF5K8jgdwW0ncpKsEAj2yWMP9Y40kKgCM_i3HoHwNnM,8307
24
+ warp_beacon/scheduler/scheduler.py,sha256=Bf4sGXjX75Dox3q-yzUHhagtzUAj3hl5GzfnZya-_io,4995
25
+ warp_beacon/scraper/__init__.py,sha256=a-nnFAPvXtmJFQJOEbN2UL92FllK_7NTPM3Yoz_hYjk,20103
26
26
  warp_beacon/scraper/abstract.py,sha256=_Cr_MaSQ56Wp6n00PcqiM2WDa5DlRKXUnQ9C15bPObw,3692
27
27
  warp_beacon/scraper/account_selector.py,sha256=VmXH8SHZqQ6a2mrt2agzDWepE3v46QrFLL3OqVwJ2A4,9731
28
28
  warp_beacon/scraper/exceptions.py,sha256=EKwoF0oH2xZWbNU-v8DOaWK5skKwa3s1yTIBdlcfMpc,1452
29
29
  warp_beacon/scraper/fail_handler.py,sha256=zcPK3ZVEsu6JmHYcWP7L3naTRK3gWFVRkpP84VBOtJs,964
30
30
  warp_beacon/scraper/link_resolver.py,sha256=Rc9ZuMyOo3iPywDHwjngy-WRQ2SXhJwxcg-5ripx7tM,2447
31
- warp_beacon/scraper/utils.py,sha256=fEqKFlWkZTyThU1rokvMEHIVdc8bk70kCWo5LPvnZYE,1045
31
+ warp_beacon/scraper/utils.py,sha256=Kk_lDmdJiCSaHmOV80OFK05O1wRL2H0agH98JiO8dyg,1268
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=64XxGui7bPuiJT-Hqlg1KQT9GsbX1YMXzEUJdzvkxLQ,17141
35
35
  warp_beacon/scraper/instagram/wb_instagrapi.py,sha256=OECHz1eK6J5bfw2H84CdywwxBNegkNb_UhDr0MtNtZ4,5237
36
36
  warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
- warp_beacon/scraper/youtube/abstract.py,sha256=WLbQKtrKSwpZUQlpjL2XI7z8XxoRCtVxrRjSXFJmXuM,13230
37
+ warp_beacon/scraper/youtube/abstract.py,sha256=0ub4O8kNBzcrYCbMaNoNQzwE5vBdpNcSYNtxT-cBXe4,15024
38
38
  warp_beacon/scraper/youtube/music.py,sha256=5AeSBQyUgVCJT2hoBCV2WvlyuV9US09SYJhmBG_P9F8,2755
39
39
  warp_beacon/scraper/youtube/shorts.py,sha256=1GtoYUlxAwcgSQcn80u5ehNJytH5AN5dPOicmX-XD8E,1705
40
40
  warp_beacon/scraper/youtube/youtube.py,sha256=x9v9p1coA9TvBhxjNAofGu4UBkAEdYPE2ePRnU-5tK0,7233
@@ -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=1Lq67aRylVJzbwSyvAgjPAGjJZFATkICvAj3TJGuJiM,4635
54
54
  warp_beacon/uploader/__init__.py,sha256=j3qcuKhpchseZLGzSsSiogqe6WdMbkK8d3I-ConhNRs,5687
55
- warp_beacon-2.6.87.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
- warp_beacon-2.6.87.dist-info/METADATA,sha256=d99T_Qpshl5vd8q5Ikhz44db0tH5b8Lpe4fLaxoTR4o,22736
57
- warp_beacon-2.6.87.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
58
- warp_beacon-2.6.87.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
59
- warp_beacon-2.6.87.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
60
- warp_beacon-2.6.87.dist-info/RECORD,,
55
+ warp_beacon-2.6.88.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ warp_beacon-2.6.88.dist-info/METADATA,sha256=pdq3qKn6nykzvnMC11AcwO_KgOcGOglLGEsTGVXKmV4,22736
57
+ warp_beacon-2.6.88.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
58
+ warp_beacon-2.6.88.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
59
+ warp_beacon-2.6.88.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
60
+ warp_beacon-2.6.88.dist-info/RECORD,,