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.

53 lines
1.6 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. _TEST = {
  9. u'url': u'http://www.youjizz.com/videos/zeichentrick-1-2189178.html',
  10. u'file': u'2189178.flv',
  11. u'md5': u'07e15fa469ba384c7693fd246905547c',
  12. u'info_dict': {
  13. u"title": u"Zeichentrick 1"
  14. }
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('videoid')
  19. # Get webpage content
  20. webpage = self._download_webpage(url, video_id)
  21. # Get the video title
  22. video_title = self._html_search_regex(r'<title>(?P<title>.*)</title>',
  23. webpage, u'title').strip()
  24. # Get the embed page
  25. result = re.search(r'https?://www.youjizz.com/videos/embed/(?P<videoid>[0-9]+)', webpage)
  26. if result is None:
  27. raise ExtractorError(u'ERROR: unable to extract embed page')
  28. embed_page_url = result.group(0).strip()
  29. video_id = result.group('videoid')
  30. webpage = self._download_webpage(embed_page_url, video_id)
  31. # Get the video URL
  32. video_url = self._search_regex(r'so.addVariable\("file",encodeURIComponent\("(?P<source>[^"]+)"\)\);',
  33. webpage, u'video URL')
  34. info = {'id': video_id,
  35. 'url': video_url,
  36. 'title': video_title,
  37. 'ext': 'flv',
  38. 'format': 'flv',
  39. 'player_url': embed_page_url}
  40. return [info]