logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

localnews8.py (1728B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class LocalNews8IE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?localnews8\.com/(?:[^/]+/)*(?P<display_id>[^/]+)/(?P<id>[0-9]+)'
  7. _TEST = {
  8. 'url': 'http://www.localnews8.com/news/rexburg-business-turns-carbon-fiber-scraps-into-wedding-rings/35183304',
  9. 'md5': 'be4d48aea61aa2bde7be2ee47691ad20',
  10. 'info_dict': {
  11. 'id': '35183304',
  12. 'display_id': 'rexburg-business-turns-carbon-fiber-scraps-into-wedding-rings',
  13. 'ext': 'mp4',
  14. 'title': 'Rexburg business turns carbon fiber scraps into wedding ring',
  15. 'description': 'The process was first invented by Lamborghini and less than a dozen companies around the world use it.',
  16. 'duration': 153,
  17. 'timestamp': 1441844822,
  18. 'upload_date': '20150910',
  19. 'uploader_id': 'api',
  20. }
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. display_id = mobj.group('display_id')
  26. webpage = self._download_webpage(url, display_id)
  27. partner_id = self._search_regex(
  28. r'partnerId\s*[:=]\s*(["\'])(?P<id>\d+)\1',
  29. webpage, 'partner id', group='id')
  30. kaltura_id = self._search_regex(
  31. r'videoIdString\s*[:=]\s*(["\'])kaltura:(?P<id>[0-9a-z_]+)\1',
  32. webpage, 'videl id', group='id')
  33. return {
  34. '_type': 'url_transparent',
  35. 'url': 'kaltura:%s:%s' % (partner_id, kaltura_id),
  36. 'ie_key': 'Kaltura',
  37. 'id': video_id,
  38. 'display_id': display_id,
  39. }