]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/planetaplay.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..utils 
import ExtractorError
 
  10 class PlanetaPlayIE(InfoExtractor
): 
  11     _VALID_URL 
= r
'https?://(?:www\.)?planetaplay\.com/\?sng=(?P<id>[0-9]+)' 
  12     _API_URL 
= 'http://planetaplay.com/action/playlist/?sng={0:}' 
  13     _THUMBNAIL_URL 
= 'http://planetaplay.com/img/thumb/{thumb:}' 
  15         'url': 'http://planetaplay.com/?sng=3586', 
  16         'md5': '9d569dceb7251a4e01355d5aea60f9db', 
  20             'title': 'md5:e829428ee28b1deed00de90de49d1da1', 
  25         'lq': (0, 'http://www.planetaplay.com/videoplayback/{med_hash:}'), 
  26         'hq': (1, 'http://www.planetaplay.com/videoplayback/hi/{med_hash:}'), 
  29     def _real_extract(self
, url
): 
  30         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  31         video_id 
= mobj
.group('id') 
  33         response 
= self
._download
_json
( 
  34             self
._API
_URL
.format(video_id
), video_id
)['response'] 
  36             data 
= response
.get('data')[0] 
  39                 '%s: failed to get the playlist' % self
.IE_NAME
, expected
=True) 
  41         title 
= '{song_artists:} - {sng_name:}'.format(**data
) 
  42         thumbnail 
= self
._THUMBNAIL
_URL
.format(**data
) 
  45         for format_id
, (quality
, url_template
) in self
._SONG
_FORMATS
.items(): 
  47                 'format_id': format_id
, 
  48                 'url': url_template
.format(**data
), 
  53         self
._sort
_formats
(formats
) 
  59             'thumbnail': thumbnail
,