]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/patreon.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  10 class PatreonIE(InfoExtractor
): 
  11     _VALID_URL 
= r
'https?://(?:www\.)?patreon\.com/creation\?hid=(?P<id>[^&#]+)' 
  14             'url': 'http://www.patreon.com/creation?hid=743933', 
  15             'md5': 'e25505eec1053a6e6813b8ed369875cc', 
  19                 'title': 'Episode 166: David Smalley of Dogma Debate', 
  20                 'uploader': 'Cognitive Dissonance Podcast', 
  21                 'thumbnail': 're:^https?://.*$', 
  25             'url': 'http://www.patreon.com/creation?hid=754133', 
  26             'md5': '3eb09345bf44bf60451b8b0b81759d0a', 
  30                 'title': 'CD 167 Extra', 
  31                 'uploader': 'Cognitive Dissonance Podcast', 
  32                 'thumbnail': 're:^https?://.*$', 
  36             'url': 'https://www.patreon.com/creation?hid=1682498', 
  40                 'title': 'I\'m on Patreon!', 
  41                 'uploader': 'TraciJHines', 
  42                 'thumbnail': 're:^https?://.*$', 
  43                 'upload_date': '20150211', 
  44                 'description': 'md5:c5a706b1f687817a3de09db1eb93acd4', 
  45                 'uploader_id': 'TraciJHines', 
  49                 'skip_download': True, 
  54     # Currently Patreon exposes download URL via hidden CSS, so login is not 
  55     # needed. Keeping this commented for when this inevitably changes. 
  58         (username, password) = self._get_login_info() 
  63             'redirectUrl': 'http://www.patreon.com/', 
  68         request = compat_urllib_request.Request( 
  69             'https://www.patreon.com/processLogin', 
  70             compat_urllib_parse.urlencode(login_form).encode('utf-8') 
  72         login_page = self._download_webpage(request, None, note='Logging in as %s' % username) 
  74         if re.search(r'onLoginFailed', login_page): 
  75             raise ExtractorError('Unable to login, incorrect username and/or password', expected=True) 
  77     def _real_initialize(self): 
  81     def _real_extract(self
, url
): 
  82         video_id 
= self
._match
_id
(url
) 
  83         webpage 
= self
._download
_webpage
(url
, video_id
) 
  84         title 
= self
._og
_search
_title
(webpage
).strip() 
  86         attach_fn 
= self
._html
_search
_regex
( 
  87             r
'<div class="attach"><a target="_blank" href="([^"]+)">', 
  88             webpage
, 'attachment URL', default
=None) 
  89         embed 
= self
._html
_search
_regex
( 
  90             r
'<div id="watchCreation">\s*<iframe class="embedly-embed" src="([^"]+)"', 
  91             webpage
, 'embedded URL', default
=None) 
  93         if attach_fn 
is not None: 
  94             video_url 
= 'http://www.patreon.com' + attach_fn
 
  95             thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
  96             uploader 
= self
._html
_search
_regex
( 
  97                 r
'<strong>(.*?)</strong> is creating', webpage
, 'uploader') 
  98         elif embed 
is not None: 
  99             return self
.url_result(embed
) 
 101             playlist 
= self
._parse
_json
(self
._search
_regex
( 
 102                 r
'(?s)new\s+jPlayerPlaylist\(\s*\{\s*[^}]*},\s*(\[.*?,?\s*\])', 
 103                 webpage
, 'playlist JSON'), 
 104                 video_id
, transform_source
=js_to_json
) 
 106             video_url 
= self
._proto
_relative
_url
(data
['mp3']) 
 107             thumbnail 
= self
._proto
_relative
_url
(data
.get('cover')) 
 108             uploader 
= data
.get('artist') 
 115             'uploader': uploader
, 
 116             'thumbnail': thumbnail
,