warp-beacon 2.6.10__py3-none-any.whl → 2.6.11__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.10"
1
+ __version__ = "2.6.11"
2
2
 
@@ -78,6 +78,9 @@ class YoutubeScraper(YoutubeAbstract):
78
78
 
79
79
  video_stream = yt.streams.filter(adaptive=True, file_extension='mp4', only_video=True).order_by('resolution').desc().first()
80
80
  audio_stream = yt.streams.filter(adaptive=True, file_extension='mp4', only_audio=True).order_by('abr').desc().first()
81
+ size_in_bytes = video_stream.filesize + audio_stream.filesize
82
+ if size_in_bytes > 2147483648: # 2 GiB
83
+ video_stream = yt.streams.filter(adaptive=True, file_extension='mp4', only_video=True, res='720p').order_by('resolution').desc().first()
81
84
 
82
85
  local_video_file = video_stream.download(
83
86
  output_path=self.DOWNLOAD_DIR,
@@ -161,7 +164,30 @@ class YoutubeScraper(YoutubeAbstract):
161
164
  def _download_yt_dlp(self, url: str, thumbnail: Optional[io.BytesIO] = None, timeout: int = 60) -> list:
162
165
  res = []
163
166
  with self.build_yt_dlp(timeout) as ydl:
164
- info = ydl.extract_info(url, download=True)
167
+ info = ydl.extract_info(url, download=False)
168
+ formats = info.get('formats', [])
169
+
170
+ dl_format = {}
171
+ for f in sorted(formats, key=lambda x: (x.get('height') or 0), reverse=True):
172
+ if f.get('vcodec') != 'none' and f.get('acodec') != 'none' and f.get('ext') == 'mp4':
173
+ dl_format = f
174
+ break
175
+
176
+ filesize = dl_format.get('filesize', 0) or dl_format.get('filesize_approx', 0)
177
+ if filesize:
178
+ if filesize > 2147483648: # 2 GiB
179
+ logging.warning("Max resolution exceeding TG limits")
180
+ for f in sorted(formats, key=lambda x: (x.get('height') or 0), reverse=True):
181
+ if (f.get('vcodec') != 'none' and f.get('acodec') != 'none'
182
+ and (f.get('height') or 0) <= 720 and f.get('ext') == 'mp4'):
183
+ alt_filesize = f.get('filesize', 0) or f.get('filesize_approx', 0)
184
+ if alt_filesize: #and alt_filesize <= max_size_bytes:
185
+ dl_format = f
186
+ break
187
+ else:
188
+ logging.warning("Unknown filesize!")
189
+ ydl.params['format'] = dl_format['format_id']
190
+ ydl.download([url])
165
191
  local_file = ydl.prepare_filename(info)
166
192
  logging.debug("Temp filename: '%s'", local_file)
167
193
  res.append({
@@ -172,4 +198,4 @@ class YoutubeScraper(YoutubeAbstract):
172
198
  "media_type": JobType.VIDEO
173
199
  })
174
200
 
175
- return res
201
+ return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.6.10
3
+ Version: 2.6.11
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=SFrcGmw0WP5isDp-80uATES8jnBoMALQAAKg7kvyG5o,24
7
+ warp_beacon/__version__.py,sha256=C7jtLSU2gzphprs_5clHuXcYaQR2PmQ8amiD-k1a3zw,24
8
8
  warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,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
@@ -35,7 +35,7 @@ warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
35
35
  warp_beacon/scraper/youtube/abstract.py,sha256=QiifUOEhMMIobmBMyqgReNZ-m0sjhzhM9S0hPgiBk1s,12527
36
36
  warp_beacon/scraper/youtube/music.py,sha256=5AeSBQyUgVCJT2hoBCV2WvlyuV9US09SYJhmBG_P9F8,2755
37
37
  warp_beacon/scraper/youtube/shorts.py,sha256=1GtoYUlxAwcgSQcn80u5ehNJytH5AN5dPOicmX-XD8E,1705
38
- warp_beacon/scraper/youtube/youtube.py,sha256=ZjLv14l-ZeuJQXbZ88GbiXB276SmiGU3i8gUh6b-s60,5983
38
+ warp_beacon/scraper/youtube/youtube.py,sha256=-Ev8uhEVk8jDuqcy5_4f24JqoxBEW47wBaZVtCaKfdk,7200
39
39
  warp_beacon/storage/__init__.py,sha256=0Vajd0oITKJfu2vmNx5uQSt3-L6vwIvUYWJo8HZCjco,3398
40
40
  warp_beacon/storage/mongo.py,sha256=qC4ZiO8XXvPnP0rJwz4CJx42pqFsyAjCiW10W5QdT6E,527
41
41
  warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -45,9 +45,9 @@ warp_beacon/telegram/handlers.py,sha256=uvR6TPHSqdSxigp3wR-ewiE6t3TvVcbVLVcYGwkg
45
45
  warp_beacon/telegram/placeholder_message.py,sha256=wN9-BRiyrtHG-EvXtZkGJHt2CX71munQ57ITttjt0mw,6400
46
46
  warp_beacon/telegram/utils.py,sha256=1Lq67aRylVJzbwSyvAgjPAGjJZFATkICvAj3TJGuJiM,4635
47
47
  warp_beacon/uploader/__init__.py,sha256=e75mOcC0vrUVjrTNMQzVUTgXGdGo4J6n8t5doOnYG5I,5616
48
- warp_beacon-2.6.10.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
- warp_beacon-2.6.10.dist-info/METADATA,sha256=vnGbP5mBVoQmeOOyTv12i6eV2lWyPQVr8ls1gt-C1o8,22706
50
- warp_beacon-2.6.10.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
51
- warp_beacon-2.6.10.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
52
- warp_beacon-2.6.10.dist-info/top_level.txt,sha256=4ML0-mXsezLtRXyxQUntL_ktc5HX9npTeQWzvV8kFvA,1161
53
- warp_beacon-2.6.10.dist-info/RECORD,,
48
+ warp_beacon-2.6.11.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
49
+ warp_beacon-2.6.11.dist-info/METADATA,sha256=CJkug-SA9giMvoT7f3JBxdUczQPixtWRQBZSog5_VgY,22706
50
+ warp_beacon-2.6.11.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
51
+ warp_beacon-2.6.11.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
52
+ warp_beacon-2.6.11.dist-info/top_level.txt,sha256=4ML0-mXsezLtRXyxQUntL_ktc5HX9npTeQWzvV8kFvA,1161
53
+ warp_beacon-2.6.11.dist-info/RECORD,,