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