]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/newgrounds.py
   1 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   9 class NewgroundsIE(InfoExtractor
): 
  10     _VALID_URL 
= r
'https?://(?:www\.)?newgrounds\.com/audio/listen/(?P<id>[0-9]+)' 
  12         'url': 'http://www.newgrounds.com/audio/listen/549479', 
  13         'md5': 'fe6033d297591288fa1c1f780386f07a', 
  17             'title': 'B7 - BusMode', 
  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
) 
  27         title 
= self
._html
_search
_regex
( 
  28             r
',"name":"([^"]+)",', webpage
, 'music title') 
  29         uploader 
= self
._html
_search
_regex
( 
  30             r
',"artist":"([^"]+)",', webpage
, 'music uploader') 
  32         music_url_json_string 
= self
._html
_search
_regex
( 
  33             r
'({"url":"[^"]+"),', webpage
, 'music url') + '}' 
  34         music_url_json 
= json
.loads(music_url_json_string
) 
  35         music_url 
= music_url_json
['url']