]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/thesixtyone.py
   2 from __future__ 
import unicode_literals
 
   7 from .common 
import InfoExtractor
 
   8 from ..utils 
import unified_strdate
 
  11 class TheSixtyOneIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'''(?x)https?://(?:www\.)?thesixtyone\.com/ 
  18         )/(?P<id>[A-Za-z0-9]+)/?$''' 
  19     _SONG_URL_TEMPLATE 
= 'http://thesixtyone.com/s/{0:}' 
  20     _SONG_FILE_URL_TEMPLATE 
= 'http://{audio_server:}.thesixtyone.com/thesixtyone_production/audio/{0:}_stream' 
  21     _THUMBNAIL_URL_TEMPLATE 
= '{photo_base_url:}_desktop' 
  24             'url': 'http://www.thesixtyone.com/s/SrE3zD7s1jt/', 
  25             'md5': '821cc43b0530d3222e3e2b70bb4622ea', 
  29                 'title': 'CASIO - Unicorn War Mixtape', 
  30                 'thumbnail': 're:^https?://.*_desktop$', 
  31                 'upload_date': '20071217', 
  36             'url': 'http://www.thesixtyone.com/song/comments/list/SrE3zD7s1jt', 
  37             'only_matching': True, 
  40             'url': 'http://www.thesixtyone.com/s/ULoiyjuJWli#/s/SrE3zD7s1jt/', 
  41             'only_matching': True, 
  44             'url': 'http://www.thesixtyone.com/#/s/SrE3zD7s1jt/', 
  45             'only_matching': True, 
  48             'url': 'http://www.thesixtyone.com/song/SrE3zD7s1jt/', 
  49             'only_matching': True, 
  72     def _real_extract(self
, url
): 
  73         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  74         song_id 
= mobj
.group('id') 
  76         webpage 
= self
._download
_webpage
( 
  77             self
._SONG
_URL
_TEMPLATE
.format(song_id
), song_id
) 
  79         song_data 
= json
.loads(self
._search
_regex
( 
  80             r
'"%s":\s(\{.*?\})' % song_id
, webpage
, 'song_data')) 
  81         keys 
= [self
._DECODE
_MAP
.get(s
, s
) for s 
in song_data
['key']] 
  82         url 
= self
._SONG
_FILE
_URL
_TEMPLATE
.format( 
  83             "".join(reversed(keys
)), **song_data
) 
  93             'title': '{artist:} - {name:}'.format(**song_data
), 
  95             'comment_count': song_data
.get('comments_count'), 
  96             'duration': song_data
.get('play_time'), 
  97             'like_count': song_data
.get('score'), 
  98             'thumbnail': self
._THUMBNAIL
_URL
_TEMPLATE
.format(**song_data
), 
  99             'upload_date': unified_strdate(song_data
.get('publish_date')),