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.

52 lines
1.8 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'"file"\s*:\s*\'([^\']+)', webpage, 'video url')
  34. return {
  35. 'id': video_id,
  36. 'url': video_url,
  37. 'ext': 'flv',
  38. 'title': info['title'],
  39. 'description': info.get('description'),
  40. 'thumbnail': info.get('screenshotURI'),
  41. 'duration': int_or_none(info.get('duration'), 1000),
  42. 'uploader': info.get('user'),
  43. 'timestamp': float_or_none(info.get('dateCreated'), 1000),
  44. 'view_count': int_or_none(info.get('numberOfViews')),
  45. }