BennyThink commited on
Commit
a5577b3
·
1 Parent(s): 6679e26

live detection

Browse files
Files changed (2) hide show
  1. src/engine/generic.py +7 -0
  2. src/main.py +0 -5
src/engine/generic.py CHANGED
@@ -13,6 +13,12 @@ from database.model import get_format_settings, get_quality_settings
13
  from engine.base import BaseDownloader
14
 
15
 
 
 
 
 
 
 
16
  class YoutubeDownload(BaseDownloader):
17
  @staticmethod
18
  def get_format(m):
@@ -82,6 +88,7 @@ class YoutubeDownload(BaseDownloader):
82
  "outtmpl": output,
83
  "restrictfilenames": False,
84
  "quiet": True,
 
85
  }
86
  # setup cookies for youtube only
87
  if self._url.startswith("https://www.youtube.com/") or self._url.startswith("https://youtu.be/"):
 
13
  from engine.base import BaseDownloader
14
 
15
 
16
+ def match_filter(info_dict):
17
+ if info_dict.get("is_live"):
18
+ raise NotImplementedError("Skipping live video")
19
+ return None # Allow download for non-live videos
20
+
21
+
22
  class YoutubeDownload(BaseDownloader):
23
  @staticmethod
24
  def get_format(m):
 
88
  "outtmpl": output,
89
  "restrictfilenames": False,
90
  "quiet": True,
91
+ "match_filter": match_filter,
92
  }
93
  # setup cookies for youtube only
94
  if self._url.startswith("https://www.youtube.com/") or self._url.startswith("https://youtu.be/"):
src/main.py CHANGED
@@ -281,11 +281,6 @@ def check_link(url: str):
281
  if re.findall(r"m3u8|\.m3u8|\.m3u$", url.lower()):
282
  raise ValueError("m3u8 links are not supported.")
283
 
284
- with contextlib.suppress(yt_dlp.utils.DownloadError):
285
- # TODO remove it or try 'match_filter': '!is_live',
286
- if ytdl.extract_info(url, download=False).get("live_status") == "is_live":
287
- raise ValueError("Live stream links are disabled. Please engine it after the stream ends.")
288
-
289
 
290
  @app.on_message(filters.incoming & filters.text)
291
  @private_use
 
281
  if re.findall(r"m3u8|\.m3u8|\.m3u$", url.lower()):
282
  raise ValueError("m3u8 links are not supported.")
283
 
 
 
 
 
 
284
 
285
  @app.on_message(filters.incoming & filters.text)
286
  @private_use