unity.py 1.2 KB

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