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.

49 lines
1.7 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urlparse
  5. from ..utils import (
  6. ExtractorError,
  7. js_to_json,
  8. )
  9. class ScreencastOMaticIE(InfoExtractor):
  10. _VALID_URL = r'https?://screencast-o-matic\.com/watch/(?P<id>[0-9a-zA-Z]+)'
  11. _TEST = {
  12. 'url': 'http://screencast-o-matic.com/watch/c2lD3BeOPl',
  13. 'md5': '483583cb80d92588f15ccbedd90f0c18',
  14. 'info_dict': {
  15. 'id': 'c2lD3BeOPl',
  16. 'ext': 'mp4',
  17. 'title': 'Welcome to 3-4 Philosophy @ DECV!',
  18. 'thumbnail': 're:^https?://.*\.jpg$',
  19. 'description': 'as the title says! also: some general info re 1) VCE philosophy and 2) distance learning.',
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. setup_js = self._search_regex(
  26. r"(?s)jwplayer\('mp4Player'\).setup\((\{.*?\})\);",
  27. webpage, 'setup code')
  28. data = self._parse_json(setup_js, video_id, transform_source=js_to_json)
  29. try:
  30. video_data = next(
  31. m for m in data['modes'] if m.get('type') == 'html5')
  32. except StopIteration:
  33. raise ExtractorError('Could not find any video entries!')
  34. video_url = compat_urlparse.urljoin(url, video_data['config']['file'])
  35. thumbnail = data.get('image')
  36. return {
  37. 'id': video_id,
  38. 'title': self._og_search_title(webpage),
  39. 'description': self._og_search_description(webpage),
  40. 'url': video_url,
  41. 'ext': 'mp4',
  42. 'thumbnail': thumbnail,
  43. }