]>
Commit | Line | Data |
---|---|---|
85409a0c JMF |
1 | from __future__ import unicode_literals |
2 | ||
13e06d29 | 3 | from .common import InfoExtractor |
124f3bc6 S |
4 | from ..utils import ( |
5 | float_or_none, | |
6 | int_or_none, | |
7 | ) | |
13e06d29 YK |
8 | |
9 | ||
10 | class DotsubIE(InfoExtractor): | |
124f3bc6 | 11 | _VALID_URL = r'https?://(?:www\.)?dotsub\.com/view/(?P<id>[^/]+)' |
13e06d29 | 12 | _TEST = { |
4245f558 S |
13 | 'url': 'https://dotsub.com/view/9c63db2a-fa95-4838-8e6e-13deafe47f09', |
14 | 'md5': '21c7ff600f545358134fea762a6d42b6', | |
85409a0c | 15 | 'info_dict': { |
4245f558 | 16 | 'id': '9c63db2a-fa95-4838-8e6e-13deafe47f09', |
85409a0c | 17 | 'ext': 'flv', |
4245f558 S |
18 | 'title': 'MOTIVATION - "It\'s Possible" Best Inspirational Video Ever', |
19 | 'description': 'md5:41af1e273edbbdfe4e216a78b9d34ac6', | |
20 | 'thumbnail': 're:^https?://dotsub.com/media/9c63db2a-fa95-4838-8e6e-13deafe47f09/p', | |
21 | 'duration': 198, | |
22 | 'uploader': 'liuxt', | |
23 | 'timestamp': 1385778501.104, | |
24 | 'upload_date': '20131130', | |
124f3bc6 | 25 | 'view_count': int, |
13e06d29 YK |
26 | } |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
124f3bc6 S |
30 | video_id = self._match_id(url) |
31 | ||
32 | info = self._download_json( | |
33 | 'https://dotsub.com/api/media/%s/metadata' % video_id, video_id) | |
34 | video_url = info.get('mediaURI') | |
35 | ||
36 | if not video_url: | |
37 | webpage = self._download_webpage(url, video_id) | |
38 | video_url = self._search_regex( | |
5090d93f S |
39 | [r'<source[^>]+src="([^"]+)"', r'"file"\s*:\s*\'([^\']+)'], |
40 | webpage, 'video url') | |
41bece30 | 41 | |
85409a0c JMF |
42 | return { |
43 | 'id': video_id, | |
124f3bc6 | 44 | 'url': video_url, |
85409a0c JMF |
45 | 'ext': 'flv', |
46 | 'title': info['title'], | |
124f3bc6 S |
47 | 'description': info.get('description'), |
48 | 'thumbnail': info.get('screenshotURI'), | |
49 | 'duration': int_or_none(info.get('duration'), 1000), | |
50 | 'uploader': info.get('user'), | |
51 | 'timestamp': float_or_none(info.get('dateCreated'), 1000), | |
52 | 'view_count': int_or_none(info.get('numberOfViews')), | |
85409a0c | 53 | } |