]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ndtv.py
debian/rules: Adapt to new upstream build system.
[youtubedl] / youtube_dl / extractor / ndtv.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 int_or_none,
6 remove_end,
7 unified_strdate,
8 )
9
10
11 class NDTVIE(InfoExtractor):
12 _VALID_URL = r'https?://(?:www\.)?ndtv\.com/video/(?:[^/]+/)+[^/?^&]+-(?P<id>\d+)'
13
14 _TEST = {
15 'url': 'http://www.ndtv.com/video/news/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal-300710',
16 'md5': '39f992dbe5fb531c395d8bbedb1e5e88',
17 'info_dict': {
18 'id': '300710',
19 'ext': 'mp4',
20 'title': "NDTV exclusive: Don't need character certificate from Rahul Gandhi, says Arvind Kejriwal",
21 'description': 'md5:ab2d4b4a6056c5cb4caa6d729deabf02',
22 'upload_date': '20131208',
23 'duration': 1327,
24 'thumbnail': 're:https?://.*\.jpg',
25 },
26 }
27
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
31
32 title = remove_end(self._og_search_title(webpage), ' - NDTV')
33
34 filename = self._search_regex(
35 r"__filename='([^']+)'", webpage, 'video filename')
36 video_url = 'http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' % filename
37
38 duration = int_or_none(self._search_regex(
39 r"__duration='([^']+)'", webpage, 'duration', fatal=False))
40
41 upload_date = unified_strdate(self._html_search_meta(
42 'publish-date', webpage, 'upload date', fatal=False))
43
44 description = remove_end(self._og_search_description(webpage), ' (Read more)')
45
46 return {
47 'id': video_id,
48 'url': video_url,
49 'title': title,
50 'description': description,
51 'thumbnail': self._og_search_thumbnail(webpage),
52 'duration': duration,
53 'upload_date': upload_date,
54 }