warp-beacon 2.2.11__py3-none-any.whl → 2.2.12__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.2.11"
1
+ __version__ = "2.2.12"
2
2
 
@@ -7,7 +7,7 @@ import ssl
7
7
  from typing import Callable, Union, Optional
8
8
  import json
9
9
  import urllib
10
- import urllib.request
10
+ import requests
11
11
  import http.client
12
12
  from PIL import Image
13
13
 
@@ -102,19 +102,23 @@ class YoutubeAbstract(ScraperAbstract):
102
102
  if "yt_download_" in i:
103
103
  os.unlink("%s/%s" % (self.DOWNLOAD_DIR, i))
104
104
 
105
- def download_thumbnail(self, url: str, timeout: int) -> Optional[io.BytesIO]:
106
- try:
107
- logging.info("Youtube thumbnail url '%s'", url)
108
- with urllib.request.urlopen(url, timeout=timeout) as f:
109
- image = Image.open(io.BytesIO(f.read()))
110
- image = MediaInfoAbstract.shrink_image_to_fit(image, size=(320, 240))
111
- io_buf = io.BytesIO()
112
- image.save(io_buf, format='JPEG', subsampling=0, quality=100, progressive=True, optimize=False, icc_profile=image.info.get('icc_profile'))
113
- io_buf.seek(0)
114
- return io_buf
115
- except Exception as e:
116
- logging.error("Failed to download download thumbnail!")
117
- logging.exception(e)
105
+ def download_thumbnail(self, video_id: str, timeout: int) -> Optional[io.BytesIO]:
106
+ for i in ("https://img.youtube.com/vi/{VIDEO_ID}/maxresdefault.jpg",
107
+ "https://img.youtube.com/vi/{VIDEO_ID}/hqdefault.jpg",
108
+ "https://img.youtube.com/vi/{VIDEO_ID}/sddefault.jpg"):
109
+ try:
110
+ url = i.format(VIDEO_ID=video_id)
111
+ logging.info("Youtube thumbnail url '%s'", url)
112
+ with requests.get(url, timeout=(timeout, timeout)) as response:
113
+ image = Image.open(io.BytesIO(response.content))
114
+ image = MediaInfoAbstract.shrink_image_to_fit(image, size=(320, 180))
115
+ io_buf = io.BytesIO()
116
+ image.save(io_buf, format='JPEG', subsampling=0, quality=100, progressive=True, optimize=False, icc_profile=image.info.get('icc_profile'))
117
+ io_buf.seek(0)
118
+ return io_buf
119
+ except Exception as e:
120
+ logging.error("Failed to download download thumbnail!")
121
+ logging.exception(e)
118
122
 
119
123
  return None
120
124
 
@@ -1,6 +1,6 @@
1
1
  from warp_beacon.jobs.types import JobType
2
2
  from warp_beacon.scraper.youtube.abstract import YoutubeAbstract
3
- from warp_beacon.scraper.exceptions import NotFound
3
+ from warp_beacon.scraper.exceptions import NotFound, FileTooBig
4
4
 
5
5
  import logging
6
6
 
@@ -15,8 +15,8 @@ class YoutubeMusicScraper(YoutubeAbstract):
15
15
  thumbnail = None
16
16
  yt = self.build_yt(url)
17
17
 
18
- if yt and yt.thumbnail_url:
19
- thumbnail = self._download_hndlr(self.download_thumbnail, yt.thumbnail_url)
18
+ if yt:
19
+ thumbnail = self._download_hndlr(self.download_thumbnail, yt.video_id)
20
20
 
21
21
  stream = yt.streams.get_audio_only()
22
22
 
@@ -19,8 +19,8 @@ class YoutubeShortsScraper(YoutubeAbstract):
19
19
  if not stream:
20
20
  raise NotFound("No suitable video stream found")
21
21
 
22
- if yt and yt.thumbnail_url:
23
- thumbnail = self._download_hndlr(self.download_thumbnail, yt.thumbnail_url)
22
+ if yt:
23
+ thumbnail = self._download_hndlr(self.download_thumbnail, yt.video_id)
24
24
 
25
25
  local_file = stream.download(
26
26
  output_path=self.DOWNLOAD_DIR,
@@ -37,8 +37,8 @@ class YoutubeScraper(YoutubeAbstract):
37
37
  if self.is_live(yt.initial_data):
38
38
  raise YotubeLiveError("Youtube Live is not supported")
39
39
 
40
- if yt and yt.thumbnail_url:
41
- thumbnail = self._download_hndlr(self.download_thumbnail, yt.thumbnail_url)
40
+ if yt:
41
+ thumbnail = self._download_hndlr(self.download_thumbnail, yt.video_id)
42
42
 
43
43
  stream = yt.streams.get_highest_resolution()
44
44
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: warp_beacon
3
- Version: 2.2.11
3
+ Version: 2.2.12
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
@@ -3,7 +3,7 @@ lib/systemd/system/warp_beacon.service,sha256=lPmHqLqcI2eIV7nwHS0qcALQrznixqJuww
3
3
  var/warp_beacon/accounts.json,sha256=rKFQM_b9eoDS4mJ1B_SZNolPLXx1SQdQMdY2F_ZcBt8,1523
4
4
  var/warp_beacon/placeholder.gif,sha256=cE5CGJVaop4Sx21zx6j4AyoHU0ncmvQuS2o6hJfEH88,6064
5
5
  warp_beacon/__init__.py,sha256=_rThNODmz0nDp_n4mWo_HKaNFE5jk1_7cRhHyYaencI,163
6
- warp_beacon/__version__.py,sha256=aUbdyFfi_4ESHpZeMAdC3w7P2YbNirARoYoYvf5I8tY,24
6
+ warp_beacon/__version__.py,sha256=hDIJ_Fs0qeKWVPqLmverl05BYiTpkbCtWQI3bEWOBRs,24
7
7
  warp_beacon/warp_beacon.py,sha256=7KEtZDj-pdhtl6m-zFLsSojs1ZR4o7L0xbqtdmYPvfE,342
8
8
  warp_beacon/compress/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  warp_beacon/compress/video.py,sha256=_PDMVYCyzLYxHv1uZmmzGcG_8rjaZr7BTXsXTTy_oS4,2846
@@ -26,10 +26,10 @@ warp_beacon/scraper/exceptions.py,sha256=lHsPrYy5iYnHsIdUHqRxZmzlqrkNj_TS4TkiTJf
26
26
  warp_beacon/scraper/instagram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  warp_beacon/scraper/instagram/instagram.py,sha256=iT66IM7nsbVDWQzBW-CJUWDBjoBbRZH4BHx6TJw3oqo,13517
28
28
  warp_beacon/scraper/youtube/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
- warp_beacon/scraper/youtube/abstract.py,sha256=H04KDpO5RWBvFX7BxQ3U4jeiQnkpfADHdaRtfsk13pk,6170
30
- warp_beacon/scraper/youtube/music.py,sha256=8TguqXc1BC9Slp09BzCU8dtQ6BnyKwzZSLLFHpqDHtg,1498
31
- warp_beacon/scraper/youtube/shorts.py,sha256=pHfvEBau8Zp7Ar3LBuPmjqYq8fmjJUQvzeZXujQMpG4,1203
32
- warp_beacon/scraper/youtube/youtube.py,sha256=K98n2TSJaDZt-xT7mADZL1UEf2exIYm0Wnenn2GAYfI,2250
29
+ warp_beacon/scraper/youtube/abstract.py,sha256=SwoO5GnBJ7NHQKSLu_qwi0Gh0ATcbqb-YO9reqCnV4E,6425
30
+ warp_beacon/scraper/youtube/music.py,sha256=nbTDFdgXGbTNqttE828DEgvSc8-SuAsQAHeqUwU6yFM,1484
31
+ warp_beacon/scraper/youtube/shorts.py,sha256=RqMYDq4XHChtp-LdlxXyHej4h3NI3Qi9T8USxwk-pIk,1177
32
+ warp_beacon/scraper/youtube/youtube.py,sha256=JvN5pVz0jtxCY9FGMl1dIg5Ccr2Kulaoxtym0Vb1QwQ,2224
33
33
  warp_beacon/storage/__init__.py,sha256=m86MDXBMtZZsTPLI2cD-pM5Xkh2g2NYVvp_dtW8eH0Q,3548
34
34
  warp_beacon/telegram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  warp_beacon/telegram/bot.py,sha256=EOfqhAZN_LDgjJrJCgIKzU1F6rd1t6dHYGmspu0OWas,15387
@@ -37,9 +37,9 @@ warp_beacon/telegram/handlers.py,sha256=xSNG_v4D4FaA5q1_5wXvJkjcDUhy5GaQnfpijJZp
37
37
  warp_beacon/telegram/placeholder_message.py,sha256=32U-R_IMPRJd-S5UwlpemLkArJOxCmO7whcynduSbMA,6418
38
38
  warp_beacon/telegram/utils.py,sha256=CeWXMwyzv2l4Af6I-wW2ySU490c-5k82sBhkjabv0n4,2452
39
39
  warp_beacon/uploader/__init__.py,sha256=rsUkzzmtaeQY-kNkcIiPsrayS9idFKY3hBC71mR19XE,4743
40
- warp_beacon-2.2.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
- warp_beacon-2.2.11.dist-info/METADATA,sha256=9E-tsvgS-txck4R0L-qXn2OAnsVIr_sCNGV6t0M93Dc,21251
42
- warp_beacon-2.2.11.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
43
- warp_beacon-2.2.11.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
44
- warp_beacon-2.2.11.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
45
- warp_beacon-2.2.11.dist-info/RECORD,,
40
+ warp_beacon-2.2.12.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
41
+ warp_beacon-2.2.12.dist-info/METADATA,sha256=ZpGFn4PB3SpYf745fbI1qu0gl8A3-0cq32ZpP5Woa7M,21251
42
+ warp_beacon-2.2.12.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
43
+ warp_beacon-2.2.12.dist-info/entry_points.txt,sha256=eSB61Rb89d56WY0O-vEIQwkn18J-4CMrJcLA_R_8h3g,119
44
+ warp_beacon-2.2.12.dist-info/top_level.txt,sha256=ALb_Ft_eG-OY4_m0TWUifNUOZsrx483L-zw7G7vqXoc,971
45
+ warp_beacon-2.2.12.dist-info/RECORD,,