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.

56 lines
1.8 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. _TEST = {
  6. "url": "http://www.worldstarhiphop.com/videos/video.php?v=wshh6a7q1ny0G34ZwuIO",
  7. "file": "wshh6a7q1ny0G34ZwuIO.mp4",
  8. "md5": "9d04de741161603bf7071bbf4e883186",
  9. "info_dict": {
  10. "title": "Video: KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!"
  11. }
  12. }
  13. def _real_extract(self, url):
  14. m = re.match(self._VALID_URL, url)
  15. video_id = m.group('id')
  16. webpage_src = self._download_webpage(url, video_id)
  17. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  18. webpage_src, u'video URL')
  19. if 'youtube' in video_url:
  20. self.to_screen(u'Youtube video detected:')
  21. return self.url_result(video_url, ie='Youtube')
  22. if 'mp4' in video_url:
  23. ext = 'mp4'
  24. else:
  25. ext = 'flv'
  26. video_title = self._html_search_regex(r"<title>(.*)</title>",
  27. webpage_src, u'title')
  28. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  29. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  30. webpage_src, u'thumbnail', fatal=False)
  31. if not thumbnail:
  32. _title = r"""candytitles.*>(.*)</span>"""
  33. mobj = re.search(_title, webpage_src)
  34. if mobj is not None:
  35. video_title = mobj.group(1)
  36. results = [{
  37. 'id': video_id,
  38. 'url' : video_url,
  39. 'title' : video_title,
  40. 'thumbnail' : thumbnail,
  41. 'ext' : ext,
  42. }]
  43. return results