]>
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 = { |
85409a0c JMF |
13 | 'url': 'http://dotsub.com/view/aed3b8b2-1889-4df5-ae63-ad85f5572f27', |
14 | 'md5': '0914d4d69605090f623b7ac329fea66e', | |
15 | 'info_dict': { | |
16 | 'id': 'aed3b8b2-1889-4df5-ae63-ad85f5572f27', | |
17 | 'ext': 'flv', | |
18 | 'title': 'Pyramids of Waste (2010), AKA The Lightbulb Conspiracy - Planned obsolescence documentary', | |
124f3bc6 S |
19 | 'description': 'md5:699a0f7f50aeec6042cb3b1db2d0d074', |
20 | 'thumbnail': 're:^https?://dotsub.com/media/aed3b8b2-1889-4df5-ae63-ad85f5572f27/p', | |
21 | 'duration': 3169, | |
85409a0c | 22 | 'uploader': '4v4l0n42', |
124f3bc6 | 23 | 'timestamp': 1292248482.625, |
85409a0c | 24 | 'upload_date': '20101213', |
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( | |
39 | r'"file"\s*:\s*\'([^\']+)', webpage, 'video url') | |
41bece30 | 40 | |
85409a0c JMF |
41 | return { |
42 | 'id': video_id, | |
124f3bc6 | 43 | 'url': video_url, |
85409a0c JMF |
44 | 'ext': 'flv', |
45 | 'title': info['title'], | |
124f3bc6 S |
46 | 'description': info.get('description'), |
47 | 'thumbnail': info.get('screenshotURI'), | |
48 | 'duration': int_or_none(info.get('duration'), 1000), | |
49 | 'uploader': info.get('user'), | |
50 | 'timestamp': float_or_none(info.get('dateCreated'), 1000), | |
51 | 'view_count': int_or_none(info.get('numberOfViews')), | |
85409a0c | 52 | } |