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.

48 lines
1.5 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 'youtube' in video_url:
  13. self.to_screen(u'Youtube video detected:')
  14. return self.url_result(video_url, ie='Youtube')
  15. if 'mp4' in video_url:
  16. ext = 'mp4'
  17. else:
  18. ext = 'flv'
  19. video_title = self._html_search_regex(r"<title>(.*)</title>",
  20. webpage_src, u'title')
  21. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  22. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  23. webpage_src, u'thumbnail', fatal=False)
  24. if not thumbnail:
  25. _title = r"""candytitles.*>(.*)</span>"""
  26. mobj = re.search(_title, webpage_src)
  27. if mobj is not None:
  28. video_title = mobj.group(1)
  29. results = [{
  30. 'id': video_id,
  31. 'url' : video_url,
  32. 'title' : video_title,
  33. 'thumbnail' : thumbnail,
  34. 'ext' : ext,
  35. }]
  36. return results