warp-beacon 2.3.41__tar.gz → 2.3.43__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.
Files changed (61) hide show
  1. {warp_beacon-2.3.41/warp_beacon.egg-info → warp_beacon-2.3.43}/PKG-INFO +1 -1
  2. warp_beacon-2.3.43/warp_beacon/__version__.py +2 -0
  3. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/youtube/abstract.py +7 -6
  4. warp_beacon-2.3.43/warp_beacon/scraper/youtube/music.py +97 -0
  5. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/youtube/youtube.py +1 -2
  6. {warp_beacon-2.3.41 → warp_beacon-2.3.43/warp_beacon.egg-info}/PKG-INFO +1 -1
  7. warp_beacon-2.3.41/warp_beacon/__version__.py +0 -2
  8. warp_beacon-2.3.41/warp_beacon/scraper/youtube/music.py +0 -47
  9. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/LICENSE +0 -0
  10. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/MANIFEST.in +0 -0
  11. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/README.md +0 -0
  12. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/assets/placeholder.gif +0 -0
  13. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/etc/.gitignore +0 -0
  14. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/etc/accounts.json +0 -0
  15. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/etc/proxies.json +0 -0
  16. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/etc/warp_beacon.conf +0 -0
  17. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/etc/warp_beacon.service +0 -0
  18. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/pyproject.toml +0 -0
  19. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/setup.cfg +0 -0
  20. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/setup.py +0 -0
  21. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/__init__.py +0 -0
  22. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/compress/__init__.py +0 -0
  23. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/compress/video.py +0 -0
  24. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/jobs/__init__.py +0 -0
  25. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/jobs/abstract.py +0 -0
  26. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/jobs/download_job.py +0 -0
  27. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/jobs/types.py +0 -0
  28. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/jobs/upload_job.py +0 -0
  29. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/mediainfo/__init__.py +0 -0
  30. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/mediainfo/abstract.py +0 -0
  31. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/mediainfo/audio.py +0 -0
  32. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/mediainfo/silencer.py +0 -0
  33. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/mediainfo/video.py +0 -0
  34. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scheduler/__init__.py +0 -0
  35. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scheduler/instagram_human.py +0 -0
  36. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scheduler/scheduler.py +0 -0
  37. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/__init__.py +0 -0
  38. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/abstract.py +0 -0
  39. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/account_selector.py +0 -0
  40. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/exceptions.py +0 -0
  41. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/fail_handler.py +0 -0
  42. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/instagram/__init__.py +0 -0
  43. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/instagram/instagram.py +0 -0
  44. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/link_resolver.py +0 -0
  45. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/youtube/__init__.py +0 -0
  46. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/scraper/youtube/shorts.py +0 -0
  47. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/storage/__init__.py +0 -0
  48. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/storage/mongo.py +0 -0
  49. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/telegram/__init__.py +0 -0
  50. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/telegram/bot.py +0 -0
  51. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/telegram/caption_shortener.py +0 -0
  52. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/telegram/handlers.py +0 -0
  53. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/telegram/placeholder_message.py +0 -0
  54. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/telegram/utils.py +0 -0
  55. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/uploader/__init__.py +0 -0
  56. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon/warp_beacon.py +0 -0
  57. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon.egg-info/SOURCES.txt +0 -0
  58. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon.egg-info/dependency_links.txt +0 -0
  59. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon.egg-info/entry_points.txt +0 -0
  60. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon.egg-info/requires.txt +0 -0
  61. {warp_beacon-2.3.41 → warp_beacon-2.3.43}/warp_beacon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.3.41
3
+ Version: 2.3.43
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
@@ -0,0 +1,2 @@
1
+ __version__ = "2.3.43"
2
+
@@ -219,10 +219,10 @@ class YoutubeAbstract(ScraperAbstract):
219
219
  requests.RequestException,
220
220
  urllib.error.URLError,
221
221
  urllib.error.HTTPError) as e:
222
- if hasattr(e, "code") and int(e.code) == 403:
222
+ if hasattr(e, "code") and (int(e.code) == 403 or int(e.code) == 400):
223
223
  raise Unavailable(extract_exception_message(e))
224
- logging.warning("Youtube read timeout! Retrying in %d seconds ...", pause_secs)
225
- logging.info("Your `YT_MAX_RETRIES` values is %d", max_retries)
224
+ logging.warning("Youtube read timeout! Retrying in '%d' seconds ...", pause_secs)
225
+ logging.info("Your `YT_MAX_RETRIES` values is '%d'", max_retries)
226
226
  logging.exception(extract_exception_message(e))
227
227
  if max_retries <= retries:
228
228
  self.remove_tmp_files()
@@ -279,13 +279,14 @@ class YoutubeAbstract(ScraperAbstract):
279
279
  logging.warning("Proxy DSN malformed!")
280
280
  return YouTube(**yt_opts)
281
281
 
282
- def build_yt_dlp(self, timeout: int = 0) -> yt_dlp.YoutubeDL:
282
+ def build_yt_dlp(self, timeout: int = 60) -> yt_dlp.YoutubeDL:
283
283
  auth_data = {}
284
284
  with open(self.YT_SESSION_FILE % self.account_index, 'r', encoding="utf-8") as f:
285
285
  auth_data = json.loads(f.read())
286
286
  time_name = str(time.time()).replace('.', '_')
287
287
  ydl_opts = {
288
- 'outtmpl': f'{self.DOWNLOAD_DIR}/{time_name}.%(ext)s',
288
+ 'socket_timeout': timeout,
289
+ 'outtmpl': f'{self.DOWNLOAD_DIR}/yt_download_{time_name}.%(ext)s',
289
290
  'format': 'bestvideo+bestaudio/best',
290
291
  'merge_output_format': 'mp4',
291
292
  'noplaylist': True,
@@ -317,6 +318,6 @@ class YoutubeAbstract(ScraperAbstract):
317
318
  ret = self.download_hndlr(self._download_yt_dlp, job.url)
318
319
  except NotImplementedError:
319
320
  logging.info("yt_dlp is not supported for this submodule yet")
320
- raise Unavailable("Video unvailable")
321
+ raise Unavailable("Сontent unvailable")
321
322
 
322
323
  return ret
@@ -0,0 +1,97 @@
1
+ import logging
2
+
3
+ import time
4
+ import json
5
+
6
+ import yt_dlp
7
+
8
+ from warp_beacon.jobs.types import JobType
9
+ from warp_beacon.scraper.youtube.abstract import YoutubeAbstract
10
+ from warp_beacon.scraper.exceptions import NotFound, FileTooBig
11
+
12
+
13
+ class YoutubeMusicScraper(YoutubeAbstract):
14
+ YT_MAX_RETRIES_DEFAULT = 3
15
+ YT_PAUSE_BEFORE_RETRY_DEFAULT = 3
16
+ YT_TIMEOUT_DEFAULT = 2
17
+ YT_TIMEOUT_INCREMENT_DEFAULT = 60
18
+
19
+ def _download(self, url: str, session: bool = True, timeout: int = 0) -> list:
20
+ res = []
21
+ thumbnail = None
22
+ audio_id = self.get_video_id(url)
23
+
24
+ if audio_id:
25
+ thumbnail = self.download_hndlr(self.download_thumbnail, audio_id)
26
+
27
+ yt = self.build_yt(url, session=session)
28
+
29
+ stream = yt.streams.get_audio_only()
30
+
31
+ if not stream:
32
+ raise NotFound("No suitable audio stream found")
33
+
34
+ logging.info("Announced audio file size: '%d'", stream.filesize)
35
+ if stream.filesize > 2e+9:
36
+ logging.warning("Downloading size reported by YouTube is over than 2 GB!")
37
+ raise FileTooBig("YouTube file is larger than 2 GB")
38
+ logging.info("Operation timeout is '%d'", timeout)
39
+ local_file = stream.download(
40
+ output_path=self.DOWNLOAD_DIR,
41
+ max_retries=0,
42
+ timeout=timeout,
43
+ skip_existing=False,
44
+ filename_prefix='yt_download_'
45
+ )
46
+ logging.debug("Temp filename: '%s'", local_file)
47
+ res.append({
48
+ "local_media_path": self.rename_local_file(local_file),
49
+ "performer": yt.author,
50
+ "thumb": thumbnail,
51
+ "canonical_name": stream.title,
52
+ "media_type": JobType.AUDIO
53
+ })
54
+
55
+ return res
56
+
57
+ def build_yt_dlp(self, timeout: int = 60) -> yt_dlp.YoutubeDL:
58
+ auth_data = {}
59
+ with open(self.YT_SESSION_FILE % self.account_index, 'r', encoding="utf-8") as f:
60
+ auth_data = json.loads(f.read())
61
+ time_name = str(time.time()).replace('.', '_')
62
+ ydl_opts = {
63
+ 'socket_timeout': timeout,
64
+ 'outtmpl': f'{self.DOWNLOAD_DIR}/yt_download_{time_name}.%(ext)s',
65
+ 'format': 'bestaudio[ext=m4a]/bestaudio/best',
66
+ 'noplaylist': True,
67
+ 'keepvideo': False,
68
+ 'tv_auth': auth_data
69
+ }
70
+
71
+ if self.proxy:
72
+ proxy_dsn = self.proxy.get("dsn", "")
73
+ logging.info("Using proxy DSN '%s'", proxy_dsn)
74
+ if proxy_dsn:
75
+ ydl_opts["proxy"] = proxy_dsn
76
+
77
+ return yt_dlp.YoutubeDL(ydl_opts)
78
+
79
+ def _download_yt_dlp(self, url: str, timeout: int = 60) -> list:
80
+ res = []
81
+ thumbnail = None
82
+ video_id = self.get_video_id(url)
83
+ if video_id:
84
+ thumbnail = self.download_hndlr(self.download_thumbnail, video_id)
85
+ with self.build_yt_dlp(timeout) as ydl:
86
+ info = ydl.extract_info(url, download=True)
87
+ local_file = ydl.prepare_filename(info)
88
+ logging.debug("Temp filename: '%s'", local_file)
89
+ res.append({
90
+ "local_media_path": local_file,
91
+ "performer": info.get("uploader", "Unknown"),
92
+ "thumb": thumbnail,
93
+ "canonical_name": info.get("title", ''),
94
+ "media_type": JobType.AUDIO
95
+ })
96
+
97
+ return res
@@ -73,12 +73,11 @@ class YoutubeScraper(YoutubeAbstract):
73
73
  video_id = self.get_video_id(url)
74
74
  if video_id:
75
75
  thumbnail = self.download_hndlr(self.download_thumbnail, video_id)
76
- with self.build_yt_dlp() as ydl:
76
+ with self.build_yt_dlp(timeout) as ydl:
77
77
  info = ydl.extract_info(url, download=True)
78
78
  local_file = ydl.prepare_filename(info)
79
79
  logging.debug("Temp filename: '%s'", local_file)
80
80
  res.append({
81
- "socket_timeout": timeout,
82
81
  "local_media_path": local_file,
83
82
  "performer": info.get("uploader", "Unknown"),
84
83
  "thumb": thumbnail,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: warp_beacon
3
- Version: 2.3.41
3
+ Version: 2.3.43
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
@@ -1,2 +0,0 @@
1
- __version__ = "2.3.41"
2
-
@@ -1,47 +0,0 @@
1
- from warp_beacon.jobs.types import JobType
2
- from warp_beacon.scraper.youtube.abstract import YoutubeAbstract
3
- from warp_beacon.scraper.exceptions import NotFound, FileTooBig
4
-
5
- import logging
6
-
7
- class YoutubeMusicScraper(YoutubeAbstract):
8
- YT_MAX_RETRIES_DEFAULT = 6
9
- YT_PAUSE_BEFORE_RETRY_DEFAULT = 3
10
- YT_TIMEOUT_DEFAULT = 2
11
- YT_TIMEOUT_INCREMENT_DEFAULT = 60
12
-
13
- def _download(self, url: str, session: bool = True, timeout: int = 0) -> list:
14
- res = []
15
- thumbnail = None
16
- yt = self.build_yt(url, session=session)
17
-
18
- if yt:
19
- thumbnail = self.download_hndlr(self.download_thumbnail, yt.video_id)
20
-
21
- stream = yt.streams.get_audio_only()
22
-
23
- if not stream:
24
- raise NotFound("No suitable audio stream found")
25
-
26
- logging.info("Announced audio file size: '%d'", stream.filesize)
27
- if stream.filesize > 2e+9:
28
- logging.warning("Downloading size reported by YouTube is over than 2 GB!")
29
- raise FileTooBig("YouTube file is larger than 2 GB")
30
- logging.info("Operation timeout is '%d'", timeout)
31
- local_file = stream.download(
32
- output_path=self.DOWNLOAD_DIR,
33
- max_retries=0,
34
- timeout=timeout,
35
- skip_existing=False,
36
- filename_prefix='yt_download_'
37
- )
38
- logging.debug("Temp filename: '%s'", local_file)
39
- res.append({
40
- "local_media_path": self.rename_local_file(local_file),
41
- "performer": yt.author,
42
- "thumb": thumbnail,
43
- "canonical_name": stream.title,
44
- "media_type": JobType.AUDIO
45
- })
46
-
47
- return res
File without changes
File without changes
File without changes
File without changes
File without changes