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.

32 lines
1.2 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from .youtube import YoutubeIE
  4. class UnityIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?unity3d\.com/learn/tutorials/(?:[^/]+/)*(?P<id>[^/?#&]+)'
  6. _TESTS = [{
  7. 'url': 'https://unity3d.com/learn/tutorials/topics/animation/animate-anything-mecanim',
  8. 'info_dict': {
  9. 'id': 'jWuNtik0C8E',
  10. 'ext': 'mp4',
  11. 'title': 'Live Training 22nd September 2014 - Animate Anything',
  12. 'description': 'md5:e54913114bd45a554c56cdde7669636e',
  13. 'duration': 2893,
  14. 'uploader': 'Unity',
  15. 'uploader_id': 'Unity3D',
  16. 'upload_date': '20140926',
  17. }
  18. }, {
  19. 'url': 'https://unity3d.com/learn/tutorials/projects/2d-ufo-tutorial/following-player-camera?playlist=25844',
  20. 'only_matching': True,
  21. }]
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. youtube_id = self._search_regex(
  26. r'data-video-id="([_0-9a-zA-Z-]+)"',
  27. webpage, 'youtube ID')
  28. return self.url_result(youtube_id, ie=YoutubeIE.ie_key(), video_id=video_id)