]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/patreon.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..utils
import js_to_json
8 class PatreonIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?patreon\.com/creation\?hid=(?P<id>[^&#]+)'
12 'url': 'http://www.patreon.com/creation?hid=743933',
13 'md5': 'e25505eec1053a6e6813b8ed369875cc',
17 'title': 'Episode 166: David Smalley of Dogma Debate',
18 'uploader': 'Cognitive Dissonance Podcast',
19 'thumbnail': 're:^https?://.*$',
23 'url': 'http://www.patreon.com/creation?hid=754133',
24 'md5': '3eb09345bf44bf60451b8b0b81759d0a',
28 'title': 'CD 167 Extra',
29 'uploader': 'Cognitive Dissonance Podcast',
30 'thumbnail': 're:^https?://.*$',
34 'url': 'https://www.patreon.com/creation?hid=1682498',
38 'title': 'I\'m on Patreon!',
39 'uploader': 'TraciJHines',
40 'thumbnail': 're:^https?://.*$',
41 'upload_date': '20150211',
42 'description': 'md5:c5a706b1f687817a3de09db1eb93acd4',
43 'uploader_id': 'TraciJHines',
47 'skip_download': True,
52 # Currently Patreon exposes download URL via hidden CSS, so login is not
53 # needed. Keeping this commented for when this inevitably changes.
56 (username, password) = self._get_login_info()
61 'redirectUrl': 'http://www.patreon.com/',
66 request = sanitized_Request(
67 'https://www.patreon.com/processLogin',
68 compat_urllib_parse_urlencode(login_form).encode('utf-8')
70 login_page = self._download_webpage(request, None, note='Logging in')
72 if re.search(r'onLoginFailed', login_page):
73 raise ExtractorError('Unable to login, incorrect username and/or password', expected=True)
75 def _real_initialize(self):
79 def _real_extract(self
, url
):
80 video_id
= self
._match
_id
(url
)
81 webpage
= self
._download
_webpage
(url
, video_id
)
82 title
= self
._og
_search
_title
(webpage
).strip()
84 attach_fn
= self
._html
_search
_regex
(
85 r
'<div class="attach"><a target="_blank" href="([^"]+)">',
86 webpage
, 'attachment URL', default
=None)
87 embed
= self
._html
_search
_regex
(
88 r
'<div[^>]+id="watchCreation"[^>]*>\s*<iframe[^>]+src="([^"]+)"',
89 webpage
, 'embedded URL', default
=None)
91 if attach_fn
is not None:
92 video_url
= 'http://www.patreon.com' + attach_fn
93 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
94 uploader
= self
._html
_search
_regex
(
95 r
'<strong>(.*?)</strong> is creating', webpage
, 'uploader')
96 elif embed
is not None:
97 return self
.url_result(embed
)
99 playlist
= self
._parse
_json
(self
._search
_regex
(
100 r
'(?s)new\s+jPlayerPlaylist\(\s*\{\s*[^}]*},\s*(\[.*?,?\s*\])',
101 webpage
, 'playlist JSON'),
102 video_id
, transform_source
=js_to_json
)
104 video_url
= self
._proto
_relative
_url
(data
['mp3'])
105 thumbnail
= self
._proto
_relative
_url
(data
.get('cover'))
106 uploader
= data
.get('artist')
113 'uploader': uploader
,
114 'thumbnail': thumbnail
,