You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.9 KiB

  1. import re
  2. import json
  3. import time
  4. from .common import InfoExtractor
  5. class DotsubIE(InfoExtractor):
  6. _VALID_URL = r'(?:http://)?(?:www\.)?dotsub\.com/view/([^/]+)'
  7. _TEST = {
  8. u'url': u'http://dotsub.com/view/aed3b8b2-1889-4df5-ae63-ad85f5572f27',
  9. u'file': u'aed3b8b2-1889-4df5-ae63-ad85f5572f27.flv',
  10. u'md5': u'0914d4d69605090f623b7ac329fea66e',
  11. u'info_dict': {
  12. u"title": u"Pyramids of Waste (2010), AKA The Lightbulb Conspiracy - Planned obsolescence documentary",
  13. u"uploader": u"4v4l0n42",
  14. 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',
  15. u'thumbnail': u'http://dotsub.com/media/aed3b8b2-1889-4df5-ae63-ad85f5572f27/p',
  16. u'upload_date': u'20101213',
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. video_id = mobj.group(1)
  22. info_url = "https://dotsub.com/api/media/%s/metadata" %(video_id)
  23. webpage = self._download_webpage(info_url, video_id)
  24. info = json.loads(webpage)
  25. date = time.gmtime(info['dateCreated']/1000) # The timestamp is in miliseconds
  26. return [{
  27. 'id': video_id,
  28. 'url': info['mediaURI'],
  29. 'ext': 'flv',
  30. 'title': info['title'],
  31. 'thumbnail': info['screenshotURI'],
  32. 'description': info['description'],
  33. 'uploader': info['user'],
  34. 'view_count': info['numberOfViews'],
  35. 'upload_date': u'%04i%02i%02i' % (date.tm_year, date.tm_mon, date.tm_mday),
  36. }]