]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/franceinter.py
Imported Upstream version 2015.07.21
[youtubedl] / youtube_dl / extractor / franceinter.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import int_or_none
8
9
10 class FranceInterIE(InfoExtractor):
11 _VALID_URL = r'http://(?:www\.)?franceinter\.fr/player/reecouter\?play=(?P<id>[0-9]+)'
12 _TEST = {
13 'url': 'http://www.franceinter.fr/player/reecouter?play=793962',
14 'md5': '4764932e466e6f6c79c317d2e74f6884',
15 "info_dict": {
16 'id': '793962',
17 'ext': 'mp3',
18 'title': 'L’Histoire dans les jeux vidéo',
19 'description': 'md5:7e93ddb4451e7530022792240a3049c7',
20 'timestamp': 1387369800,
21 'upload_date': '20131218',
22 },
23 }
24
25 def _real_extract(self, url):
26 mobj = re.match(self._VALID_URL, url)
27 video_id = mobj.group('id')
28
29 webpage = self._download_webpage(url, video_id)
30
31 path = self._search_regex(
32 r'<a id="player".+?href="([^"]+)"', webpage, 'video url')
33 video_url = 'http://www.franceinter.fr/' + path
34
35 title = self._html_search_regex(
36 r'<span class="title">(.+?)</span>', webpage, 'title')
37 description = self._html_search_regex(
38 r'<span class="description">(.*?)</span>',
39 webpage, 'description', fatal=False)
40 timestamp = int_or_none(self._search_regex(
41 r'data-date="(\d+)"', webpage, 'upload date', fatal=False))
42
43 return {
44 'id': video_id,
45 'title': title,
46 'description': description,
47 'timestamp': timestamp,
48 'formats': [{
49 'url': video_url,
50 'vcodec': 'none',
51 }],
52 }