]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/ndtv.py
release 2017.10.01
[yt-dlp.git] / youtube_dl / extractor / ndtv.py
CommitLineData
3141feb7
S
1from __future__ import unicode_literals
2
caefb1de 3from .common import InfoExtractor
3141feb7 4from ..utils import (
3141feb7 5 int_or_none,
dd81769c
S
6 remove_end,
7 unified_strdate,
3141feb7 8)
caefb1de
PH
9
10
11class NDTVIE(InfoExtractor):
dd81769c 12 _VALID_URL = r'https?://(?:www\.)?ndtv\.com/video/(?:[^/]+/)+[^/?^&]+-(?P<id>\d+)'
caefb1de
PH
13
14 _TEST = {
dd81769c 15 'url': 'http://www.ndtv.com/video/news/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal-300710',
3141feb7
S
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,
ec85ded8 24 'thumbnail': r're:https?://.*\.jpg',
caefb1de
PH
25 },
26 }
27
28 def _real_extract(self, url):
c511f13f 29 video_id = self._match_id(url)
caefb1de
PH
30 webpage = self._download_webpage(url, video_id)
31
dd81769c
S
32 title = remove_end(self._og_search_title(webpage), ' - NDTV')
33
caefb1de 34 filename = self._search_regex(
3141feb7 35 r"__filename='([^']+)'", webpage, 'video filename')
dd81769c 36 video_url = 'http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' % filename
caefb1de 37
3141feb7
S
38 duration = int_or_none(self._search_regex(
39 r"__duration='([^']+)'", webpage, 'duration', fatal=False))
caefb1de 40
dd81769c
S
41 upload_date = unified_strdate(self._html_search_meta(
42 'publish-date', webpage, 'upload date', fatal=False))
caefb1de 43
dd81769c 44 description = remove_end(self._og_search_description(webpage), ' (Read more)')
3141feb7 45
caefb1de
PH
46 return {
47 'id': video_id,
48 'url': video_url,
3141feb7 49 'title': title,
caefb1de
PH
50 'description': description,
51 'thumbnail': self._og_search_thumbnail(webpage),
52 'duration': duration,
53 'upload_date': upload_date,
54 }