]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/freesound.py
Imported Upstream version 2013.10.23
[youtubedl] / youtube_dl / extractor / freesound.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import determine_ext
5
6 class FreesoundIE(InfoExtractor):
7 _VALID_URL = r'(?:https?://)?(?:www\.)?freesound\.org/people/([^/]+)/sounds/(?P<id>[^/]+)'
8 _TEST = {
9 u'url': u'http://www.freesound.org/people/miklovan/sounds/194503/',
10 u'file': u'194503.mp3',
11 u'md5': u'12280ceb42c81f19a515c745eae07650',
12 u'info_dict': {
13 u"title": u"gulls in the city.wav",
14 u"uploader" : u"miklovan",
15 u'description': u'the sounds of seagulls in the city',
16 }
17 }
18
19 def _real_extract(self, url):
20 mobj = re.match(self._VALID_URL, url)
21 music_id = mobj.group('id')
22 webpage = self._download_webpage(url, music_id)
23 title = self._html_search_regex(r'<div id="single_sample_header">.*?<a href="#">(.+?)</a>',
24 webpage, 'music title', flags=re.DOTALL)
25 music_url = self._og_search_property('audio', webpage, 'music url')
26 description = self._html_search_regex(r'<div id="sound_description">(.*?)</div>',
27 webpage, 'description', fatal=False, flags=re.DOTALL)
28
29 return [{
30 'id': music_id,
31 'title': title,
32 'url': music_url,
33 'uploader': self._og_search_property('audio:artist', webpage, 'music uploader'),
34 'ext': determine_ext(music_url),
35 'description': description,
36 }]