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.

38 lines
1.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class JWPlatformIE(InfoExtractor):
  6. _VALID_URL = r'(?:https?://content\.jwplatform\.com/(?:feeds|players|jw6)/|jwplatform:)(?P<id>[a-zA-Z0-9]{8})'
  7. _TEST = {
  8. 'url': 'http://content.jwplatform.com/players/nPripu9l-ALJ3XQCI.js',
  9. 'md5': 'fa8899fa601eb7c83a64e9d568bdf325',
  10. 'info_dict': {
  11. 'id': 'nPripu9l',
  12. 'ext': 'mov',
  13. 'title': 'Big Buck Bunny Trailer',
  14. 'description': 'Big Buck Bunny is a short animated film by the Blender Institute. It is made using free and open source software.',
  15. 'upload_date': '20081127',
  16. 'timestamp': 1227796140,
  17. }
  18. }
  19. @staticmethod
  20. def _extract_url(webpage):
  21. urls = JWPlatformIE._extract_urls(webpage)
  22. return urls[0] if urls else None
  23. @staticmethod
  24. def _extract_urls(webpage):
  25. return re.findall(
  26. r'<(?:script|iframe)[^>]+?src=["\']((?:https?:)?//content\.jwplatform\.com/players/[a-zA-Z0-9]{8})',
  27. webpage)
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. json_data = self._download_json('http://content.jwplatform.com/feeds/%s.json' % video_id, video_id)
  31. return self._parse_jwplayer_data(json_data, video_id)