1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-18 08:16:10 +00:00
youtube-dl/youtube_dl/extractor/dotsub.py

54 lines
1.9 KiB
Python
Raw Normal View History

2014-02-10 19:52:53 +00:00
from __future__ import unicode_literals
2013-07-08 19:05:52 +00:00
from .common import InfoExtractor
2015-02-11 16:33:03 +00:00
from ..utils import (
float_or_none,
int_or_none,
)
2013-07-08 19:05:52 +00:00
class DotsubIE(InfoExtractor):
2015-02-11 16:33:03 +00:00
_VALID_URL = r'https?://(?:www\.)?dotsub\.com/view/(?P<id>[^/]+)'
2013-07-08 19:05:52 +00:00
_TEST = {
2016-08-19 23:18:20 +00:00
'url': 'https://dotsub.com/view/9c63db2a-fa95-4838-8e6e-13deafe47f09',
'md5': '21c7ff600f545358134fea762a6d42b6',
2014-02-10 19:52:53 +00:00
'info_dict': {
2016-08-19 23:18:20 +00:00
'id': '9c63db2a-fa95-4838-8e6e-13deafe47f09',
2014-02-10 19:52:53 +00:00
'ext': 'flv',
2016-08-19 23:18:20 +00:00
'title': 'MOTIVATION - "It\'s Possible" Best Inspirational Video Ever',
'description': 'md5:41af1e273edbbdfe4e216a78b9d34ac6',
'thumbnail': 're:^https?://dotsub.com/media/9c63db2a-fa95-4838-8e6e-13deafe47f09/p',
'duration': 198,
'uploader': 'liuxt',
'timestamp': 1385778501.104,
'upload_date': '20131130',
2015-02-11 16:33:03 +00:00
'view_count': int,
2013-07-08 19:05:52 +00:00
}
}
def _real_extract(self, url):
2015-02-11 16:33:03 +00:00
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(
2015-04-24 15:47:13 +00:00
[r'<source[^>]+src="([^"]+)"', r'"file"\s*:\s*\'([^\']+)'],
webpage, 'video url')
2014-02-10 19:52:53 +00:00
return {
'id': video_id,
2015-02-11 16:33:03 +00:00
'url': video_url,
2014-02-10 19:52:53 +00:00
'ext': 'flv',
'title': info['title'],
2015-02-11 16:33:03 +00:00
'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')),
2014-02-10 19:52:53 +00:00
}