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.

53 lines
1.9 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. float_or_none,
  5. int_or_none,
  6. )
  7. class DotsubIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?dotsub\.com/view/(?P<id>[^/]+)'
  9. _TEST = {
  10. 'url': 'http://dotsub.com/view/aed3b8b2-1889-4df5-ae63-ad85f5572f27',
  11. 'md5': '0914d4d69605090f623b7ac329fea66e',
  12. 'info_dict': {
  13. 'id': 'aed3b8b2-1889-4df5-ae63-ad85f5572f27',
  14. 'ext': 'flv',
  15. 'title': 'Pyramids of Waste (2010), AKA The Lightbulb Conspiracy - Planned obsolescence documentary',
  16. 'description': 'md5:699a0f7f50aeec6042cb3b1db2d0d074',
  17. 'thumbnail': 're:^https?://dotsub.com/media/aed3b8b2-1889-4df5-ae63-ad85f5572f27/p',
  18. 'duration': 3169,
  19. 'uploader': '4v4l0n42',
  20. 'timestamp': 1292248482.625,
  21. 'upload_date': '20101213',
  22. 'view_count': int,
  23. }
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. info = self._download_json(
  28. 'https://dotsub.com/api/media/%s/metadata' % video_id, video_id)
  29. video_url = info.get('mediaURI')
  30. if not video_url:
  31. webpage = self._download_webpage(url, video_id)
  32. video_url = self._search_regex(
  33. [r'<source[^>]+src="([^"]+)"', r'"file"\s*:\s*\'([^\']+)'],
  34. webpage, 'video url')
  35. return {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'ext': 'flv',
  39. 'title': info['title'],
  40. 'description': info.get('description'),
  41. 'thumbnail': info.get('screenshotURI'),
  42. 'duration': int_or_none(info.get('duration'), 1000),
  43. 'uploader': info.get('user'),
  44. 'timestamp': float_or_none(info.get('dateCreated'), 1000),
  45. 'view_count': int_or_none(info.get('numberOfViews')),
  46. }