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.

39 lines
1.3 KiB

  1. import re
  2. import base64
  3. from .common import InfoExtractor
  4. class HotNewHipHopIE(InfoExtractor):
  5. _VALID_URL = r'http://www\.hotnewhiphop.com/.*\.(?P<id>.*)\.html'
  6. def _real_extract(self, url):
  7. m = re.match(self._VALID_URL, url)
  8. video_id = m.group('id')
  9. webpage_src = self._download_webpage(url, video_id)
  10. video_url_base64 = self._search_regex(r'data-path="(.*?)"',
  11. webpage_src, u'video URL', fatal=False)
  12. if video_url_base64 == None:
  13. video_url = self._search_regex(r'"contentUrl" content="(.*?)"', webpage_src,
  14. u'video URL')
  15. return self.url_result(video_url, ie='Youtube')
  16. video_url = base64.b64decode(video_url_base64).decode('utf-8')
  17. video_title = self._html_search_regex(r"<title>(.*)</title>",
  18. webpage_src, u'title')
  19. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  20. thumbnail = self._html_search_regex(r'"og:image" content="(.*)"',
  21. webpage_src, u'thumbnail', fatal=False)
  22. results = [{
  23. 'id': video_id,
  24. 'url' : video_url,
  25. 'title' : video_title,
  26. 'thumbnail' : thumbnail,
  27. 'ext' : 'mp3',
  28. }]
  29. return results