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