]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/freesound.py
debian/control: Remove mplayer2 from recommends. (Closes: #841187)
[youtubedl] / youtube_dl / extractor / freesound.py
1 from __future__ import unicode_literals
2
3 import re
4
5 from .common import InfoExtractor
6
7
8 class FreesoundIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?freesound\.org/people/([^/]+)/sounds/(?P<id>[^/]+)'
10 _TEST = {
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',
19 }
20 }
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
24 music_id = mobj.group('id')
25 webpage = self._download_webpage(url, music_id)
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)
32
33 return {
34 'id': music_id,
35 'title': title,
36 'url': self._og_search_property('audio', webpage, 'music url'),
37 'uploader': self._og_search_property('audio:artist', webpage, 'music uploader'),
38 'description': description,
39 }