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.

45 lines
1.3 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. ExtractorError,
  5. )
  6. class YouJizzIE(InfoExtractor):
  7. _VALID_URL = r'^(?:https?://)?(?:\w+\.)?youjizz\.com/videos/(?P<videoid>[^.]+).html$'
  8. def _real_extract(self, url):
  9. mobj = re.match(self._VALID_URL, url)
  10. video_id = mobj.group('videoid')
  11. # Get webpage content
  12. webpage = self._download_webpage(url, video_id)
  13. # Get the video title
  14. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  15. webpage, u'title').strip()
  16. # Get the embed page
  17. result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
  18. if result is None:
  19. raise ExtractorError(u'ERROR: unable to extract embed page')
  20. embed_page_url = result.group(0).strip()
  21. video_id = result.group('videoid')
  22. webpage = self._download_webpage(embed_page_url, video_id)
  23. # Get the video URL
  24. video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
  25. webpage, u'video URL')
  26. info = {'id': video_id,
  27. 'url': video_url,
  28. 'title': video_title,
  29. 'ext': 'flv',
  30. 'format': 'flv',
  31. 'player_url': embed_page_url}
  32. return [info]