]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/newgrounds.py
debian/changelog: Fix spelling of Re-enable to please lintian.
[youtubedl] / youtube_dl / extractor / newgrounds.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class NewgroundsIE(InfoExtractor):
7 _VALID_URL = r'https?://(?:www\.)?newgrounds\.com/(?:audio/listen|portal/view)/(?P<id>[0-9]+)'
8 _TESTS = [{
9 'url': 'https://www.newgrounds.com/audio/listen/549479',
10 'md5': 'fe6033d297591288fa1c1f780386f07a',
11 'info_dict': {
12 'id': '549479',
13 'ext': 'mp3',
14 'title': 'B7 - BusMode',
15 'uploader': 'Burn7',
16 }
17 }, {
18 'url': 'https://www.newgrounds.com/portal/view/673111',
19 'md5': '3394735822aab2478c31b1004fe5e5bc',
20 'info_dict': {
21 'id': '673111',
22 'ext': 'mp4',
23 'title': 'Dancin',
24 'uploader': 'Squirrelman82',
25 },
26 }]
27
28 def _real_extract(self, url):
29 media_id = self._match_id(url)
30 webpage = self._download_webpage(url, media_id)
31
32 title = self._html_search_regex(
33 r'<title>([^>]+)</title>', webpage, 'title')
34
35 uploader = self._html_search_regex(
36 r'Author\s*<a[^>]+>([^<]+)', webpage, 'uploader', fatal=False)
37
38 music_url = self._parse_json(self._search_regex(
39 r'"url":("[^"]+"),', webpage, ''), media_id)
40
41 return {
42 'id': media_id,
43 'title': title,
44 'url': music_url,
45 'uploader': uploader,
46 }