Added an IE for freesound.org
[youtube-dl] / youtube_dl / extractor / freesound.py
1 # -*- coding: utf-8 -*-
2 import re
3
4 from .common import InfoExtractor
5
6 class FreeSoundIE(InfoExtractor):
7     _VALID_URL = r'(?:http://)?(?:www\.)?freesound\.org/people/([^/]+)/sounds/([^/]+)'
8
9     def _real_extract(self, url):
10         mobj = re.match(self._VALID_URL, url)
11         music_id = mobj.group(2)
12         webpage = self._download_webpage(url, music_id)
13         title = self._html_search_regex(r'<meta property="og:title" content="([^"]*)"',
14                                 webpage, 'music title')
15         music_url = self._html_search_regex(r'<meta property="og:audio" content="([^"]*)"',
16                                 webpage, 'music url')       
17         uploader = self._html_search_regex(r'<meta property="og:audio:artist" content="([^"]*)"',
18                                 webpage, 'music uploader')                                                                        
19         ext = music_url.split('.')[-1]
20
21         return [{
22             'id':       music_id,
23             'title':    title,            
24             'url':      music_url,
25             'uploader': uploader,
26             'ext':      ext,
27         }]