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.8 KiB

11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class WorldStarHipHopIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/videos/video\.php\?v=(?P<id>.*)'
  6. _TEST = {
  7. "url": "http://www.worldstarhiphop.com/videos/video.php?v=wshh6a7q1ny0G34ZwuIO",
  8. "md5": "9d04de741161603bf7071bbf4e883186",
  9. "info_dict": {
  10. "id": "wshh6a7q1ny0G34ZwuIO",
  11. "ext": "mp4",
  12. "title": "KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!"
  13. }
  14. }
  15. def _real_extract(self, url):
  16. video_id = self._match_id(url)
  17. webpage = self._download_webpage(url, video_id)
  18. m_vevo_id = re.search(r'videoId=(.*?)&amp?', webpage)
  19. if m_vevo_id is not None:
  20. return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo')
  21. video_url = self._search_regex(
  22. r'so\.addVariable\("file","(.*?)"\)', webpage, 'video URL')
  23. if 'youtube' in video_url:
  24. return self.url_result(video_url, ie='Youtube')
  25. video_title = self._html_search_regex(
  26. r'(?s)<div class="content-heading">\s*<h1>(.*?)</h1>',
  27. webpage, 'title')
  28. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  29. thumbnail = self._html_search_regex(
  30. r'rel="image_src" href="(.*)" />', webpage, 'thumbnail',
  31. fatal=False)
  32. if not thumbnail:
  33. _title = r'candytitles.*>(.*)</span>'
  34. mobj = re.search(_title, webpage)
  35. if mobj is not None:
  36. video_title = mobj.group(1)
  37. return {
  38. 'id': video_id,
  39. 'url': video_url,
  40. 'title': video_title,
  41. 'thumbnail': thumbnail,
  42. }