[patreon] Support vimeo embeds (#349)

Authored by: rhsmachine
This commit is contained in:
rhsmachine 2021-05-27 22:14:43 +05:30 committed by GitHub
parent 177877c544
commit 65af1839c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

View File

@ -2,6 +2,9 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from .vimeo import VimeoIE
from ..compat import compat_urllib_parse_unquote
from ..utils import (
clean_html,
determine_ext,
@ -11,6 +14,7 @@ from ..utils import (
parse_iso8601,
str_or_none,
try_get,
url_or_none
)
@ -63,6 +67,20 @@ class PatreonIE(InfoExtractor):
}, {
'url': 'https://www.patreon.com/posts/743933',
'only_matching': True,
}, {
'url': 'https://www.patreon.com/posts/kitchen-as-seen-51706779',
'md5': '96656690071f6d64895866008484251b',
'info_dict': {
'id': '555089736',
'ext': 'mp4',
'title': 'KITCHEN AS SEEN ON DEEZ NUTS EXTENDED!',
'uploader': 'Cold Ones',
'thumbnail': 're:^https?://.*$',
'upload_date': '20210526',
'description': 'md5:557a409bd79d3898689419094934ba79',
'uploader_id': '14936315',
},
'skip': 'Patron-only content'
}]
# Currently Patreon exposes download URL via hidden CSS, so login is not
@ -136,6 +154,19 @@ class PatreonIE(InfoExtractor):
'uploader_url': user_attributes.get('url'),
})
if not info.get('url'):
# handle Vimeo embeds
if try_get(attributes, lambda x: x['embed']['provider']) == 'Vimeo':
embed_html = try_get(attributes, lambda x: x['embed']['html'])
v_url = url_or_none(compat_urllib_parse_unquote(
self._search_regex(r'src=(https%3A%2F%2Fplayer\.vimeo\.com.+)%3F', embed_html, 'vimeo url', fatal=False)))
if v_url:
info.update({
'_type': 'url_transparent',
'url': VimeoIE._smuggle_referrer(v_url, 'https://patreon.com'),
'ie_key': 'Vimeo',
})
if not info.get('url'):
embed_url = try_get(attributes, lambda x: x['embed']['url'])
if embed_url: