warp-beacon 2.2.14__tar.gz → 2.2.16__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.
- {warp_beacon-2.2.14/warp_beacon.egg-info → warp_beacon-2.2.16}/PKG-INFO +1 -1
- warp_beacon-2.2.16/warp_beacon/__version__.py +2 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/youtube/abstract.py +32 -2
- {warp_beacon-2.2.14 → warp_beacon-2.2.16/warp_beacon.egg-info}/PKG-INFO +1 -1
- warp_beacon-2.2.14/warp_beacon/__version__.py +0 -2
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/LICENSE +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/MANIFEST.in +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/README.md +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/assets/placeholder.gif +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/etc/.gitignore +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/etc/accounts.json +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/etc/warp_beacon.conf +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/etc/warp_beacon.service +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/pyproject.toml +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/setup.cfg +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/setup.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/compress/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/compress/video.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/jobs/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/jobs/abstract.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/jobs/download_job.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/jobs/types.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/jobs/upload_job.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/mediainfo/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/mediainfo/abstract.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/mediainfo/audio.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/mediainfo/silencer.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/mediainfo/video.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scheduler/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scheduler/scheduler.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/abstract.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/account_selector.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/exceptions.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/instagram/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/instagram/instagram.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/youtube/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/youtube/music.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/youtube/shorts.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/scraper/youtube/youtube.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/storage/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/telegram/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/telegram/bot.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/telegram/handlers.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/telegram/placeholder_message.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/telegram/utils.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/uploader/__init__.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon/warp_beacon.py +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon.egg-info/SOURCES.txt +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon.egg-info/dependency_links.txt +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon.egg-info/entry_points.txt +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon.egg-info/requires.txt +0 -0
- {warp_beacon-2.2.14 → warp_beacon-2.2.16}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
import os, io
|
2
2
|
import pathlib
|
3
3
|
import time
|
4
|
+
import math
|
4
5
|
import socket
|
5
6
|
import ssl
|
6
7
|
#from abc import abstractmethod
|
@@ -102,6 +103,34 @@ class YoutubeAbstract(ScraperAbstract):
|
|
102
103
|
if "yt_download_" in i:
|
103
104
|
os.unlink("%s/%s" % (self.DOWNLOAD_DIR, i))
|
104
105
|
|
106
|
+
def calculate_size(self, aspect_ratio_width: int, aspect_ratio_height: int, max_width: int=1280, max_height: int=1280, min_width: int=640, min_height: int=360) -> tuple:
|
107
|
+
# check ratio
|
108
|
+
aspect_ratio = aspect_ratio_width / aspect_ratio_height
|
109
|
+
|
110
|
+
# probe the max width and calculate height
|
111
|
+
width = max_width
|
112
|
+
height = int(width / aspect_ratio)
|
113
|
+
|
114
|
+
# if height exceeds max height of Telegram recalculate based on max height
|
115
|
+
if height > max_height:
|
116
|
+
height = max_height
|
117
|
+
width = int(height * aspect_ratio)
|
118
|
+
|
119
|
+
# check min sizes
|
120
|
+
if width < min_width:
|
121
|
+
width = min_width
|
122
|
+
height = int(width / aspect_ratio)
|
123
|
+
|
124
|
+
if height < min_height:
|
125
|
+
height = min_height
|
126
|
+
width = int(height * aspect_ratio)
|
127
|
+
|
128
|
+
return width, height
|
129
|
+
|
130
|
+
def aspect_ratio(self, size: tuple) -> tuple:
|
131
|
+
gcd = math.gcd(size[0], size[1])
|
132
|
+
return size[0] // gcd, size[1] // gcd
|
133
|
+
|
105
134
|
def download_thumbnail(self, video_id: str, timeout: int) -> Optional[io.BytesIO]:
|
106
135
|
for i in ("https://img.youtube.com/vi/{VIDEO_ID}/maxresdefault.jpg",
|
107
136
|
"https://img.youtube.com/vi/{VIDEO_ID}/hqdefault.jpg",
|
@@ -111,9 +140,10 @@ class YoutubeAbstract(ScraperAbstract):
|
|
111
140
|
logging.info("Youtube thumbnail url '%s'", url)
|
112
141
|
with requests.get(url, timeout=(timeout, timeout)) as response:
|
113
142
|
if response.status_code == 200:
|
114
|
-
desired_size = (320, 180)
|
115
|
-
new_image = Image.new("RGB", desired_size, (255, 255, 255))
|
116
143
|
image = Image.open(io.BytesIO(response.content))
|
144
|
+
ratio = self.aspect_ratio(image.size)
|
145
|
+
desired_size = self.calculate_size(ratio[0], ratio[1])
|
146
|
+
new_image = Image.new("RGB", desired_size, (255, 255, 255))
|
117
147
|
image = MediaInfoAbstract.shrink_image_to_fit(image, size=desired_size)
|
118
148
|
image_position = (
|
119
149
|
(desired_size[0] - image.size[0]) // 2,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|