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.

40 lines
1.3 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. class WorldStarHipHopIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www|m)\.worldstar(?:candy|hiphop)\.com/(?:videos|android)/video\.php\?.*?\bv=(?P<id>[^&]+)'
  5. _TESTS = [{
  6. 'url': 'http://www.worldstarhiphop.com/videos/video.php?v=wshh6a7q1ny0G34ZwuIO',
  7. 'md5': '9d04de741161603bf7071bbf4e883186',
  8. 'info_dict': {
  9. 'id': 'wshh6a7q1ny0G34ZwuIO',
  10. 'ext': 'mp4',
  11. 'title': 'KO Of The Week: MMA Fighter Gets Knocked Out By Swift Head Kick!'
  12. }
  13. }, {
  14. 'url': 'http://m.worldstarhiphop.com/android/video.php?v=wshh6a7q1ny0G34ZwuIO',
  15. 'only_matching': True,
  16. }]
  17. def _real_extract(self, url):
  18. video_id = self._match_id(url)
  19. webpage = self._download_webpage(url, video_id)
  20. entries = self._parse_html5_media_entries(url, webpage, video_id)
  21. if not entries:
  22. return self.url_result(url, 'Generic')
  23. title = self._html_search_regex(
  24. [r'(?s)<div class="content-heading">\s*<h1>(.*?)</h1>',
  25. r'<span[^>]+class="tc-sp-pinned-title">(.*)</span>'],
  26. webpage, 'title')
  27. info = entries[0]
  28. info.update({
  29. 'id': video_id,
  30. 'title': title,
  31. })
  32. return info