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.

64 lines
2.3 KiB

12 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|android)/video\.php\?v=(?P<id>.*)'
  6. _TESTS = [{
  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. 'url': 'http://m.worldstarhiphop.com/android/video.php?v=wshh6a7q1ny0G34ZwuIO',
  16. 'md5': 'dc1c76c83ecc4190bb1eb143899b87d3',
  17. 'info_dict': {
  18. 'id': 'wshh6a7q1ny0G34ZwuIO',
  19. 'ext': 'mp4',
  20. 'title': 'KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!'
  21. }
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. m_vevo_id = re.search(r'videoId=(.*?)&amp?', webpage)
  27. if m_vevo_id is not None:
  28. return self.url_result('vevo:%s' % m_vevo_id.group(1), ie='Vevo')
  29. video_url = self._search_regex(
  30. [r'so\.addVariable\("file","(.*?)"\)',
  31. r'<div class="artlist">\s*<a[^>]+href="([^"]+)">'],
  32. webpage, 'video URL')
  33. if 'youtube' in video_url:
  34. return self.url_result(video_url, ie='Youtube')
  35. video_title = self._html_search_regex(
  36. [r'(?s)<div class="content-heading">\s*<h1>(.*?)</h1>',
  37. r'<span[^>]+class="tc-sp-pinned-title">(.*)</span>'],
  38. webpage, 'title')
  39. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  40. thumbnail = self._html_search_regex(
  41. r'rel="image_src" href="(.*)" />', webpage, 'thumbnail',
  42. default=None)
  43. if not thumbnail:
  44. _title = r'candytitles.*>(.*)</span>'
  45. mobj = re.search(_title, webpage)
  46. if mobj is not None:
  47. video_title = mobj.group(1)
  48. return {
  49. 'id': video_id,
  50. 'url': video_url,
  51. 'title': video_title,
  52. 'thumbnail': thumbnail,
  53. }