2 from __future__ import unicode_literals
7 from .common import InfoExtractor
14 class VideoEsriIE(InfoExtractor):
15 _VALID_URL = r'https?://video\.esri\.com/watch/(?P<id>[0-9]+)'
17 'url': 'https://video.esri.com/watch/4228',
18 'md5': '170b4d513c2466ed483c150a48384133',
22 'title': 'AppStudio for ArcGIS',
23 'thumbnail': 're:^https?://.*\.jpg$',
24 'upload_date': '20150310',
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
32 title = self._html_search_regex(r'<h1>(.*?)</h1>', webpage, 'title')
34 upload_date_raw = self._search_regex(
35 r'http-equiv="last-modified" content="(.*)"',
36 webpage, 'upload date')
37 upload_date = unified_strdate(upload_date_raw)
39 settings_info = self._search_regex(
40 r'evPlayerSettings = {(.*?);\s*$',
41 webpage, 'settings info', flags=re.MULTILINE | re.DOTALL)
43 # thumbnail includes '_x' for large, also has {_m,_t,_s} or
44 # without size suffix returns full image
45 thumbnail_path = re.findall(
46 r'image\': \'(\/thumbs.*)\'',
50 thumbnail = '/'.join(['http://video.esri.com', thumbnail_path])
52 # note that this misses the (exceedly rare) webm files
53 video_paths = re.findall(r'mp4:(.*)\'', settings_info)
55 # find possible http servers of the mp4 files (also has rtsp)
56 base_url = re.findall(
57 r'netstreambasepath\':\s\'(h.*)\'', settings_info)[0]
59 # these are the numbers used internally, but really map
60 # to other resolutions, e.g. 960 is 720p.
61 heights = [480, 720, 960]
63 for video_path in video_paths:
64 url = "{base_url}{video_path}".format(
66 video_path=video_path)
67 filename, ext = os.path.splitext(video_path)
68 height_label = int(filename.split('_')[1])
69 videos_by_res[height_label] = {
72 'protocol': 'http', # http-only supported currently
76 for height in heights:
77 if height in videos_by_res:
78 formats.append(videos_by_res[height])
83 'upload_date': upload_date,
88 result['thumbnail'] = thumbnail