From c346035bdf83546f075a6b858b47fafcf439e8a3 Mon Sep 17 00:00:00 2001 From: nicole trinity Date: Mon, 29 Jul 2024 16:27:34 -0400 Subject: [PATCH 1/5] basic working la1ere extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/la1ere.py | 83 ++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 youtube_dl/extractor/la1ere.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 3da5f802093..9f18cc057e5 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -585,6 +585,7 @@ KuwoCategoryIE, KuwoMvIE, ) +from .la1ere import La1ereExtractorPageIE, La1ereExtractorShowPageIE from .la7 import LA7IE from .laola1tv import ( Laola1TvEmbedIE, diff --git a/youtube_dl/extractor/la1ere.py b/youtube_dl/extractor/la1ere.py new file mode 100644 index 00000000000..f7c4808f77b --- /dev/null +++ b/youtube_dl/extractor/la1ere.py @@ -0,0 +1,83 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from urllib.parse import quote + +from .common import InfoExtractor + + +class La1ereExrtractorBaseIE(InfoExtractor): + + def _extract_given_title(self, webpage, title): + + # get the ID + video_id = self._html_search_regex(r'data-id="([^"]+)"', webpage, 'id') + + # request the mpd-request url + json_request_url = 'https://k7.ftven.fr/videos/%s?country_code=FR&w=937&h=527&screen_w=1920&screen_h=1200&player_version=5.116.1&domain=la1ere.francetvinfo.fr&device_type=desktop&browser=chrome&browser_version=126&os=linux&diffusion_mode=tunnel&gmt=-0400&capabilities=drm' % video_id + json_request = self._download_json(json_request_url, video_id) + mpd_request_url = json_request['video']['url'] + + # using the mpd-request url, auth to get the full mpd URL with auth params + auth_request_url = 'https://hdfauth.ftven.fr/esi/TA?format=json&url=%s' % quote(mpd_request_url) + auth_request = self._download_json(auth_request_url, video_id) + + # this is the full playlist URL with auth params + playlist_url = auth_request['url'] + return video_id, playlist_url + + +class La1ereExtractorPageIE(La1ereExrtractorBaseIE): + _VALID_URL = r'https://la1ere.francetvinfo.fr/(?P[^/]+)/programme-video/diffusion/(?P[^\.]+).html' + _TEST = { + 'url': 'https://la1ere.francetvinfo.fr/martinique/programme-video/diffusion/4774522-origine-kongo.html', + 'info_dict': { + 'ext': 'mp4', + 'title': 'Origine Kongo', + } + } + + def _real_extract(self, url): + webpage = self._download_webpage(url, 'la1ere') + + title = self._html_search_regex(r'

(.+?)

', webpage, 'title') + + video_id, playlist_url = self._extract_given_title(webpage, title) + + # get the mpd playlist + formats = self._extract_m3u8_formats(playlist_url, video_id) + + return { + 'id': video_id, + 'title': title, + 'formats': formats, + } + +class La1ereExtractorShowPageIE(La1ereExrtractorBaseIE): + _VALID_URL = r'https://la1ere.francetvinfo.fr/(?P[^/]+)/programme-video/(?P[^/]+)/diffusion/(?P[^\.]+).html' + _TEST = { + 'url': 'https://la1ere.francetvinfo.fr/guadeloupe/programme-video/la1ere_guadeloupe_le-13h-en-guadeloupe/diffusion/5643549-emission-du-lundi-29-janvier-2024.html', + 'info_dict': { + 'ext': 'mp4', + 'title': '13H en Guadeloupe - Émission du lundi 29 janvier 2024', + } + } + + def _real_extract(self, url): + webpage = self._download_webpage(url, 'la1ere') + + series_name = self._html_search_regex(r'(.+?)', webpage, 'series_name') + episode_name = self._html_search_regex(r'

(.+?)

', webpage, 'episode_name') + title = f'{series_name} - {episode_name}' + + video_id, playlist_url = self._extract_given_title(webpage, title) + + # get the m3u8 playlist + formats = self._extract_m3u8_formats(playlist_url, video_id) + + return { + 'id': video_id, + 'title': title, + 'formats': formats, + } + From d933a0ef767c08f4c4c3aa090070b80e24ec4f33 Mon Sep 17 00:00:00 2001 From: nicole trinity Date: Mon, 29 Jul 2024 16:29:12 -0400 Subject: [PATCH 2/5] skip tests for la1ere extractor as its only available in FR --- youtube_dl/extractor/la1ere.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/youtube_dl/extractor/la1ere.py b/youtube_dl/extractor/la1ere.py index f7c4808f77b..b1008fcf771 100644 --- a/youtube_dl/extractor/la1ere.py +++ b/youtube_dl/extractor/la1ere.py @@ -30,6 +30,7 @@ def _extract_given_title(self, webpage, title): class La1ereExtractorPageIE(La1ereExrtractorBaseIE): _VALID_URL = r'https://la1ere.francetvinfo.fr/(?P[^/]+)/programme-video/diffusion/(?P[^\.]+).html' _TEST = { + 'skip': 'Only available in FR', 'url': 'https://la1ere.francetvinfo.fr/martinique/programme-video/diffusion/4774522-origine-kongo.html', 'info_dict': { 'ext': 'mp4', @@ -56,6 +57,7 @@ def _real_extract(self, url): class La1ereExtractorShowPageIE(La1ereExrtractorBaseIE): _VALID_URL = r'https://la1ere.francetvinfo.fr/(?P[^/]+)/programme-video/(?P[^/]+)/diffusion/(?P[^\.]+).html' _TEST = { + 'skip': 'Only available in FR', 'url': 'https://la1ere.francetvinfo.fr/guadeloupe/programme-video/la1ere_guadeloupe_le-13h-en-guadeloupe/diffusion/5643549-emission-du-lundi-29-janvier-2024.html', 'info_dict': { 'ext': 'mp4', From 8b8d196f65aa58be9ba7f5863b79a4e1adaee476 Mon Sep 17 00:00:00 2001 From: nicole trinity Date: Mon, 29 Jul 2024 16:31:08 -0400 Subject: [PATCH 3/5] flake8 fixes for la1ere extractor --- youtube_dl/extractor/la1ere.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/youtube_dl/extractor/la1ere.py b/youtube_dl/extractor/la1ere.py index b1008fcf771..2952c6a0de0 100644 --- a/youtube_dl/extractor/la1ere.py +++ b/youtube_dl/extractor/la1ere.py @@ -26,7 +26,7 @@ def _extract_given_title(self, webpage, title): playlist_url = auth_request['url'] return video_id, playlist_url - + class La1ereExtractorPageIE(La1ereExrtractorBaseIE): _VALID_URL = r'https://la1ere.francetvinfo.fr/(?P[^/]+)/programme-video/diffusion/(?P[^\.]+).html' _TEST = { @@ -44,7 +44,7 @@ def _real_extract(self, url): title = self._html_search_regex(r'

(.+?)

', webpage, 'title') video_id, playlist_url = self._extract_given_title(webpage, title) - + # get the mpd playlist formats = self._extract_m3u8_formats(playlist_url, video_id) @@ -53,7 +53,8 @@ def _real_extract(self, url): 'title': title, 'formats': formats, } - + + class La1ereExtractorShowPageIE(La1ereExrtractorBaseIE): _VALID_URL = r'https://la1ere.francetvinfo.fr/(?P[^/]+)/programme-video/(?P[^/]+)/diffusion/(?P[^\.]+).html' _TEST = { @@ -64,7 +65,7 @@ class La1ereExtractorShowPageIE(La1ereExrtractorBaseIE): 'title': '13H en Guadeloupe - Émission du lundi 29 janvier 2024', } } - + def _real_extract(self, url): webpage = self._download_webpage(url, 'la1ere') @@ -73,7 +74,7 @@ def _real_extract(self, url): title = f'{series_name} - {episode_name}' video_id, playlist_url = self._extract_given_title(webpage, title) - + # get the m3u8 playlist formats = self._extract_m3u8_formats(playlist_url, video_id) @@ -82,4 +83,3 @@ def _real_extract(self, url): 'title': title, 'formats': formats, } - From 2e31ae21dd88349fe9b92efaf2a8223b723ff8e8 Mon Sep 17 00:00:00 2001 From: nicole trinity Date: Tue, 30 Jul 2024 10:03:41 -0400 Subject: [PATCH 4/5] sort formats before return --- youtube_dl/extractor/la1ere.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/youtube_dl/extractor/la1ere.py b/youtube_dl/extractor/la1ere.py index 2952c6a0de0..2f2da9a4a9e 100644 --- a/youtube_dl/extractor/la1ere.py +++ b/youtube_dl/extractor/la1ere.py @@ -47,6 +47,7 @@ def _real_extract(self, url): # get the mpd playlist formats = self._extract_m3u8_formats(playlist_url, video_id) + self._sort_formats(formats) return { 'id': video_id, @@ -77,9 +78,13 @@ def _real_extract(self, url): # get the m3u8 playlist formats = self._extract_m3u8_formats(playlist_url, video_id) + self._sort_formats(formats) return { 'id': video_id, 'title': title, 'formats': formats, } + + + From 29e60290cfc508f7823b9191d2a2a124128e9876 Mon Sep 17 00:00:00 2001 From: nicole trinity Date: Thu, 1 Aug 2024 11:33:20 -0400 Subject: [PATCH 5/5] extract mpd for single video --- youtube_dl/extractor/la1ere.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/la1ere.py b/youtube_dl/extractor/la1ere.py index 2f2da9a4a9e..a527a0bbf26 100644 --- a/youtube_dl/extractor/la1ere.py +++ b/youtube_dl/extractor/la1ere.py @@ -46,7 +46,7 @@ def _real_extract(self, url): video_id, playlist_url = self._extract_given_title(webpage, title) # get the mpd playlist - formats = self._extract_m3u8_formats(playlist_url, video_id) + formats = self._extract_mpd_formats(playlist_url, video_id) self._sort_formats(formats) return {