[stretchinternet] Add extractor
[youtube-dl] / youtube_dl / extractor / stretchinternet.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class StretchInternetIE(InfoExtractor):
8     IE_DESC = 'StretchInternet'
9     _VALID_URL = r'https?://.*?stretchinternet\.com/[^/_?].*(?<=eventId=)(?P<id>.*)(?=&).*'
10     _TEST = {
11         'url': 'https://portal.stretchinternet.com/umary/portal.htm?eventId=313900&streamType=video',
12         'info_dict': {
13             'id': '313900',
14             'ext': 'mp4',
15             'title': 'StretchInternet'
16         }
17     }
18
19     def _real_extract(self, url):
20         video_id = self._match_id(url)
21         stream = self._download_json('https://neo-client.stretchinternet.com/streamservice/v1/media/stream/v%s' % video_id, video_id)
22         stream_url = stream.get('source')
23         return {
24             'ie_key': 'Generic',
25             'id': video_id,
26             'url': 'http://%s' % stream_url,
27             'title': 'StretchInternet'
28         }