- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group(1)
- info_url = "https://dotsub.com/api/media/%s/metadata" %(video_id)
- webpage = self._download_webpage(info_url, video_id)
- info = json.loads(webpage)
- video_url = info['mediaURI']
- uploader = info['user']
- description = info['description']
- view_count = info['numberOfViews']
- title = info['title']
- thumbnail_url = info['screenshotURI']
- ext = 'flv'
- return [{
- 'id': video_id,
- 'url': video_url,
- 'ext': ext,
- 'title': title,
- 'thumbnail': thumbnail_url,
- 'description': description,
- 'uploader': uploader,
- 'view_count': view_count,
- }]
+ video_id = self._match_id(url)
+
+ info = self._download_json(
+ 'https://dotsub.com/api/media/%s/metadata' % video_id, video_id)
+ video_url = info.get('mediaURI')
+
+ if not video_url:
+ webpage = self._download_webpage(url, video_id)
+ video_url = self._search_regex(
+ r'"file"\s*:\s*\'([^\']+)', webpage, 'video url')
+
+ return {
+ 'id': video_id,
+ 'url': video_url,
+ 'ext': 'flv',
+ 'title': info['title'],
+ 'description': info.get('description'),
+ 'thumbnail': info.get('screenshotURI'),
+ 'duration': int_or_none(info.get('duration'), 1000),
+ 'uploader': info.get('user'),
+ 'timestamp': float_or_none(info.get('dateCreated'), 1000),
+ 'view_count': int_or_none(info.get('numberOfViews')),
+ }