1
0
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-12-23 09:56:43 +00:00
youtube-dl/youtube_dl/extractor/ndtv.py

55 lines
1.9 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
2013-12-09 18:39:41 +00:00
from .common import InfoExtractor
from ..utils import (
int_or_none,
2016-05-18 22:34:19 +00:00
remove_end,
unified_strdate,
)
2013-12-09 18:39:41 +00:00
class NDTVIE(InfoExtractor):
2016-05-18 22:34:19 +00:00
_VALID_URL = r'https?://(?:www\.)?ndtv\.com/video/(?:[^/]+/)+[^/?^&]+-(?P<id>\d+)'
2013-12-09 18:39:41 +00:00
_TEST = {
2016-05-18 22:34:19 +00:00
'url': 'http://www.ndtv.com/video/news/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal-300710',
'md5': '39f992dbe5fb531c395d8bbedb1e5e88',
'info_dict': {
'id': '300710',
'ext': 'mp4',
'title': "NDTV exclusive: Don't need character certificate from Rahul Gandhi, says Arvind Kejriwal",
'description': 'md5:ab2d4b4a6056c5cb4caa6d729deabf02',
'upload_date': '20131208',
'duration': 1327,
'thumbnail': r're:https?://.*\.jpg',
2013-12-09 18:39:41 +00:00
},
}
def _real_extract(self, url):
2015-01-19 09:10:05 +00:00
video_id = self._match_id(url)
2013-12-09 18:39:41 +00:00
webpage = self._download_webpage(url, video_id)
2016-05-18 22:34:19 +00:00
title = remove_end(self._og_search_title(webpage), ' - NDTV')
2013-12-09 18:39:41 +00:00
filename = self._search_regex(
r"__filename='([^']+)'", webpage, 'video filename')
2016-05-18 22:34:19 +00:00
video_url = 'http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' % filename
2013-12-09 18:39:41 +00:00
duration = int_or_none(self._search_regex(
r"__duration='([^']+)'", webpage, 'duration', fatal=False))
2013-12-09 18:39:41 +00:00
2016-05-18 22:34:19 +00:00
upload_date = unified_strdate(self._html_search_meta(
'publish-date', webpage, 'upload date', fatal=False))
2013-12-09 18:39:41 +00:00
2016-05-18 22:34:19 +00:00
description = remove_end(self._og_search_description(webpage), ' (Read more)')
2013-12-09 18:39:41 +00:00
return {
'id': video_id,
'url': video_url,
'title': title,
2013-12-09 18:39:41 +00:00
'description': description,
'thumbnail': self._og_search_thumbnail(webpage),
'duration': duration,
'upload_date': upload_date,
}