]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/soundgasm.py
[youtube] Force `hl=en` for comments (#594)
[yt-dlp.git] / yt_dlp / extractor / soundgasm.py
CommitLineData
1044f8af 1# coding: utf-8
2from __future__ import unicode_literals
3
4import re
5
6from .common import InfoExtractor
7
ba7aa464 8
1044f8af 9class SoundgasmIE(InfoExtractor):
80af2b73 10 IE_NAME = 'soundgasm'
30e61617 11 _VALID_URL = r'https?://(?:www\.)?soundgasm\.net/u/(?P<user>[0-9a-zA-Z_-]+)/(?P<display_id>[0-9a-zA-Z_-]+)'
1044f8af 12 _TEST = {
13 'url': 'http://soundgasm.net/u/ytdl/Piano-sample',
14 'md5': '010082a2c802c5275bb00030743e75ad',
15 'info_dict': {
16 'id': '88abd86ea000cafe98f96321b23cc1206cbcbcc9',
17 'ext': 'm4a',
30e61617
S
18 'title': 'Piano sample',
19 'description': 'Royalty Free Sample Music',
20 'uploader': 'ytdl',
1044f8af 21 }
22 }
23
24 def _real_extract(self, url):
25 mobj = re.match(self._VALID_URL, url)
30e61617
S
26 display_id = mobj.group('display_id')
27
ba7aa464 28 webpage = self._download_webpage(url, display_id)
30e61617 29
ba7aa464 30 audio_url = self._html_search_regex(
30e61617
S
31 r'(?s)m4a\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
32 'audio URL', group='url')
33
34 title = self._search_regex(
35 r'<div[^>]+\bclass=["\']jp-title[^>]+>([^<]+)',
36 webpage, 'title', default=display_id)
37
ba7aa464 38 description = self._html_search_regex(
30e61617
S
39 (r'(?s)<div[^>]+\bclass=["\']jp-description[^>]+>(.+?)</div>',
40 r'(?s)<li>Description:\s(.*?)<\/li>'),
41 webpage, 'description', fatal=False)
42
43 audio_id = self._search_regex(
44 r'/([^/]+)\.m4a', audio_url, 'audio id', default=display_id)
1044f8af 45
46 return {
47 'id': audio_id,
ba7aa464 48 'display_id': display_id,
1044f8af 49 'url': audio_url,
30e61617
S
50 'vcodec': 'none',
51 'title': title,
52 'description': description,
53 'uploader': mobj.group('user'),
1044f8af 54 }
93b5071f 55
591ab1df 56
93b5071f 57class SoundgasmProfileIE(InfoExtractor):
80af2b73 58 IE_NAME = 'soundgasm:profile'
40969398 59 _VALID_URL = r'https?://(?:www\.)?soundgasm\.net/u/(?P<id>[^/]+)/?(?:\#.*)?$'
93b5071f
LP
60 _TEST = {
61 'url': 'http://soundgasm.net/u/ytdl',
93b5071f 62 'info_dict': {
93b5071f 63 'id': 'ytdl',
3cc57f96
S
64 },
65 'playlist_count': 1,
93b5071f
LP
66 }
67
68 def _real_extract(self, url):
69 profile_id = self._match_id(url)
93b5071f 70
3cc57f96 71 webpage = self._download_webpage(url, profile_id)
93b5071f 72
3cc57f96
S
73 entries = [
74 self.url_result(audio_url, 'Soundgasm')
75 for audio_url in re.findall(r'href="([^"]+/u/%s/[^"]+)' % profile_id, webpage)]
93b5071f 76
3cc57f96 77 return self.playlist_result(entries, profile_id)