]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/patreon.py
5429592a75a9f66fdc9f0e9fb908af9e67559aae
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
13 class PatreonIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?patreon\.com/creation\?hid=(.+)'
17 'url': 'http://www.patreon.com/creation?hid=743933',
18 'md5': 'e25505eec1053a6e6813b8ed369875cc',
22 'title': 'Episode 166: David Smalley of Dogma Debate',
23 'uploader': 'Cognitive Dissonance Podcast',
24 'thumbnail': 're:^https?://.*$',
28 'url': 'http://www.patreon.com/creation?hid=754133',
29 'md5': '3eb09345bf44bf60451b8b0b81759d0a',
33 'title': 'CD 167 Extra',
34 'uploader': 'Cognitive Dissonance Podcast',
35 'thumbnail': 're:^https?://.*$',
40 # Currently Patreon exposes download URL via hidden CSS, so login is not
41 # needed. Keeping this commented for when this inevitably changes.
44 (username, password) = self._get_login_info()
49 'redirectUrl': 'http://www.patreon.com/',
54 request = compat_urllib_request.Request(
55 'https://www.patreon.com/processLogin',
56 compat_urllib_parse.urlencode(login_form).encode('utf-8')
58 login_page = self._download_webpage(request, None, note='Logging in as %s' % username)
60 if re.search(r'onLoginFailed', login_page):
61 raise ExtractorError('Unable to login, incorrect username and/or password', expected=True)
63 def _real_initialize(self):
67 def _real_extract(self
, url
):
68 mobj
= re
.match(self
._VALID
_URL
, url
)
69 video_id
= mobj
.group(1)
71 webpage
= self
._download
_webpage
(url
, video_id
)
72 title
= self
._og
_search
_title
(webpage
).strip()
74 attach_fn
= self
._html
_search
_regex
(
75 r
'<div class="attach"><a target="_blank" href="([^"]+)">',
76 webpage
, 'attachment URL', default
=None)
77 if attach_fn
is not None:
78 video_url
= 'http://www.patreon.com' + attach_fn
79 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
80 uploader
= self
._html
_search
_regex
(
81 r
'<strong>(.*?)</strong> is creating', webpage
, 'uploader')
83 playlist_js
= self
._search
_regex
(
84 r
'(?s)new\s+jPlayerPlaylist\(\s*\{\s*[^}]*},\s*(\[.*?,?\s*\])',
85 webpage
, 'playlist JSON')
86 playlist_json
= js_to_json(playlist_js
)
87 playlist
= json
.loads(playlist_json
)
89 video_url
= self
._proto
_relative
_url
(data
['mp3'])
90 thumbnail
= self
._proto
_relative
_url
(data
.get('cover'))
91 uploader
= data
.get('artist')
99 'thumbnail': thumbnail
,