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

11 years ago
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": "Video: KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!"
  13. }
  14. }
  15. def _real_extract(self, url):
  16. m = re.match(self._VALID_URL, url)
  17. video_id = m.group('id')
  18. webpage_src = self._download_webpage(url, video_id)
  19. m_vevo_id = re.search(r'videoId=(.*?)&amp?',
  20. webpage_src)
  21. if m_vevo_id is not None:
  22. return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo')
  23. video_url = self._search_regex(
  24. r'so\.addVariable\("file","(.*?)"\)', webpage_src, 'video URL')
  25. if 'youtube' in video_url:
  26. return self.url_result(video_url, ie='Youtube')
  27. video_title = self._html_search_regex(
  28. r"<title>(.*)</title>", webpage_src, 'title')
  29. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  30. thumbnail = self._html_search_regex(
  31. r'rel="image_src" href="(.*)" />', webpage_src, 'thumbnail',
  32. fatal=False)
  33. if not thumbnail:
  34. _title = r"""candytitles.*>(.*)</span>"""
  35. mobj = re.search(_title, webpage_src)
  36. if mobj is not None:
  37. video_title = mobj.group(1)
  38. return {
  39. 'id': video_id,
  40. 'url': video_url,
  41. 'title': video_title,
  42. 'thumbnail': thumbnail,
  43. }