1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-18 12:57:18 +01:00
youtube-dl/youtube_dl/extractor/dotsub.py

53 lines
1.8 KiB
Python
Raw Normal View History

2014-02-10 20:52:53 +01:00
from __future__ import unicode_literals
2013-07-08 21:05:52 +02:00
from .common import InfoExtractor
2015-02-11 17:33:03 +01:00
from ..utils import (
float_or_none,
int_or_none,
)
2013-07-08 21:05:52 +02:00
class DotsubIE(InfoExtractor):
2015-02-11 17:33:03 +01:00
_VALID_URL = r'https?://(?:www\.)?dotsub\.com/view/(?P<id>[^/]+)'
2013-07-08 21:05:52 +02:00
_TEST = {
2014-02-10 20:52:53 +01:00
'url': 'http://dotsub.com/view/aed3b8b2-1889-4df5-ae63-ad85f5572f27',
'md5': '0914d4d69605090f623b7ac329fea66e',
'info_dict': {
'id': 'aed3b8b2-1889-4df5-ae63-ad85f5572f27',
'ext': 'flv',
'title': 'Pyramids of Waste (2010), AKA The Lightbulb Conspiracy - Planned obsolescence documentary',
2015-02-11 17:33:03 +01:00
'description': 'md5:699a0f7f50aeec6042cb3b1db2d0d074',
'thumbnail': 're:^https?://dotsub.com/media/aed3b8b2-1889-4df5-ae63-ad85f5572f27/p',
'duration': 3169,
2014-02-10 20:52:53 +01:00
'uploader': '4v4l0n42',
2015-02-11 17:33:03 +01:00
'timestamp': 1292248482.625,
2014-02-10 20:52:53 +01:00
'upload_date': '20101213',
2015-02-11 17:33:03 +01:00
'view_count': int,
2013-07-08 21:05:52 +02:00
}
}
def _real_extract(self, url):
2015-02-11 17:33:03 +01: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(
r'"file"\s*:\s*\'([^\']+)', webpage, 'video url')
2014-02-10 20:52:53 +01:00
return {
'id': video_id,
2015-02-11 17:33:03 +01:00
'url': video_url,
2014-02-10 20:52:53 +01:00
'ext': 'flv',
'title': info['title'],
2015-02-11 17:33:03 +01: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 20:52:53 +01:00
}