warp-beacon 2.2.13__tar.gz → 2.2.15__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.13/warp_beacon.egg-info → warp_beacon-2.2.15}/PKG-INFO +1 -1
- warp_beacon-2.2.15/warp_beacon/__version__.py +2 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/youtube/abstract.py +40 -3
- {warp_beacon-2.2.13 → warp_beacon-2.2.15/warp_beacon.egg-info}/PKG-INFO +1 -1
- warp_beacon-2.2.13/warp_beacon/__version__.py +0 -2
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/LICENSE +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/MANIFEST.in +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/README.md +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/assets/placeholder.gif +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/etc/.gitignore +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/etc/accounts.json +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/etc/warp_beacon.conf +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/etc/warp_beacon.service +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/pyproject.toml +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/setup.cfg +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/setup.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/compress/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/compress/video.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/jobs/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/jobs/abstract.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/jobs/download_job.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/jobs/types.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/jobs/upload_job.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/mediainfo/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/mediainfo/abstract.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/mediainfo/audio.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/mediainfo/silencer.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/mediainfo/video.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scheduler/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scheduler/scheduler.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/abstract.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/account_selector.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/exceptions.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/instagram/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/instagram/instagram.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/youtube/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/youtube/music.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/youtube/shorts.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/scraper/youtube/youtube.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/storage/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/telegram/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/telegram/bot.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/telegram/handlers.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/telegram/placeholder_message.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/telegram/utils.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/uploader/__init__.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon/warp_beacon.py +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon.egg-info/SOURCES.txt +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon.egg-info/dependency_links.txt +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon.egg-info/entry_points.txt +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/warp_beacon.egg-info/requires.txt +0 -0
- {warp_beacon-2.2.13 → warp_beacon-2.2.15}/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
|
@@ -9,7 +10,7 @@ import json
|
|
9
10
|
import urllib
|
10
11
|
import requests
|
11
12
|
import http.client
|
12
|
-
from PIL import Image
|
13
|
+
from PIL import Image, ImageOps
|
13
14
|
|
14
15
|
from warp_beacon.scraper.abstract import ScraperAbstract
|
15
16
|
from warp_beacon.mediainfo.abstract import MediaInfoAbstract
|
@@ -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=320, min_height: int=320) -> 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",
|
@@ -112,9 +141,17 @@ class YoutubeAbstract(ScraperAbstract):
|
|
112
141
|
with requests.get(url, timeout=(timeout, timeout)) as response:
|
113
142
|
if response.status_code == 200:
|
114
143
|
image = Image.open(io.BytesIO(response.content))
|
115
|
-
|
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))
|
147
|
+
image = MediaInfoAbstract.shrink_image_to_fit(image, size=desired_size)
|
148
|
+
image_position = (
|
149
|
+
(desired_size[0] - image.size[0]) // 2,
|
150
|
+
(desired_size[1] - image.size[1]) // 2
|
151
|
+
)
|
152
|
+
new_image.paste(image, image_position)
|
116
153
|
io_buf = io.BytesIO()
|
117
|
-
|
154
|
+
new_image.save(io_buf, format='JPEG', subsampling=0, quality=100, progressive=True, optimize=False)
|
118
155
|
io_buf.seek(0)
|
119
156
|
return io_buf
|
120
157
|
except Exception as e:
|
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
|