]>
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
15 class KakaoIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:play-)?tv\.kakao\.com/(?:channel/\d+|embed/player)/cliplink/(?P<id>\d+|[^?#&]+@my)'
17 _API_BASE_TMPL
= 'http://tv.kakao.com/api/v1/ft/playmeta/cliplink/%s/'
18 _CDN_API
= 'https://tv.kakao.com/katz/v1/ft/cliplink/%s/readyNplay?'
21 'url': 'http://tv.kakao.com/channel/2671005/cliplink/301965083',
22 'md5': '702b2fbdeb51ad82f5c904e8c0766340',
26 'title': '乃木坂46 バナナマン 「3期生紹介コーナーが始動!顔高低差GPも!」 『乃木坂工事中』',
27 'uploader_id': 2671005,
29 'timestamp': 1488160199,
30 'upload_date': '20170227',
33 'url': 'http://tv.kakao.com/channel/2653210/cliplink/300103180',
34 'md5': 'a8917742069a4dd442516b86e7d66529',
38 'description': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)\r\n\r\n[쇼! 음악중심] 20160611, 507회',
39 'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)',
40 'uploader_id': 2653210,
41 'uploader': '쇼! 음악중심',
42 'timestamp': 1485684628,
43 'upload_date': '20170129',
47 def _real_extract(self
, url
):
48 video_id
= self
._match
_id
(url
)
49 api_base
= self
._API
_BASE
_TMPL
% video_id
50 cdn_api_base
= self
._CDN
_API
% video_id
53 'player': 'monet_html5',
56 'service': 'kakao_tv',
60 '-*', 'tid', 'clipLink', 'displayTitle', 'clip', 'title',
61 'description', 'channelId', 'createTime', 'duration', 'playCount',
62 'likeCount', 'commentCount', 'tagList', 'channel', 'name',
63 'clipChapterThumbnailList', 'thumbnailUrl', 'timeInSec', 'isDefault',
64 'videoOutputList', 'width', 'height', 'kbps', 'profile', 'label'])
67 api_json
= self
._download
_json
(
68 api_base
, video_id
, 'Downloading video info')
70 clip_link
= api_json
['clipLink']
71 clip
= clip_link
['clip']
73 title
= clip
.get('title') or clip_link
.get('displayTitle')
76 for fmt
in clip
.get('videoOutputList', []):
77 profile_name
= fmt
.get('profile')
78 if not profile_name
or 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)
89 fmt_url
= traverse_obj(fmt_url_json
, ('videoLocation', 'url'))
95 'format_id': profile_name
,
96 'width': int_or_none(fmt
.get('width')),
97 'height': int_or_none(fmt
.get('height')),
98 'format_note': fmt
.get('label'),
99 'filesize': int_or_none(fmt
.get('filesize')),
100 'tbr': int_or_none(fmt
.get('kbps')),
102 self
._sort
_formats
(formats
)
105 for thumb
in clip
.get('clipChapterThumbnailList') or []:
107 'url': thumb
.get('thumbnailUrl'),
108 'id': compat_str(thumb
.get('timeInSec')),
109 'preference': -1 if thumb
.get('isDefault') else 0
111 top_thumbnail
= clip
.get('thumbnailUrl')
114 'url': top_thumbnail
,
121 'description': strip_or_none(clip
.get('description')),
122 'uploader': traverse_obj(clip_link
, ('channel', 'name')),
123 'uploader_id': clip_link
.get('channelId'),
124 'thumbnails': thumbs
,
125 'timestamp': unified_timestamp(clip_link
.get('createTime')),
126 'duration': int_or_none(clip
.get('duration')),
127 'view_count': int_or_none(clip
.get('playCount')),
128 'like_count': int_or_none(clip
.get('likeCount')),
129 'comment_count': int_or_none(clip
.get('commentCount')),
131 'tags': clip
.get('tagList'),