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.

41 lines
1.5 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|cdn\.jwplayer)\.com/(?:(?:feed|player|thumb|preview|video)s|jw6|v2/media)/|jwplatform:)(?P<id>[a-zA-Z0-9]{8})'
  7. _TESTS = [{
  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. 'url': 'https://cdn.jwplayer.com/players/nPripu9l-ALJ3XQCI.js',
  20. 'only_matching': True,
  21. }]
  22. @staticmethod
  23. def _extract_url(webpage):
  24. urls = JWPlatformIE._extract_urls(webpage)
  25. return urls[0] if urls else None
  26. @staticmethod
  27. def _extract_urls(webpage):
  28. return re.findall(
  29. r'<(?:script|iframe)[^>]+?src=["\']((?:https?:)?//content\.jwplatform\.com/players/[a-zA-Z0-9]{8})',
  30. webpage)
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. json_data = self._download_json('https://cdn.jwplayer.com/v2/media/' + video_id, video_id)
  34. return self._parse_jwplayer_data(json_data, video_id)