]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dotsub.py
Merge tag 'upstream/2013.08.17'
[youtubedl] / youtube_dl / extractor / dotsub.py
1 import re
2 import json
3 import time
4
5 from .common import InfoExtractor
6
7
8 class DotsubIE(InfoExtractor):
9 _VALID_URL = r'(?:http://)?(?:www\.)?dotsub\.com/view/([^/]+)'
10 _TEST = {
11 u'url': u'http://dotsub.com/view/aed3b8b2-1889-4df5-ae63-ad85f5572f27',
12 u'file': u'aed3b8b2-1889-4df5-ae63-ad85f5572f27.flv',
13 u'md5': u'0914d4d69605090f623b7ac329fea66e',
14 u'info_dict': {
15 u"title": u"Pyramids of Waste (2010), AKA The Lightbulb Conspiracy - Planned obsolescence documentary",
16 u"uploader": u"4v4l0n42",
17 u'description': u'Pyramids of Waste (2010) also known as "The lightbulb conspiracy" is a documentary about how our economic system based on consumerism and planned obsolescence is breaking our planet down.\r\n\r\nSolutions to this can be found at:\r\nhttp://robotswillstealyourjob.com\r\nhttp://www.federicopistono.org\r\n\r\nhttp://opensourceecology.org\r\nhttp://thezeitgeistmovement.com',
18 u'thumbnail': u'http://dotsub.com/media/aed3b8b2-1889-4df5-ae63-ad85f5572f27/p',
19 u'upload_date': u'20101213',
20 }
21 }
22
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25 video_id = mobj.group(1)
26 info_url = "https://dotsub.com/api/media/%s/metadata" %(video_id)
27 webpage = self._download_webpage(info_url, video_id)
28 info = json.loads(webpage)
29 date = time.gmtime(info['dateCreated']/1000) # The timestamp is in miliseconds
30
31 return [{
32 'id': video_id,
33 'url': info['mediaURI'],
34 'ext': 'flv',
35 'title': info['title'],
36 'thumbnail': info['screenshotURI'],
37 'description': info['description'],
38 'uploader': info['user'],
39 'view_count': info['numberOfViews'],
40 'upload_date': u'%04i%02i%02i' % (date.tm_year, date.tm_mon, date.tm_mday),
41 }]