- 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)
- date = time.gmtime(info['dateCreated']/1000) # The timestamp is in miliseconds
-
- return [{
- 'id': video_id,
- 'url': info['mediaURI'],
- 'ext': 'flv',
- 'title': info['title'],
- 'thumbnail': info['screenshotURI'],
- 'description': info['description'],
- 'uploader': info['user'],
- 'view_count': info['numberOfViews'],
- 'upload_date': u'%04i%02i%02i' % (date.tm_year, date.tm_mon, date.tm_mday),
- }]
+ 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'<source[^>]+src="([^"]+)"', r'"file"\s*:\s*\'([^\']+)'],
+ webpage, 'video url', default=None)
+ info_dict = {
+ 'id': video_id,
+ 'url': video_url,
+ 'ext': 'flv',
+ }
+
+ if not video_url:
+ setup_data = self._parse_json(self._html_search_regex(
+ r'(?s)data-setup=([\'"])(?P<content>(?!\1).+?)\1',
+ webpage, 'setup data', group='content'), video_id)
+ info_dict = {
+ '_type': 'url_transparent',
+ 'url': setup_data['src'],
+ }
+
+ info_dict.update({
+ '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')),
+ })
+
+ return info_dict