warp-beacon 2.2.54__tar.gz → 2.2.56__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.54/warp_beacon.egg-info → warp_beacon-2.2.56}/PKG-INFO +1 -1
- warp_beacon-2.2.56/warp_beacon/__version__.py +2 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/mediainfo/video.py +1 -2
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/youtube/abstract.py +15 -4
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/youtube/shorts.py +8 -4
- {warp_beacon-2.2.54 → warp_beacon-2.2.56/warp_beacon.egg-info}/PKG-INFO +1 -1
- warp_beacon-2.2.54/warp_beacon/__version__.py +0 -2
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/LICENSE +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/MANIFEST.in +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/README.md +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/assets/placeholder.gif +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/etc/.gitignore +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/etc/accounts.json +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/etc/warp_beacon.conf +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/etc/warp_beacon.service +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/pyproject.toml +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/setup.cfg +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/setup.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/compress/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/compress/video.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/jobs/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/jobs/abstract.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/jobs/download_job.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/jobs/types.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/jobs/upload_job.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/mediainfo/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/mediainfo/abstract.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/mediainfo/audio.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/mediainfo/silencer.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scheduler/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scheduler/scheduler.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/abstract.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/account_selector.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/exceptions.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/instagram/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/instagram/instagram.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/youtube/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/youtube/music.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/scraper/youtube/youtube.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/storage/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/telegram/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/telegram/bot.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/telegram/handlers.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/telegram/placeholder_message.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/telegram/utils.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/uploader/__init__.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon/warp_beacon.py +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon.egg-info/SOURCES.txt +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon.egg-info/dependency_links.txt +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon.egg-info/entry_points.txt +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon.egg-info/requires.txt +0 -0
- {warp_beacon-2.2.54 → warp_beacon-2.2.56}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -141,10 +141,19 @@ class YoutubeAbstract(ScraperAbstract):
|
|
141
141
|
|
142
142
|
def crop_black_edges_pil(self, img: Image, threshold: int = 35) -> Image:
|
143
143
|
y_nonzero, x_nonzero, _ = np.nonzero(np.array(img) > threshold)
|
144
|
-
return img.crop((np.min(x_nonzero), np.min(y_nonzero)
|
144
|
+
return img.crop((np.min(x_nonzero), np.min(y_nonzero), np.max(x_nonzero), np.max(y_nonzero)))
|
145
145
|
|
146
|
-
def
|
147
|
-
|
146
|
+
def crop_center(self, image: Image, width: int, height: int) -> Image:
|
147
|
+
img_width, img_height = image.size
|
148
|
+
left = (img_width - width) // 2
|
149
|
+
top = (img_height - height) // 2
|
150
|
+
right = left + width
|
151
|
+
bottom = top + height
|
152
|
+
|
153
|
+
return image.crop((left, top, right, bottom))
|
154
|
+
|
155
|
+
def download_thumbnail(self, video_id: str, timeout: int, crop_center: dict = None) -> Optional[io.BytesIO]:
|
156
|
+
for i in ("https://img.youtube.com/vi/{VIDEO_ID}/maxresdefault.jpg",
|
148
157
|
"https://img.youtube.com/vi/{VIDEO_ID}/hqdefault.jpg",
|
149
158
|
"https://img.youtube.com/vi/{VIDEO_ID}/sddefault.jpg"):
|
150
159
|
try:
|
@@ -155,6 +164,8 @@ class YoutubeAbstract(ScraperAbstract):
|
|
155
164
|
image = Image.open(io.BytesIO(response.content))
|
156
165
|
ratio = self.aspect_ratio(image.size)
|
157
166
|
image = self.crop_black_edges_pil(image)
|
167
|
+
if crop_center:
|
168
|
+
image = self.crop_center(image, width=crop_center["width"], height=crop_center["height"])
|
158
169
|
logging.info("thumb ratio: '%s'", ratio)
|
159
170
|
new_image = self.resize_aspect_ratio(image)
|
160
171
|
logging.info("thumb size: '%s'", new_image.size)
|
@@ -169,7 +180,7 @@ class YoutubeAbstract(ScraperAbstract):
|
|
169
180
|
|
170
181
|
return None
|
171
182
|
|
172
|
-
def _download_hndlr(self, func: Callable, *args: tuple[str], **kwargs: dict[str]) -> Union[str, dict, io.BytesIO]:
|
183
|
+
def _download_hndlr(self, func: Callable, *args: tuple[Union[str, int, dict, tuple]], **kwargs: dict[Union[str, int, dict, tuple]]) -> Union[str, dict, io.BytesIO]:
|
173
184
|
ret_val = ''
|
174
185
|
max_retries = int(os.environ.get("YT_MAX_RETRIES", default=self.YT_MAX_RETRIES_DEFAULT))
|
175
186
|
pause_secs = int(os.environ.get("YT_PAUSE_BEFORE_RETRY", default=self.YT_PAUSE_BEFORE_RETRY_DEFAULT))
|
@@ -2,6 +2,8 @@ from warp_beacon.jobs.types import JobType
|
|
2
2
|
from warp_beacon.scraper.youtube.abstract import YoutubeAbstract
|
3
3
|
from warp_beacon.scraper.exceptions import NotFound
|
4
4
|
|
5
|
+
from warp_beacon.mediainfo.video import VideoInfo
|
6
|
+
|
5
7
|
import logging
|
6
8
|
|
7
9
|
class YoutubeShortsScraper(YoutubeAbstract):
|
@@ -19,9 +21,6 @@ class YoutubeShortsScraper(YoutubeAbstract):
|
|
19
21
|
if not stream:
|
20
22
|
raise NotFound("No suitable video stream found")
|
21
23
|
|
22
|
-
if yt:
|
23
|
-
thumbnail = self._download_hndlr(self.download_thumbnail, yt.video_id)
|
24
|
-
|
25
24
|
local_file = stream.download(
|
26
25
|
output_path=self.DOWNLOAD_DIR,
|
27
26
|
max_retries=0,
|
@@ -29,9 +28,14 @@ class YoutubeShortsScraper(YoutubeAbstract):
|
|
29
28
|
skip_existing=False,
|
30
29
|
filename_prefix="yt_download_"
|
31
30
|
)
|
31
|
+
|
32
|
+
local_file = self.rename_local_file(local_file)
|
33
|
+
vinfo = VideoInfo(local_file)
|
34
|
+
thumbnail = self._download_hndlr(self.download_thumbnail, video_id=yt.video_id, crop_center=vinfo.get_demensions())
|
35
|
+
|
32
36
|
logging.debug("Temp filename: '%s'", local_file)
|
33
37
|
res.append({
|
34
|
-
"local_media_path":
|
38
|
+
"local_media_path": local_file,
|
35
39
|
"performer": yt.author,
|
36
40
|
"thumb": thumbnail,
|
37
41
|
"canonical_name": stream.title,
|
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
|