You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

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