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.

40 lines
1.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class SoundgasmIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?soundgasm\.net/u/(?P<user>[0-9a-zA-Z_\-]+)/(?P<title>[0-9a-zA-Z_\-]+)'
  7. _TEST = {
  8. 'url': 'http://soundgasm.net/u/ytdl/Piano-sample',
  9. 'md5': '010082a2c802c5275bb00030743e75ad',
  10. 'info_dict': {
  11. 'id': '88abd86ea000cafe98f96321b23cc1206cbcbcc9',
  12. 'ext': 'm4a',
  13. 'title': 'ytdl_Piano-sample',
  14. 'description': 'Royalty Free Sample Music'
  15. }
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. display_id = mobj.group('title')
  20. audio_title = mobj.group('user') + '_' + mobj.group('title')
  21. webpage = self._download_webpage(url, display_id)
  22. audio_url = self._html_search_regex(
  23. r'(?s)m4a\:\s"([^"]+)"', webpage, 'audio URL')
  24. audio_id = re.split('\/|\.', audio_url)[-2]
  25. description = self._html_search_regex(
  26. r'(?s)<li>Description:\s(.*?)<\/li>', webpage, 'description',
  27. fatal=False)
  28. return {
  29. 'id': audio_id,
  30. 'display_id': display_id,
  31. 'url': audio_url,
  32. 'title': audio_title,
  33. 'description': description
  34. }