[Filmweb] Add extractor
[youtube-dl] / youtube_dl / extractor / twentythreevideo.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class TwentyThreeVideoIE(InfoExtractor):
7     IE_NAME = '23video'
8     _VALID_URL = r'https?://(?:www\.)?(?P<client>[\w-]+)\.23video\.com/v.ihtml/player.html.*photo_id=(?P<id>\d+)'
9     _TEST = {}
10
11     _URL_TEMPLATE = 'https://%s.23video.com/%s/%s/%s/%s/download-video.mp4'
12     _FORMATS = {
13         'video_hd': {
14             'width': 1280,
15             'height': 720,
16         },
17         'video_medium': {
18             'width': 640,
19             'height': 360,
20         },
21         'video_mobile_high': {
22             'width': 320,
23             'height': 180,
24         }
25     }
26
27     def _extract_formats(self, url, client_id):
28         client_name = self._search_regex(r'([a-z]+)\.23video\.com', url, 'client name')
29         video_id = self._search_regex(r'photo%5fid=([^?&]+)', url, 'video id')
30         token = self._search_regex(r'token=([^?&]+)', url, 'token')
31
32         formats = []
33         for format_key in self._FORMATS.keys():
34             formats.append({
35                 'url': self._URL_TEMPLATE % (client_name, client_id, video_id,
36                     token, format_key),
37                 'width': self._FORMATS.get(format_key, {}).get('width'),
38                 'height': self._FORMATS.get(format_key, {}).get('height'),
39             })
40
41         return formats
42
43     def _real_extract(self, url):
44         # TODO: Find out how to extract client_id
45         raise NotImplementedError('Not able to extract the `client_id`')