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.

47 lines
1.6 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. _TEST = {
  7. u'url': u"http://www.hotnewhiphop.com/freddie-gibbs-lay-it-down-song.1435540.html'",
  8. u'file': u'1435540.mp3',
  9. u'md5': u'2c2cd2f76ef11a9b3b581e8b232f3d96',
  10. u'info_dict': {
  11. u"title": u"Freddie Gibbs Songs - Lay It Down"
  12. }
  13. }
  14. def _real_extract(self, url):
  15. m = re.match(self._VALID_URL, url)
  16. video_id = m.group('id')
  17. webpage_src = self._download_webpage(url, video_id)
  18. video_url_base64 = self._search_regex(r'data-path="(.*?)"',
  19. webpage_src, u'video URL', fatal=False)
  20. if video_url_base64 == None:
  21. video_url = self._search_regex(r'"contentUrl" content="(.*?)"', webpage_src,
  22. u'video URL')
  23. return self.url_result(video_url, ie='Youtube')
  24. video_url = base64.b64decode(video_url_base64).decode('utf-8')
  25. video_title = self._html_search_regex(r"<title>(.*)</title>",
  26. webpage_src, u'title')
  27. # Getting thumbnail and if not thumbnail sets correct title for WSHH candy video.
  28. thumbnail = self._html_search_regex(r'"og:image" content="(.*)"',
  29. webpage_src, u'thumbnail', fatal=False)
  30. results = [{
  31. 'id': video_id,
  32. 'url' : video_url,
  33. 'title' : video_title,
  34. 'thumbnail' : thumbnail,
  35. 'ext' : 'mp3',
  36. }]
  37. return results