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.

74 lines
2.5 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. month_by_name,
  6. int_or_none,
  7. )
  8. class NDTVIE(InfoExtractor):
  9. _VALID_URL = r'^https?://(?:www\.)?ndtv\.com/video/player/[^/]*/[^/]*/(?P<id>[a-z0-9]+)'
  10. _TEST = {
  11. 'url': 'http://www.ndtv.com/video/player/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': 'http://i.ndtvimg.com/video/images/vod/medium/2013-12/big_300710_1386518307.jpg',
  21. },
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. webpage = self._download_webpage(url, video_id)
  27. filename = self._search_regex(
  28. r"__filename='([^']+)'", webpage, 'video filename')
  29. video_url = ('http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' %
  30. filename)
  31. duration = int_or_none(self._search_regex(
  32. r"__duration='([^']+)'", webpage, 'duration', fatal=False))
  33. date_m = re.search(r'''(?x)
  34. <p\s+class="vod_dateline">\s*
  35. Published\s+On:\s*
  36. (?P<monthname>[A-Za-z]+)\s+(?P<day>[0-9]+),\s*(?P<year>[0-9]+)
  37. ''', webpage)
  38. upload_date = None
  39. if date_m is not None:
  40. month = month_by_name(date_m.group('monthname'))
  41. if month is not None:
  42. upload_date = '%s%02d%02d' % (
  43. date_m.group('year'), month, int(date_m.group('day')))
  44. description = self._og_search_description(webpage)
  45. READ_MORE = ' (Read more)'
  46. if description.endswith(READ_MORE):
  47. description = description[:-len(READ_MORE)]
  48. title = self._og_search_title(webpage)
  49. TITLE_SUFFIX = ' - NDTV'
  50. if title.endswith(TITLE_SUFFIX):
  51. title = title[:-len(TITLE_SUFFIX)]
  52. return {
  53. 'id': video_id,
  54. 'url': video_url,
  55. 'title': title,
  56. 'description': description,
  57. 'thumbnail': self._og_search_thumbnail(webpage),
  58. 'duration': duration,
  59. 'upload_date': upload_date,
  60. }