3 from .common
import InfoExtractor
12 class FreesoundIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?freesound\.org/people/[^/]+/sounds/(?P<id>[^/]+)'
15 'url': 'http://www.freesound.org/people/miklovan/sounds/194503/',
16 'md5': '12280ceb42c81f19a515c745eae07650',
20 'title': 'gulls in the city.wav',
21 'description': 'the sounds of seagulls in the city',
23 'uploader': 'miklovan',
24 'upload_date': '20130715',
29 def _real_extract(self
, url
):
30 audio_id
= self
._match
_id
(url
)
32 webpage
= self
._download
_webpage
(url
, audio_id
)
34 audio_url
= self
._og
_search
_property
('audio', webpage
, 'song url')
35 title
= self
._og
_search
_property
('audio:title', webpage
, 'song title')
37 description
= self
._html
_search
_regex
(
38 r
'(?s)id=["\']sound_description
["\'][^>]*>(.+?)</div>',
39 webpage, 'description', fatal=False)
41 duration = float_or_none(
42 get_element_by_class('duration', webpage), scale=1000)
44 upload_date = unified_strdate(get_element_by_id('sound_date', webpage))
45 uploader = self._og_search_property(
46 'audio:artist', webpage, 'uploader', fatal=False)
48 channels = self._html_search_regex(
49 r'Channels</dt><dd>(.+?)</dd>', webpage,
50 'channels info', fatal=False)
52 tags_str = get_element_by_class('tags', webpage)
53 tags = re.findall(r'<a[^>]+>([^<]+)', tags_str) if tags_str else None
55 audio_url = re.sub(r'^https?://freesound\.org(https?://)', r'\1', audio_url)
56 audio_urls = [audio_url]
59 if LQ_FORMAT in audio_url:
60 audio_urls.append(audio_url.replace(LQ_FORMAT, '-hq.mp3'))
64 'format_note': channels,
66 } for quality, format_url in enumerate(audio_urls)]
71 'description': description,
74 'upload_date': upload_date,