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.

77 lines
2.4 KiB

10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class SoundgasmIE(InfoExtractor):
  6. IE_NAME = 'soundgasm'
  7. _VALID_URL = r'https?://(?:www\.)?soundgasm\.net/u/(?P<user>[0-9a-zA-Z_-]+)/(?P<display_id>[0-9a-zA-Z_-]+)'
  8. _TEST = {
  9. 'url': 'http://soundgasm.net/u/ytdl/Piano-sample',
  10. 'md5': '010082a2c802c5275bb00030743e75ad',
  11. 'info_dict': {
  12. 'id': '88abd86ea000cafe98f96321b23cc1206cbcbcc9',
  13. 'ext': 'm4a',
  14. 'title': 'Piano sample',
  15. 'description': 'Royalty Free Sample Music',
  16. 'uploader': 'ytdl',
  17. }
  18. }
  19. def _real_extract(self, url):
  20. mobj = re.match(self._VALID_URL, url)
  21. display_id = mobj.group('display_id')
  22. webpage = self._download_webpage(url, display_id)
  23. audio_url = self._html_search_regex(
  24. r'(?s)m4a\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
  25. 'audio URL', group='url')
  26. title = self._search_regex(
  27. r'<div[^>]+\bclass=["\']jp-title[^>]+>([^<]+)',
  28. webpage, 'title', default=display_id)
  29. description = self._html_search_regex(
  30. (r'(?s)<div[^>]+\bclass=["\']jp-description[^>]+>(.+?)</div>',
  31. r'(?s)<li>Description:\s(.*?)<\/li>'),
  32. webpage, 'description', fatal=False)
  33. audio_id = self._search_regex(
  34. r'/([^/]+)\.m4a', audio_url, 'audio id', default=display_id)
  35. return {
  36. 'id': audio_id,
  37. 'display_id': display_id,
  38. 'url': audio_url,
  39. 'vcodec': 'none',
  40. 'title': title,
  41. 'description': description,
  42. 'uploader': mobj.group('user'),
  43. }
  44. class SoundgasmProfileIE(InfoExtractor):
  45. IE_NAME = 'soundgasm:profile'
  46. _VALID_URL = r'https?://(?:www\.)?soundgasm\.net/u/(?P<id>[^/]+)/?(?:\#.*)?$'
  47. _TEST = {
  48. 'url': 'http://soundgasm.net/u/ytdl',
  49. 'info_dict': {
  50. 'id': 'ytdl',
  51. },
  52. 'playlist_count': 1,
  53. }
  54. def _real_extract(self, url):
  55. profile_id = self._match_id(url)
  56. webpage = self._download_webpage(url, profile_id)
  57. entries = [
  58. self.url_result(audio_url, 'Soundgasm')
  59. for audio_url in re.findall(r'href="([^"]+/u/%s/[^"]+)' % profile_id, webpage)]
  60. return self.playlist_result(entries, profile_id)