]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/kakao.py
3 from __future__
import unicode_literals
5 from .common
import InfoExtractor
6 from ..compat
import compat_str
14 class KakaoIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:play-)?tv\.kakao\.com/(?:channel/\d+|embed/player)/cliplink/(?P<id>\d+|[^?#&]+@my)'
16 _API_BASE_TMPL
= 'http://tv.kakao.com/api/v1/ft/playmeta/cliplink/%s/'
17 _CDN_API
= 'https://tv.kakao.com/katz/v1/ft/cliplink/%s/readyNplay?'
20 'url': 'http://tv.kakao.com/channel/2671005/cliplink/301965083',
21 'md5': '702b2fbdeb51ad82f5c904e8c0766340',
25 'title': '乃木坂46 バナナマン 「3期生紹介コーナーが始動!顔高低差GPも!」 『乃木坂工事中』',
26 'uploader_id': 2671005,
28 'timestamp': 1488160199,
29 'upload_date': '20170227',
32 'url': 'http://tv.kakao.com/channel/2653210/cliplink/300103180',
33 'md5': 'a8917742069a4dd442516b86e7d66529',
37 'description': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)\r\n\r\n[쇼! 음악중심] 20160611, 507회',
38 'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)',
39 'uploader_id': 2653210,
40 'uploader': '쇼! 음악중심',
41 'timestamp': 1485684628,
42 'upload_date': '20170129',
46 def _real_extract(self
, url
):
47 video_id
= self
._match
_id
(url
)
48 api_base
= self
._API
_BASE
_TMPL
% video_id
49 cdn_api_base
= self
._CDN
_API
% video_id
52 'player': 'monet_html5',
55 'service': 'kakao_tv',
59 '-*', 'tid', 'clipLink', 'displayTitle', 'clip', 'title',
60 'description', 'channelId', 'createTime', 'duration', 'playCount',
61 'likeCount', 'commentCount', 'tagList', 'channel', 'name',
62 'clipChapterThumbnailList', 'thumbnailUrl', 'timeInSec', 'isDefault',
63 'videoOutputList', 'width', 'height', 'kbps', 'profile', 'label'])
66 api_json
= self
._download
_json
(
67 api_base
, video_id
, 'Downloading video info')
69 clip_link
= api_json
['clipLink']
70 clip
= clip_link
['clip']
72 title
= clip
.get('title') or clip_link
.get('displayTitle')
75 for fmt
in clip
.get('videoOutputList', []):
77 profile_name
= fmt
['profile']
78 if profile_name
== 'AUDIO':
81 'profile': profile_name
,
85 fmt_url_json
= self
._download
_json
(
86 cdn_api_base
, video_id
,
87 'Downloading video URL for profile %s' % profile_name
,
88 query
=query
, fatal
=False)
90 if fmt_url_json
is None:
93 fmt_vidLocation
= fmt_url_json
['videoLocation']
94 fmt_url
= fmt_vidLocation
['url']
97 'format_id': profile_name
,
98 'width': int_or_none(fmt
.get('width')),
99 'height': int_or_none(fmt
.get('height')),
100 'format_note': fmt
.get('label'),
101 'filesize': int_or_none(fmt
.get('filesize')),
102 'tbr': int_or_none(fmt
.get('kbps')),
106 self
._sort
_formats
(formats
)
109 for thumb
in clip
.get('clipChapterThumbnailList', []):
111 'url': thumb
.get('thumbnailUrl'),
112 'id': compat_str(thumb
.get('timeInSec')),
113 'preference': -1 if thumb
.get('isDefault') else 0
115 top_thumbnail
= clip
.get('thumbnailUrl')
118 'url': top_thumbnail
,
125 'description': strip_or_none(clip
.get('description')),
126 'uploader': clip_link
.get('channel', {}).get('name'),
127 'uploader_id': clip_link
.get('channelId'),
128 'thumbnails': thumbs
,
129 'timestamp': unified_timestamp(clip_link
.get('createTime')),
130 'duration': int_or_none(clip
.get('duration')),
131 'view_count': int_or_none(clip
.get('playCount')),
132 'like_count': int_or_none(clip
.get('likeCount')),
133 'comment_count': int_or_none(clip
.get('commentCount')),
135 'tags': clip
.get('tagList'),