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.

63 lines
2.1 KiB

11 years ago
11 years ago
11 years ago
  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. m_vevo_id = re.search(r'videoId=(.*?)&amp?',
  18. webpage_src)
  19. if m_vevo_id is not None:
  20. self.to_screen(u'Vevo video detected:')
  21. return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo')
  22. video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)',
  23. webpage_src, u'video URL')
  24. if 'youtube' in video_url:
  25. self.to_screen(u'Youtube video detected:')
  26. return self.url_result(video_url, ie='Youtube')
  27. if 'mp4' in video_url:
  28. ext = 'mp4'
  29. else:
  30. ext = 'flv'
  31. video_title = self._html_search_regex(r"<title>(.*)</title>",
  32. webpage_src, u'title')
  33. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  34. thumbnail = self._html_search_regex(r'rel="image_src" href="(.*)" />',
  35. webpage_src, u'thumbnail', fatal=False)
  36. if not thumbnail:
  37. _title = r"""candytitles.*>(.*)</span>"""
  38. mobj = re.search(_title, webpage_src)
  39. if mobj is not None:
  40. video_title = mobj.group(1)
  41. results = [{
  42. 'id': video_id,
  43. 'url' : video_url,
  44. 'title' : video_title,
  45. 'thumbnail' : thumbnail,
  46. 'ext' : ext,
  47. }]
  48. return results