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.

72 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. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. filename = self._search_regex(
  27. r"__filename='([^']+)'", webpage, 'video filename')
  28. video_url = ('http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' %
  29. filename)
  30. duration = int_or_none(self._search_regex(
  31. r"__duration='([^']+)'", webpage, 'duration', fatal=False))
  32. date_m = re.search(r'''(?x)
  33. <p\s+class="vod_dateline">\s*
  34. Published\s+On:\s*
  35. (?P<monthname>[A-Za-z]+)\s+(?P<day>[0-9]+),\s*(?P<year>[0-9]+)
  36. ''', webpage)
  37. upload_date = None
  38. if date_m is not None:
  39. month = month_by_name(date_m.group('monthname'))
  40. if month is not None:
  41. upload_date = '%s%02d%02d' % (
  42. date_m.group('year'), month, int(date_m.group('day')))
  43. description = self._og_search_description(webpage)
  44. READ_MORE = ' (Read more)'
  45. if description.endswith(READ_MORE):
  46. description = description[:-len(READ_MORE)]
  47. title = self._og_search_title(webpage)
  48. TITLE_SUFFIX = ' - NDTV'
  49. if title.endswith(TITLE_SUFFIX):
  50. title = title[:-len(TITLE_SUFFIX)]
  51. return {
  52. 'id': video_id,
  53. 'url': video_url,
  54. 'title': title,
  55. 'description': description,
  56. 'thumbnail': self._og_search_thumbnail(webpage),
  57. 'duration': duration,
  58. 'upload_date': upload_date,
  59. }