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.

36 lines
1.5 KiB

  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import determine_ext
  4. class FreesoundIE(InfoExtractor):
  5. _VALID_URL = r'(?:https?://)?(?:www\.)?freesound\.org/people/([^/]+)/sounds/(?P<id>[^/]+)'
  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",
  12. u"uploader" : u"miklovan",
  13. u'description': u'the sounds of seagulls in the city',
  14. }
  15. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. music_id = mobj.group('id')
  19. webpage = self._download_webpage(url, music_id)
  20. title = self._html_search_regex(r'<div id="single_sample_header">.*?<a href="#">(.+?)</a>',
  21. webpage, 'music title', flags=re.DOTALL)
  22. music_url = self._og_search_property('audio', webpage, 'music url')
  23. description = self._html_search_regex(r'<div id="sound_description">(.*?)</div>',
  24. webpage, 'description', fatal=False, flags=re.DOTALL)
  25. return [{
  26. 'id': music_id,
  27. 'title': title,
  28. 'url': music_url,
  29. 'uploader': self._og_search_property('audio:artist', webpage, 'music uploader'),
  30. 'ext': determine_ext(music_url),
  31. 'description': description,
  32. }]