]>
Commit | Line | Data |
---|---|---|
bd2d82a5 PH |
1 | from __future__ import unicode_literals |
2 | ||
eb03f4da | 3 | from .common import InfoExtractor |
eb03f4da | 4 | |
d0ae9e3a | 5 | |
eb03f4da | 6 | class NewgroundsIE(InfoExtractor): |
0de968b5 YCH |
7 | _VALID_URL = r'https?://(?:www\.)?newgrounds\.com/(?:audio/listen|portal/view)/(?P<id>[0-9]+)' |
8 | _TESTS = [{ | |
6c3affcb | 9 | 'url': 'https://www.newgrounds.com/audio/listen/549479', |
bd2d82a5 PH |
10 | 'md5': 'fe6033d297591288fa1c1f780386f07a', |
11 | 'info_dict': { | |
d55433bb PH |
12 | 'id': '549479', |
13 | 'ext': 'mp3', | |
14 | 'title': 'B7 - BusMode', | |
15 | 'uploader': 'Burn7', | |
eb03f4da | 16 | } |
0de968b5 | 17 | }, { |
6c3affcb | 18 | 'url': 'https://www.newgrounds.com/portal/view/673111', |
0de968b5 YCH |
19 | 'md5': '3394735822aab2478c31b1004fe5e5bc', |
20 | 'info_dict': { | |
21 | 'id': '673111', | |
22 | 'ext': 'mp4', | |
23 | 'title': 'Dancin', | |
24 | 'uploader': 'Squirrelman82', | |
25 | }, | |
26 | }] | |
eb03f4da R |
27 | |
28 | def _real_extract(self, url): | |
6c3affcb YCH |
29 | media_id = self._match_id(url) |
30 | webpage = self._download_webpage(url, media_id) | |
5f6a1245 | 31 | |
bd2d82a5 | 32 | title = self._html_search_regex( |
0de968b5 YCH |
33 | r'<title>([^>]+)</title>', webpage, 'title') |
34 | ||
bd2d82a5 | 35 | uploader = self._html_search_regex( |
6c3affcb | 36 | r'Author\s*<a[^>]+>([^<]+)', webpage, 'uploader', fatal=False) |
5f6a1245 | 37 | |
6c3affcb YCH |
38 | music_url = self._parse_json(self._search_regex( |
39 | r'"url":("[^"]+"),', webpage, ''), media_id) | |
eb03f4da | 40 | |
d0ae9e3a | 41 | return { |
6c3affcb | 42 | 'id': media_id, |
bd2d82a5 PH |
43 | 'title': title, |
44 | 'url': music_url, | |
eb03f4da | 45 | 'uploader': uploader, |
d0ae9e3a | 46 | } |