worldstarhiphop.py 1.3 KB

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