mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-11 02:37:18 +08:00
Merge pull request #155 from ytdl-org/master
[pull] master from ytdl-org:master
This commit is contained in:
commit
0dd6682e0a
@ -146,6 +146,11 @@ class DPlayIE(InfoExtractor):
|
|||||||
video = self._download_json(
|
video = self._download_json(
|
||||||
disco_base + 'content/videos/' + display_id, display_id,
|
disco_base + 'content/videos/' + display_id, display_id,
|
||||||
headers=headers, query={
|
headers=headers, query={
|
||||||
|
'fields[channel]': 'name',
|
||||||
|
'fields[image]': 'height,src,width',
|
||||||
|
'fields[show]': 'name',
|
||||||
|
'fields[tag]': 'name',
|
||||||
|
'fields[video]': 'description,episodeNumber,name,publishStart,seasonNumber,videoDuration',
|
||||||
'include': 'images,primaryChannel,show,tags'
|
'include': 'images,primaryChannel,show,tags'
|
||||||
})
|
})
|
||||||
video_id = video['data']['id']
|
video_id = video['data']['id']
|
||||||
@ -226,7 +231,6 @@ class DPlayIE(InfoExtractor):
|
|||||||
'series': series,
|
'series': series,
|
||||||
'season_number': int_or_none(info.get('seasonNumber')),
|
'season_number': int_or_none(info.get('seasonNumber')),
|
||||||
'episode_number': int_or_none(info.get('episodeNumber')),
|
'episode_number': int_or_none(info.get('episodeNumber')),
|
||||||
'age_limit': int_or_none(info.get('minimum_age')),
|
|
||||||
'creator': creator,
|
'creator': creator,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
'thumbnails': thumbnails,
|
'thumbnails': thumbnails,
|
||||||
|
@ -6,7 +6,11 @@ from ..utils import (
|
|||||||
clean_html,
|
clean_html,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
KNOWN_EXTENSIONS,
|
||||||
|
mimetype2ext,
|
||||||
parse_iso8601,
|
parse_iso8601,
|
||||||
|
str_or_none,
|
||||||
|
try_get,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +28,7 @@ class PatreonIE(InfoExtractor):
|
|||||||
'thumbnail': 're:^https?://.*$',
|
'thumbnail': 're:^https?://.*$',
|
||||||
'timestamp': 1406473987,
|
'timestamp': 1406473987,
|
||||||
'upload_date': '20140727',
|
'upload_date': '20140727',
|
||||||
|
'uploader_id': '87145',
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://www.patreon.com/creation?hid=754133',
|
'url': 'http://www.patreon.com/creation?hid=754133',
|
||||||
@ -90,7 +95,13 @@ class PatreonIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
post = self._download_json(
|
post = self._download_json(
|
||||||
'https://www.patreon.com/api/posts/' + video_id, video_id)
|
'https://www.patreon.com/api/posts/' + video_id, video_id, query={
|
||||||
|
'fields[media]': 'download_url,mimetype,size_bytes',
|
||||||
|
'fields[post]': 'comment_count,content,embed,image,like_count,post_file,published_at,title',
|
||||||
|
'fields[user]': 'full_name,url',
|
||||||
|
'json-api-use-default-includes': 'false',
|
||||||
|
'include': 'media,user',
|
||||||
|
})
|
||||||
attributes = post['data']['attributes']
|
attributes = post['data']['attributes']
|
||||||
title = attributes['title'].strip()
|
title = attributes['title'].strip()
|
||||||
image = attributes.get('image') or {}
|
image = attributes.get('image') or {}
|
||||||
@ -104,33 +115,42 @@ class PatreonIE(InfoExtractor):
|
|||||||
'comment_count': int_or_none(attributes.get('comment_count')),
|
'comment_count': int_or_none(attributes.get('comment_count')),
|
||||||
}
|
}
|
||||||
|
|
||||||
def add_file(file_data):
|
|
||||||
file_url = file_data.get('url')
|
|
||||||
if file_url:
|
|
||||||
info.update({
|
|
||||||
'url': file_url,
|
|
||||||
'ext': determine_ext(file_data.get('name'), 'mp3'),
|
|
||||||
})
|
|
||||||
|
|
||||||
for i in post.get('included', []):
|
for i in post.get('included', []):
|
||||||
i_type = i.get('type')
|
i_type = i.get('type')
|
||||||
if i_type == 'attachment':
|
if i_type == 'media':
|
||||||
add_file(i.get('attributes') or {})
|
media_attributes = i.get('attributes') or {}
|
||||||
|
download_url = media_attributes.get('download_url')
|
||||||
|
ext = mimetype2ext(media_attributes.get('mimetype'))
|
||||||
|
if download_url and ext in KNOWN_EXTENSIONS:
|
||||||
|
info.update({
|
||||||
|
'ext': ext,
|
||||||
|
'filesize': int_or_none(media_attributes.get('size_bytes')),
|
||||||
|
'url': download_url,
|
||||||
|
})
|
||||||
elif i_type == 'user':
|
elif i_type == 'user':
|
||||||
user_attributes = i.get('attributes')
|
user_attributes = i.get('attributes')
|
||||||
if user_attributes:
|
if user_attributes:
|
||||||
info.update({
|
info.update({
|
||||||
'uploader': user_attributes.get('full_name'),
|
'uploader': user_attributes.get('full_name'),
|
||||||
|
'uploader_id': str_or_none(i.get('id')),
|
||||||
'uploader_url': user_attributes.get('url'),
|
'uploader_url': user_attributes.get('url'),
|
||||||
})
|
})
|
||||||
|
|
||||||
if not info.get('url'):
|
if not info.get('url'):
|
||||||
add_file(attributes.get('post_file') or {})
|
embed_url = try_get(attributes, lambda x: x['embed']['url'])
|
||||||
|
if embed_url:
|
||||||
|
info.update({
|
||||||
|
'_type': 'url',
|
||||||
|
'url': embed_url,
|
||||||
|
})
|
||||||
|
|
||||||
if not info.get('url'):
|
if not info.get('url'):
|
||||||
info.update({
|
post_file = attributes['post_file']
|
||||||
'_type': 'url',
|
ext = determine_ext(post_file.get('name'))
|
||||||
'url': attributes['embed']['url'],
|
if ext in KNOWN_EXTENSIONS:
|
||||||
})
|
info.update({
|
||||||
|
'ext': ext,
|
||||||
|
'url': post_file['url'],
|
||||||
|
})
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user