From c4172f6de6bddd70dd8de38b9c55cd17591e5faa Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Sun, 25 Aug 2024 08:11:36 +0000 Subject: [PATCH] [ie/dailymotion/embed] Support embedded videos with "data-video" https://developers.dailymotion.com/player/#player-embed-script-video-embed --- yt_dlp/extractor/dailymotion.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yt_dlp/extractor/dailymotion.py b/yt_dlp/extractor/dailymotion.py index 632335e5b..717ba27f3 100644 --- a/yt_dlp/extractor/dailymotion.py +++ b/yt_dlp/extractor/dailymotion.py @@ -10,11 +10,13 @@ from ..utils import ( OnDemandPagedList, age_restricted, clean_html, + extract_attributes, int_or_none, traverse_obj, try_get, unescapeHTML, unsmuggle_url, + url_or_none, urlencode_postdata, ) @@ -232,6 +234,13 @@ class DailymotionIE(DailymotionBaseInfoExtractor): for mobj in re.finditer( r'(?s)DM\.player\([^,]+,\s*{.*?video[\'"]?\s*:\s*["\']?(?P[0-9a-zA-Z]+).+?}\s*\);', webpage): yield from 'https://www.dailymotion.com/embed/video/' + mobj.group('id') + for mobj in re.finditer( + r'(?s)]*?\bsrc=(["\'])((?:https?:)?//[^>]+\.dailymotion\.com/player/(?:(?!\1).)+)\1[^>]*?>', webpage): + attrs = extract_attributes(mobj.group(0)) + player_url = url_or_none(attrs.get('src')) + video_id = attrs.get('data-video') + if all((player_url, video_id)): + yield f'{player_url.replace(".js", ".html")}?video={video_id}' def _real_extract(self, url): url, smuggled_data = unsmuggle_url(url)