onionstudios.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from .common import InfoExtractor
  2. from ..compat import compat_str
  3. from ..utils import js_to_json
  4. class OnionStudiosIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?onionstudios\.com/(?:video(?:s/[^/]+-|/)|embed\?.*\bid=)(?P<id>\d+)(?!-)'
  6. _EMBED_REGEX = [r'(?s)<(?:iframe|bulbs-video)[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?onionstudios\.com/(?:embed.+?|video/\d+\.json))\1']
  7. _TESTS = [{
  8. 'url': 'http://www.onionstudios.com/videos/hannibal-charges-forward-stops-for-a-cocktail-2937',
  9. 'md5': '5a118d466d62b5cd03647cf2c593977f',
  10. 'info_dict': {
  11. 'id': '3459881',
  12. 'ext': 'mp4',
  13. 'title': 'Hannibal charges forward, stops for a cocktail',
  14. 'description': 'md5:545299bda6abf87e5ec666548c6a9448',
  15. 'thumbnail': r're:^https?://.*\.jpg$',
  16. 'uploader': 'a.v. club',
  17. 'upload_date': '20150619',
  18. 'timestamp': 1434728546,
  19. },
  20. }, {
  21. 'url': 'http://www.onionstudios.com/embed?id=2855&autoplay=true',
  22. 'only_matching': True,
  23. }, {
  24. 'url': 'http://www.onionstudios.com/video/6139.json',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. video_id = self._match_id(url)
  29. webpage = self._download_webpage(
  30. 'http://onionstudios.com/embed/dc94dc2899fe644c0e7241fa04c1b732.js',
  31. video_id)
  32. mcp_id = compat_str(self._parse_json(self._search_regex(
  33. r'window\.mcpMapping\s*=\s*({.+?});', webpage,
  34. 'MCP Mapping'), video_id, js_to_json)[video_id]['mcp_id'])
  35. return self.url_result(
  36. 'http://kinja.com/ajax/inset/iframe?id=mcp-' + mcp_id,
  37. 'KinjaEmbed', mcp_id)