logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

screencastomatic.py (1985B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. get_element_by_class,
  6. int_or_none,
  7. remove_start,
  8. strip_or_none,
  9. unified_strdate,
  10. )
  11. class ScreencastOMaticIE(InfoExtractor):
  12. _VALID_URL = r'https?://screencast-o-matic\.com/(?:(?:watch|player)/|embed\?.*?\bsc=)(?P<id>[0-9a-zA-Z]+)'
  13. _TESTS = [{
  14. 'url': 'http://screencast-o-matic.com/watch/c2lD3BeOPl',
  15. 'md5': '483583cb80d92588f15ccbedd90f0c18',
  16. 'info_dict': {
  17. 'id': 'c2lD3BeOPl',
  18. 'ext': 'mp4',
  19. 'title': 'Welcome to 3-4 Philosophy @ DECV!',
  20. 'thumbnail': r're:^https?://.*\.jpg$',
  21. 'description': 'as the title says! also: some general info re 1) VCE philosophy and 2) distance learning.',
  22. 'duration': 369,
  23. 'upload_date': '20141216',
  24. }
  25. }, {
  26. 'url': 'http://screencast-o-matic.com/player/c2lD3BeOPl',
  27. 'only_matching': True,
  28. }, {
  29. 'url': 'http://screencast-o-matic.com/embed?ff=true&sc=cbV2r4Q5TL&fromPH=true&a=1',
  30. 'only_matching': True,
  31. }]
  32. def _real_extract(self, url):
  33. video_id = self._match_id(url)
  34. webpage = self._download_webpage(
  35. 'https://screencast-o-matic.com/player/' + video_id, video_id)
  36. info = self._parse_html5_media_entries(url, webpage, video_id)[0]
  37. info.update({
  38. 'id': video_id,
  39. 'title': get_element_by_class('overlayTitle', webpage),
  40. 'description': strip_or_none(get_element_by_class('overlayDescription', webpage)) or None,
  41. 'duration': int_or_none(self._search_regex(
  42. r'player\.duration\s*=\s*function\(\)\s*{\s*return\s+(\d+);\s*};',
  43. webpage, 'duration', default=None)),
  44. 'upload_date': unified_strdate(remove_start(
  45. get_element_by_class('overlayPublished', webpage), 'Published: ')),
  46. })
  47. return info