aboutsummaryrefslogtreecommitdiffstats
path: root/hypervideo_dl/extractor/franceinter.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-06-09 17:54:27 -0500
committerJesús <heckyel@hyperbola.info>2021-06-09 17:54:27 -0500
commit27fe903c511691c078942bef5ee9a05a43b15c8f (patch)
tree50f30ab2ec749b965869518c0a28651f8677f0d3 /hypervideo_dl/extractor/franceinter.py
downloadhypervideo-27fe903c511691c078942bef5ee9a05a43b15c8f.tar.lz
hypervideo-27fe903c511691c078942bef5ee9a05a43b15c8f.tar.xz
hypervideo-27fe903c511691c078942bef5ee9a05a43b15c8f.zip
initial
Diffstat (limited to 'hypervideo_dl/extractor/franceinter.py')
-rw-r--r--hypervideo_dl/extractor/franceinter.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/hypervideo_dl/extractor/franceinter.py b/hypervideo_dl/extractor/franceinter.py
new file mode 100644
index 0000000..ae822a5
--- /dev/null
+++ b/hypervideo_dl/extractor/franceinter.py
@@ -0,0 +1,59 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import month_by_name
+
+
+class FranceInterIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?franceinter\.fr/emissions/(?P<id>[^?#]+)'
+
+ _TEST = {
+ 'url': 'https://www.franceinter.fr/emissions/affaires-sensibles/affaires-sensibles-07-septembre-2016',
+ 'md5': '9e54d7bdb6fdc02a841007f8a975c094',
+ 'info_dict': {
+ 'id': 'affaires-sensibles/affaires-sensibles-07-septembre-2016',
+ 'ext': 'mp3',
+ 'title': 'Affaire Cahuzac : le contentieux du compte en Suisse',
+ 'description': 'md5:401969c5d318c061f86bda1fa359292b',
+ 'thumbnail': r're:^https?://.*\.jpg',
+ 'upload_date': '20160907',
+ },
+ }
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+
+ webpage = self._download_webpage(url, video_id)
+
+ video_url = self._search_regex(
+ r'(?s)<div[^>]+class=["\']page-diffusion["\'][^>]*>.*?<button[^>]+data-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
+ webpage, 'video url', group='url')
+
+ title = self._og_search_title(webpage)
+ description = self._og_search_description(webpage)
+ thumbnail = self._html_search_meta(['og:image', 'twitter:image'], webpage)
+
+ upload_date_str = self._search_regex(
+ r'class=["\']\s*cover-emission-period\s*["\'][^>]*>[^<]+\s+(\d{1,2}\s+[^\s]+\s+\d{4})<',
+ webpage, 'upload date', fatal=False)
+ if upload_date_str:
+ upload_date_list = upload_date_str.split()
+ upload_date_list.reverse()
+ upload_date_list[1] = '%02d' % (month_by_name(upload_date_list[1], lang='fr') or 0)
+ upload_date_list[2] = '%02d' % int(upload_date_list[2])
+ upload_date = ''.join(upload_date_list)
+ else:
+ upload_date = None
+
+ return {
+ 'id': video_id,
+ 'title': title,
+ 'description': description,
+ 'thumbnail': thumbnail,
+ 'upload_date': upload_date,
+ 'formats': [{
+ 'url': video_url,
+ 'vcodec': 'none',
+ }],
+ }