businessinsider.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from .common import InfoExtractor
  2. from .jwplatform import JWPlatformIE
  3. class BusinessInsiderIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:[^/]+\.)?businessinsider\.(?:com|nl)/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  5. _TESTS = [{
  6. 'url': 'http://uk.businessinsider.com/how-much-radiation-youre-exposed-to-in-everyday-life-2016-6',
  7. 'md5': 'ffed3e1e12a6f950aa2f7d83851b497a',
  8. 'info_dict': {
  9. 'id': 'cjGDb0X9',
  10. 'ext': 'mp4',
  11. 'title': 'Bananas give you more radiation exposure than living next to a nuclear power plant',
  12. 'description': 'md5:0175a3baf200dd8fa658f94cade841b3',
  13. 'upload_date': '20160611',
  14. 'timestamp': 1465675620,
  15. },
  16. }, {
  17. 'url': 'https://www.businessinsider.nl/5-scientifically-proven-things-make-you-less-attractive-2017-7/',
  18. 'md5': '43f438dbc6da0b89f5ac42f68529d84a',
  19. 'info_dict': {
  20. 'id': '5zJwd4FK',
  21. 'ext': 'mp4',
  22. 'title': 'Deze dingen zorgen ervoor dat je minder snel een date scoort',
  23. 'description': 'md5:2af8975825d38a4fed24717bbe51db49',
  24. 'upload_date': '20170705',
  25. 'timestamp': 1499270528,
  26. },
  27. }, {
  28. 'url': 'http://www.businessinsider.com/excel-index-match-vlookup-video-how-to-2015-2?IR=T',
  29. 'only_matching': True,
  30. }]
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. webpage = self._download_webpage(url, video_id)
  34. jwplatform_id = self._search_regex(
  35. (r'data-media-id=["\']([a-zA-Z0-9]{8})',
  36. r'id=["\']jwplayer_([a-zA-Z0-9]{8})',
  37. r'id["\']?\s*:\s*["\']?([a-zA-Z0-9]{8})',
  38. r'(?:jwplatform\.com/players/|jwplayer_)([a-zA-Z0-9]{8})'),
  39. webpage, 'jwplatform id')
  40. return self.url_result(
  41. f'jwplatform:{jwplatform_id}', ie=JWPlatformIE.ie_key(),
  42. video_id=video_id)