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.

44 lines
1.4 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class WorldStarHipHopIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
  5. IE_NAME = u'WorldStarHipHop'
  6. def _real_extract(self, url):
  7. m = re.match(self._VALID_URL, url)
  8. video_id = m.group('id')
  9. webpage_src = self._download_webpage(url, video_id)
  10. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  11. webpage_src, u'video URL')
  12. if 'mp4' in video_url:
  13. ext = 'mp4'
  14. else:
  15. ext = 'flv'
  16. video_title = self._html_search_regex(r"<title>(.*)</title>",
  17. webpage_src, u'title')
  18. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  19. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  20. webpage_src, u'thumbnail', fatal=False)
  21. if not thumbnail:
  22. _title = r"""candytitles.*>(.*)</span>"""
  23. mobj = re.search(_title, webpage_src)
  24. if mobj is not None:
  25. video_title = mobj.group(1)
  26. results = [{
  27. 'id': video_id,
  28. 'url' : video_url,
  29. 'title' : video_title,
  30. 'thumbnail' : thumbnail,
  31. 'ext' : ext,
  32. }]
  33. return results