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.

35 lines
1.4 KiB

  1. # -*- coding: utf-8 -*-
  2. import re
  3. from .common import InfoExtractor
  4. class FreeSoundIE(InfoExtractor):
  5. _VALID_URL = r'(?:http://)?(?:www\.)?freesound\.org/people/([^/]+)/sounds/([^/]+)'
  6. _TEST = {
  7. u'url': u'http://www.freesound.org/people/miklovan/sounds/194503/',
  8. u'file': u'194503.mp3',
  9. u'md5': u'12280ceb42c81f19a515c745eae07650',
  10. u'info_dict': {
  11. u"title": u"gulls in the city.wav by miklovan",
  12. u"uploader" : u"miklovan"
  13. }
  14. }
  15. def _real_extract(self, url):
  16. mobj = re.match(self._VALID_URL, url)
  17. music_id = mobj.group(2)
  18. webpage = self._download_webpage(url, music_id)
  19. title = self._html_search_regex(r'<meta property="og:title" content="([^"]*)"',
  20. webpage, 'music title')
  21. music_url = self._html_search_regex(r'<meta property="og:audio" content="([^"]*)"',
  22. webpage, 'music url')
  23. uploader = self._html_search_regex(r'<meta property="og:audio:artist" content="([^"]*)"',
  24. webpage, 'music uploader')
  25. ext = music_url.split('.')[-1]
  26. return [{
  27. 'id': music_id,
  28. 'title': title,
  29. 'url': music_url,
  30. 'uploader': uploader,
  31. 'ext': ext,
  32. }]