2 from __future__ import unicode_literals
4 from .common import InfoExtractor
12 class AparatIE(InfoExtractor):
13 _VALID_URL = r'https?://(?:www\.)?aparat\.com/(?:v/|video/video/embed/videohash/)(?P<id>[a-zA-Z0-9]+)'
16 'url': 'http://www.aparat.com/v/wP8On',
17 'md5': '131aca2e14fe7c4dcb3c4877ba300c89',
21 'title': 'تیم گلکسی 11 - زومیت',
24 # 'skip': 'Extremely unreliable',
27 def _real_extract(self, url):
28 video_id = self._match_id(url)
30 # Note: There is an easier-to-parse configuration at
31 # http://www.aparat.com/video/video/config/videohash/%video_id
32 # but the URL in there does not work
33 webpage = self._download_webpage(
34 'http://www.aparat.com/video/video/embed/vt/frame/showvideo/yes/videohash/' + video_id,
37 file_list = self._parse_json(
39 r'var options\s*=\s*JSON\.parse\(\'([^\']+)\'\)', webpage,
43 title = file_list['plugins']['sabaPlayerPlugin']['title']
46 for list in file_list['plugins']['sabaPlayerPlugin']['multiSRC']:
48 file_url = url_or_none(item.get('src'))
51 ext = mimetype2ext(item.get('type'))
52 label = item.get('label')
56 'format_id': label or ext,
57 'height': int_or_none(self._search_regex(
58 r'(\d+)[pP]', label or '', 'height', default=None)),
60 self._sort_formats(formats)
62 thumbnail = file_list['poster']
67 'thumbnail': thumbnail,
68 'age_limit': self._family_friendly_search(webpage),