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.

64 lines
2.5 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import month_by_name
  4. class NDTVIE(InfoExtractor):
  5. _VALID_URL = r'^https?://(?:www\.)?ndtv\.com/video/player/[^/]*/[^/]*/(?P<id>[a-z0-9]+)'
  6. _TEST = {
  7. u"url": u"http://www.ndtv.com/video/player/news/ndtv-exclusive-don-t-need-character-certificate-from-rahul-gandhi-says-arvind-kejriwal/300710",
  8. u"file": u"300710.mp4",
  9. u"md5": u"39f992dbe5fb531c395d8bbedb1e5e88",
  10. u"info_dict": {
  11. u"title": u"NDTV exclusive: Don't need character certificate from Rahul Gandhi, says Arvind Kejriwal",
  12. u"description": u"In an exclusive interview to NDTV, Aam Aadmi Party's Arvind Kejriwal says it makes no difference to him that Rahul Gandhi said the Congress needs to learn from his party.",
  13. u"upload_date": u"20131208",
  14. u"duration": 1327,
  15. u"thumbnail": u"http://i.ndtvimg.com/video/images/vod/medium/2013-12/big_300710_1386518307.jpg",
  16. },
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. filename = self._search_regex(
  23. r"__filename='([^']+)'", webpage, u'video filename')
  24. video_url = (u'http://bitcast-b.bitgravity.com/ndtvod/23372/ndtv/%s' %
  25. filename)
  26. duration_str = filename = self._search_regex(
  27. r"__duration='([^']+)'", webpage, u'duration', fatal=False)
  28. duration = None if duration_str is None else int(duration_str)
  29. date_m = re.search(r'''(?x)
  30. <p\s+class="vod_dateline">\s*
  31. Published\s+On:\s*
  32. (?P<monthname>[A-Za-z]+)\s+(?P<day>[0-9]+),\s*(?P<year>[0-9]+)
  33. ''', webpage)
  34. upload_date = None
  35. assert date_m
  36. if date_m is not None:
  37. month = month_by_name(date_m.group('monthname'))
  38. if month is not None:
  39. upload_date = '%s%02d%02d' % (
  40. date_m.group('year'), month, int(date_m.group('day')))
  41. description = self._og_search_description(webpage)
  42. READ_MORE = u' (Read more)'
  43. if description.endswith(READ_MORE):
  44. description = description[:-len(READ_MORE)]
  45. return {
  46. 'id': video_id,
  47. 'url': video_url,
  48. 'title': self._og_search_title(webpage),
  49. 'description': description,
  50. 'thumbnail': self._og_search_thumbnail(webpage),
  51. 'duration': duration,
  52. 'upload_date': upload_date,
  53. }