warp-beacon 2.6.83__py3-none-any.whl → 2.6.84__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.83"
1
+ __version__ = "2.6.84"
2
2
 
@@ -13,13 +13,13 @@ import warp_beacon
13
13
  class IGScheduler(object):
14
14
  state_file = "/var/warp_beacon/scheduler_state.json"
15
15
  yt_sessions_dir = "/var/warp_beacon"
16
- downloader = None
17
- running = True
18
- thread = None
19
- event = None
20
- state = {"remaining": randrange(8400, 26200), "yt_sess_exp": []}
21
16
 
22
17
  def __init__(self, downloader: warp_beacon.scraper.AsyncDownloader) -> None:
18
+ self.downloader = None
19
+ self.running = True
20
+ self.thread = None
21
+ self.event = None
22
+ self.state = {"remaining": randrange(8400, 26200), "yt_sess_exp": []}
23
23
  self.downloader = downloader
24
24
  self.event = threading.Event()
25
25
  self.handle_time_planning()
@@ -37,9 +37,7 @@ class IGScheduler(object):
37
37
 
38
38
  def load_yt_sessions(self) -> None:
39
39
  try:
40
- # old versions migration
41
- if not "yt_sess_exp" in self.state:
42
- self.state["yt_sess_exp"] = []
40
+ self.state["yt_sess_exp"] = []
43
41
 
44
42
  for f in os.listdir(self.yt_sessions_dir):
45
43
  if f.startswith("yt_session") and f.endswith(".json"):
@@ -134,6 +132,7 @@ class IGScheduler(object):
134
132
  self.load_state()
135
133
  while self.running:
136
134
  try:
135
+ self.load_yt_sessions()
137
136
  yt_expires = self.yt_nearest_expire()
138
137
  ig_sched = self.state["remaining"]
139
138
  min_val = min(yt_expires, ig_sched)
@@ -43,7 +43,19 @@ class WBClient(Client):
43
43
  raise TypeError("Progress callback must be callable")
44
44
  self.progress_callback = callback
45
45
 
46
+ def adaptive_chunk_size(self, content_length: int) -> int:
47
+ if content_length < 100_000:
48
+ return 2048
49
+ elif content_length < 5_000_000:
50
+ return 8192
51
+ elif content_length < 100_000_000:
52
+ return 32768
53
+ else:
54
+ return 65536
55
+
46
56
  def sanitize_instagram_url(self, url: str) -> str:
57
+ if "oh=" in url: # signed url, do not touch
58
+ return url
47
59
  parsed = urlparse(url)
48
60
  query = parse_qs(parsed.query)
49
61
  filtered_query = {k: v for k, v in query.items() if k in self.essential_params}
@@ -51,7 +63,7 @@ class WBClient(Client):
51
63
  return urlunparse(parsed._replace(query=new_query))
52
64
 
53
65
  def video_download_by_url(self, url: str, filename: str = "", folder: Path = "") -> Path:
54
- #url = self.sanitize_instagram_url(url)
66
+ url = self.sanitize_instagram_url(url)
55
67
  fname = urlparse(url).path.rsplit("/", 1)[1]
56
68
  filename = f"{filename}.{fname.rsplit('.', 1)[1]}" if filename else fname
57
69
  path = Path(folder or Path.cwd()) / filename
@@ -78,7 +90,7 @@ class WBClient(Client):
78
90
 
79
91
  downloaded = 0
80
92
  with open(path, "wb") as f:
81
- for chunk in response.iter_content(chunk_size=8192):
93
+ for chunk in response.iter_content(chunk_size=self.adaptive_chunk_size(content_length)):
82
94
  if chunk:
83
95
  f.write(chunk)
84
96
  downloaded += len(chunk)
@@ -103,7 +115,7 @@ class WBClient(Client):
103
115
  def photo_download_by_url(
104
116
  self, url: str, filename: str = "", folder: Path = ""
105
117
  ) -> Path:
106
- #url = self.sanitize_instagram_url(url)
118
+ url = self.sanitize_instagram_url(url)
107
119
  fname = urlparse(url).path.rsplit("/", 1)[1]
108
120
  filename = f"{filename}.{(filename, fname.rsplit('.', 1)[1]) if filename else fname}"
109
121
  path = Path(folder) / filename
@@ -136,7 +148,7 @@ class WBClient(Client):
136
148
  downloaded = 0
137
149
  with open(path, "wb") as f:
138
150
  response.raw.decode_content = True
139
- for chunk in response.iter_content(chunk_size=4096):
151
+ for chunk in response.iter_content(chunk_size=self.adaptive_chunk_size(content_length)):
140
152
  if chunk:
141
153
  f.write(chunk)
142
154
  downloaded += len(chunk)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.83
3
+ Version: 2.6.84
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=JhRCYkX8KEsqFL6rDZYJKbIdOmCFlKJ-h03RpsX_Mrs,24
7
+ warp_beacon/__version__.py,sha256=sVfzhpFl0Ti_WQWBe-4XO6fhB_2n-4RIx64CMN0X7PY,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
@@ -21,7 +21,7 @@ warp_beacon/mediainfo/silencer.py,sha256=qxMuViOoVwUYb60uCVvqHiGrqByR1_4_rqMT-Xd
21
21
  warp_beacon/mediainfo/video.py,sha256=UBZrhTN5IDI-aYu6tsJEILo9nFkjHhkldGVFmvV7tEI,2480
22
22
  warp_beacon/scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  warp_beacon/scheduler/instagram_human.py,sha256=Li8R8Fm9sZCXCJnS4RrQnQJTsPlBPENQowRe_23Bu-Y,8207
24
- warp_beacon/scheduler/scheduler.py,sha256=9OCh7Ta4wY_aTHGAOOZmaKXg56Ftx1N_aV1g6E3ZLKA,4941
24
+ warp_beacon/scheduler/scheduler.py,sha256=C-19tIb6iiHfboKNPDjg9tzhJQ3mNEbHywW9foe7nKw,4931
25
25
  warp_beacon/scraper/__init__.py,sha256=buXmGcJnwCi0qGZAh3srcSbww0XvKyTACp_DW11e86Q,20225
26
26
  warp_beacon/scraper/abstract.py,sha256=hRyBbdZ5HK7QyyXlbFAgk3FZe2SIil0WBZ9vJziZv_s,3554
27
27
  warp_beacon/scraper/account_selector.py,sha256=VmXH8SHZqQ6a2mrt2agzDWepE3v46QrFLL3OqVwJ2A4,9731
@@ -32,7 +32,7 @@ warp_beacon/scraper/utils.py,sha256=xJfCVhiLjVPoFVupE10sTzX7UpgNWbx2EeYIsoYXGDk,
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=3KhxVQSL3lzovu9hjMA83sCv87u4TTDMfDQrxogoWak,17179
35
- warp_beacon/scraper/instagram/wb_instagrapi.py,sha256=QJtJ2Gn0fpnWwisOMB2vkMunhTil-rOW7MREr5hOWXI,4924
35
+ warp_beacon/scraper/instagram/wb_instagrapi.py,sha256=Dh0SlCZcrgLC4IsIqKUV3xszQXKlrdsll0nCAxoiXHI,5289
36
36
  warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  warp_beacon/scraper/youtube/abstract.py,sha256=K2ovycq1lkx0a2R1FddO3B0IcaVsVzni_fdXzajGdwg,13134
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=1Lq67aRylVJzbwSyvAgjPAGjJZFATkICvAj3TJGuJiM,4635
54
54
  warp_beacon/uploader/__init__.py,sha256=j3qcuKhpchseZLGzSsSiogqe6WdMbkK8d3I-ConhNRs,5687
55
- warp_beacon-2.6.83.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
- warp_beacon-2.6.83.dist-info/METADATA,sha256=CPtZD6nUsf73ZOgq4xsxIXYc0VGtSgXeolQ1A4OXLtc,22706
57
- warp_beacon-2.6.83.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
58
- warp_beacon-2.6.83.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
59
- warp_beacon-2.6.83.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
60
- warp_beacon-2.6.83.dist-info/RECORD,,
55
+ warp_beacon-2.6.84.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
56
+ warp_beacon-2.6.84.dist-info/METADATA,sha256=h1DIdxgSyWRQ3H2kNwxfugeIvva3rCmBz_JW1VFlpwg,22706
57
+ warp_beacon-2.6.84.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
58
+ warp_beacon-2.6.84.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
59
+ warp_beacon-2.6.84.dist-info/top_level.txt,sha256=5YQRN46STNg81V_3jdzZ6bftkMxhe1hTPSFvJugDu84,1405
60
+ warp_beacon-2.6.84.dist-info/RECORD,,