logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

onionstudios.py (1931B)


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