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.

48 lines
1.5 KiB

  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. compat_parse_qs,
  7. compat_urllib_request,
  8. )
  9. class ScreencastIE(InfoExtractor):
  10. _VALID_URL = r'https?://www\.screencast\.com/t/(?P<id>[a-zA-Z0-9]+)'
  11. _TEST = {
  12. 'url': 'http://www.screencast.com/t/3ZEjQXlT',
  13. 'md5': '917df1c13798a3e96211dd1561fded83',
  14. 'info_dict': {
  15. 'id': '3ZEjQXlT',
  16. 'ext': 'm4v',
  17. 'title': 'Color Measurement with Ocean Optics Spectrometers',
  18. 'description': 'md5:240369cde69d8bed61349a199c5fb153',
  19. 'thumbnail': 're:^https?://.*\.jpg$'
  20. }
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. webpage = self._download_webpage(url, video_id)
  26. flash_vars_s = self._html_search_regex(
  27. r'<param name="flashVars" value="([^"]+)"', webpage, 'flash vars')
  28. flash_vars = compat_parse_qs(flash_vars_s)
  29. thumbnail = flash_vars.get('thumb', [None])[0]
  30. video_url_raw = compat_urllib_request.quote(flash_vars['content'][0])
  31. video_url = video_url_raw.replace('http%3A', 'http:')
  32. title = self._og_search_title(webpage)
  33. description = self._og_search_description(webpage)
  34. return {
  35. 'id': video_id,
  36. 'url': video_url,
  37. 'title': title,
  38. 'description': description,
  39. 'thumbnail': thumbnail,
  40. }