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.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class FreesoundIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?freesound\.org/people/([^/]+)/sounds/(?P<id>[^/]+)'
  6. _TEST = {
  7. 'url': 'http://www.freesound.org/people/miklovan/sounds/194503/',
  8. 'md5': '12280ceb42c81f19a515c745eae07650',
  9. 'info_dict': {
  10. 'id': '194503',
  11. 'ext': 'mp3',
  12. 'title': 'gulls in the city.wav',
  13. 'uploader': 'miklovan',
  14. 'description': 'the sounds of seagulls in the city',
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. music_id = mobj.group('id')
  20. webpage = self._download_webpage(url, music_id)
  21. title = self._html_search_regex(
  22. r'<div id="single_sample_header">.*?<a href="#">(.+?)</a>',
  23. webpage, 'music title', flags=re.DOTALL)
  24. description = self._html_search_regex(
  25. r'<div id="sound_description">(.*?)</div>', webpage, 'description',
  26. fatal=False, flags=re.DOTALL)
  27. return {
  28. 'id': music_id,
  29. 'title': title,
  30. 'url': self._og_search_property('audio', webpage, 'music url'),
  31. 'uploader': self._og_search_property('audio:artist', webpage, 'music uploader'),
  32. 'description': description,
  33. }