From bd7b1dd250b73a684f892b5d4bf18e4dee50def6 Mon Sep 17 00:00:00 2001 From: flatgreen Date: Sun, 27 Dec 2015 15:30:45 +0100 Subject: [PATCH 1/5] [franceculture] improve extractor --- youtube_dl/extractor/__init__.py | 5 ++- youtube_dl/extractor/franceculture.py | 52 ++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 165835f63..7c4a19a11 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -198,7 +198,10 @@ from .fourtube import FourTubeIE from .foxgay import FoxgayIE from .foxnews import FoxNewsIE from .foxsports import FoxSportsIE -from .franceculture import FranceCultureIE +from .franceculture import ( + FranceCultureIE, + FranceCultureUrlIE, +) from .franceinter import FranceInterIE from .francetv import ( PluzzIE, diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py index 1e83a4e7e..77ef4b8b7 100644 --- a/youtube_dl/extractor/franceculture.py +++ b/youtube_dl/extractor/franceculture.py @@ -1,6 +1,8 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor from ..compat import ( compat_urlparse, @@ -22,14 +24,14 @@ class FranceCultureIE(InfoExtractor): 'alt_title': 'Carnet nomade | 13-14', 'vcodec': 'none', 'upload_date': '20140301', - 'thumbnail': r're:^http://www\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$', - 'description': 'startswith:Avec :Jean-Baptiste Péretié pour son documentaire sur Arte "La revanche des « geeks », une enquête menée aux Etats', + 'thumbnail': r're:^http://static\.franceculture\.fr/.*/images/player/Carnet-nomade\.jpg$', + 'description': 'startswith:Avec :Jean-Baptiste Péretié pour son documentaire sur Arte "La revanche', 'timestamp': 1393700400, } } - def _real_extract(self, url): - video_id = self._match_id(url) + def _extract_infos_from_player(self, url, video_id): + webpage = self._download_webpage(url, video_id) video_path = self._search_regex( @@ -42,6 +44,9 @@ class FranceCultureIE(InfoExtractor): r'\s+emission-(.*?)', webpage, 'display_id') + title = self._html_search_regex( r'(.*?)', webpage, 'title') alt_title = self._html_search_regex( @@ -66,4 +71,43 @@ class FranceCultureIE(InfoExtractor): 'alt_title': alt_title, 'thumbnail': thumbnail, 'description': description, + 'display_id': display_id } + + def _real_extract(self, url): + video_id = self._match_id(url) + return self._extract_infos_from_player(url, video_id) + + +class FranceCultureUrlIE(FranceCultureIE): + _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emission-(?P[^?#]+)' + _TEST = { + 'url': 'http://www.franceculture.fr/emission-les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13', + 'info_dict': { + 'title': 'Jean-Gabriel Périot, cinéaste', + 'alt_title': 'Les Carnets de la création', + 'id': '5093239', + 'display_id': 'les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13', + 'ext': 'mp3', + 'timestamp': 1444762500, + 'upload_date': '20151013', + 'description': 'startswith:Aujourd\'hui dans "Les carnets de la création", le cinéaste', + } + } + + # dl url + # find : + # extract '/player/reecouter?play=5093239' join to url base of franceculture + # extract mp3 with FranceCultureIE _extract_infos_from_player + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + video_path = self._html_search_regex( + r'[0-9]+)', video_path).group('id') + video_url = compat_urlparse.urljoin(url, video_path) + return self._extract_infos_from_player(video_url, new_id) From 3d2e410ec10c3f79f27880c1ebd8809ad4f7cc05 Mon Sep 17 00:00:00 2001 From: flatgreen Date: Mon, 28 Dec 2015 17:41:41 +0100 Subject: [PATCH 2/5] [franceculture] improve 2 beautiful --- youtube_dl/extractor/__init__.py | 2 +- youtube_dl/extractor/franceculture.py | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 7c4a19a11..ef63360e6 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -200,7 +200,7 @@ from .foxnews import FoxNewsIE from .foxsports import FoxSportsIE from .franceculture import ( FranceCultureIE, - FranceCultureUrlIE, + FranceCultureEmissionIE, ) from .franceinter import FranceInterIE from .francetv import ( diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py index 77ef4b8b7..995aa37c6 100644 --- a/youtube_dl/extractor/franceculture.py +++ b/youtube_dl/extractor/franceculture.py @@ -1,8 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -import re - from .common import InfoExtractor from ..compat import ( compat_urlparse, @@ -10,6 +8,7 @@ from ..compat import ( from ..utils import ( determine_ext, int_or_none, + ExtractorError, ) @@ -79,7 +78,7 @@ class FranceCultureIE(InfoExtractor): return self._extract_infos_from_player(url, video_id) -class FranceCultureUrlIE(FranceCultureIE): +class FranceCultureEmissionIE(FranceCultureIE): _VALID_URL = r'https?://(?:www\.)?franceculture\.fr/emission-(?P[^?#]+)' _TEST = { 'url': 'http://www.franceculture.fr/emission-les-carnets-de-la-creation-jean-gabriel-periot-cineaste-2015-10-13', @@ -95,19 +94,14 @@ class FranceCultureUrlIE(FranceCultureIE): } } - # dl url - # find : - # extract '/player/reecouter?play=5093239' join to url base of franceculture - # extract mp3 with FranceCultureIE _extract_infos_from_player - def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_path = self._html_search_regex( - r'[0-9]+)', video_path).group('id') + new_id = self._search_regex('play=(?P[0-9]+)', video_path, 'new_id', group='id') video_url = compat_urlparse.urljoin(url, video_path) return self._extract_infos_from_player(video_url, new_id) From d42ddf51c4c973208cd2d049264d67a6ffee1779 Mon Sep 17 00:00:00 2001 From: flatgreen Date: Mon, 28 Dec 2015 17:54:37 +0100 Subject: [PATCH 3/5] [franceculture] improve 3 --- youtube_dl/extractor/franceculture.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py index 995aa37c6..9dc89ad9c 100644 --- a/youtube_dl/extractor/franceculture.py +++ b/youtube_dl/extractor/franceculture.py @@ -29,7 +29,7 @@ class FranceCultureIE(InfoExtractor): } } - def _extract_infos_from_player(self, url, video_id): + def _extract_from_player(self, url, video_id): webpage = self._download_webpage(url, video_id) @@ -104,4 +104,4 @@ class FranceCultureEmissionIE(FranceCultureIE): return None new_id = self._search_regex('play=(?P[0-9]+)', video_path, 'new_id', group='id') video_url = compat_urlparse.urljoin(url, video_path) - return self._extract_infos_from_player(video_url, new_id) + return self._extract_from_player(video_url, new_id) From bd2ce4bd2def61c0467b5a2d9c68ed891375c03d Mon Sep 17 00:00:00 2001 From: flatgreen Date: Mon, 28 Dec 2015 18:25:51 +0100 Subject: [PATCH 4/5] [franceculture] improve 4 perhaps the end --- youtube_dl/extractor/franceculture.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py index 9dc89ad9c..fb84116dd 100644 --- a/youtube_dl/extractor/franceculture.py +++ b/youtube_dl/extractor/franceculture.py @@ -75,7 +75,7 @@ class FranceCultureIE(InfoExtractor): def _real_extract(self, url): video_id = self._match_id(url) - return self._extract_infos_from_player(url, video_id) + return self._extract_from_player(url, video_id) class FranceCultureEmissionIE(FranceCultureIE): From b72735480b1990094f70bc72ac2766b918f7b96f Mon Sep 17 00:00:00 2001 From: flatgreen Date: Mon, 28 Dec 2015 18:28:34 +0100 Subject: [PATCH 5/5] [franceculture] improve 5 --- youtube_dl/extractor/franceculture.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/franceculture.py b/youtube_dl/extractor/franceculture.py index fb84116dd..bc10255f7 100644 --- a/youtube_dl/extractor/franceculture.py +++ b/youtube_dl/extractor/franceculture.py @@ -101,7 +101,6 @@ class FranceCultureEmissionIE(FranceCultureIE): r'[0-9]+)', video_path, 'new_id', group='id') video_url = compat_urlparse.urljoin(url, video_path) return self._extract_from_player(video_url, new_id)