]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/freesound.py
[vimeo:watchlater] Fix extraction (Closes #3886)
[yt-dlp.git] / youtube_dl / extractor / freesound.py
CommitLineData
34bd9878
JMF
1from __future__ import unicode_literals
2
5d9b7505
YK
3import re
4
5from .common import InfoExtractor
34bd9878 6
5d9b7505 7
67de24e4 8class FreesoundIE(InfoExtractor):
34bd9878 9 _VALID_URL = r'https?://(?:www\.)?freesound\.org/people/([^/]+)/sounds/(?P<id>[^/]+)'
76650102 10 _TEST = {
34bd9878
JMF
11 'url': 'http://www.freesound.org/people/miklovan/sounds/194503/',
12 'md5': '12280ceb42c81f19a515c745eae07650',
13 'info_dict': {
14 'id': '194503',
15 'ext': 'mp3',
16 'title': 'gulls in the city.wav',
17 'uploader': 'miklovan',
18 'description': 'the sounds of seagulls in the city',
76650102
YK
19 }
20 }
5d9b7505
YK
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
67de24e4 24 music_id = mobj.group('id')
5d9b7505 25 webpage = self._download_webpage(url, music_id)
34bd9878
JMF
26 title = self._html_search_regex(
27 r'<div id="single_sample_header">.*?<a href="#">(.+?)</a>',
28 webpage, 'music title', flags=re.DOTALL)
29 description = self._html_search_regex(
30 r'<div id="sound_description">(.*?)</div>', webpage, 'description',
31 fatal=False, flags=re.DOTALL)
5d9b7505 32
34bd9878
JMF
33 return {
34 'id': music_id,
35 'title': title,
36 'url': self._og_search_property('audio', webpage, 'music url'),
67de24e4 37 'uploader': self._og_search_property('audio:artist', webpage, 'music uploader'),
67de24e4 38 'description': description,
34bd9878 39 }