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