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