]>
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_HTTPError
17 class KakaoIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:play-)?tv\.kakao\.com/(?:channel/\d+|embed/player)/cliplink/(?P<id>\d+|[^?#&]+@my)'
19 _API_BASE_TMPL
= 'http://tv.kakao.com/api/v1/ft/playmeta/cliplink/%s/'
20 _CDN_API
= 'https://tv.kakao.com/katz/v1/ft/cliplink/%s/readyNplay?'
23 'url': 'http://tv.kakao.com/channel/2671005/cliplink/301965083',
24 'md5': '702b2fbdeb51ad82f5c904e8c0766340',
28 'title': '乃木坂46 バナナマン 「3期生紹介コーナーが始動!顔高低差GPも!」 『乃木坂工事中』',
30 'uploader_id': '2671005',
32 'timestamp': 1488160199,
33 'upload_date': '20170227',
35 'thumbnail': r
're:http://.+/thumb\.png',
42 'url': 'http://tv.kakao.com/channel/2653210/cliplink/300103180',
43 'md5': 'a8917742069a4dd442516b86e7d66529',
47 'description': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)\r\n\r\n[쇼! 음악중심] 20160611, 507회',
48 'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)',
49 'uploader_id': '2653210',
50 'uploader': '쇼! 음악중심',
51 'timestamp': 1485684628,
52 'upload_date': '20170129',
54 'thumbnail': r
're:http://.+/thumb\.png',
62 'url': 'https://tv.kakao.com/channel/3643855/cliplink/412069491',
63 'only_matching': True,
66 def _real_extract(self
, url
):
67 video_id
= self
._match
_id
(url
)
68 api_base
= self
._API
_BASE
_TMPL
% video_id
69 cdn_api_base
= self
._CDN
_API
% video_id
72 'player': 'monet_html5',
75 'service': 'kakao_tv',
79 '-*', 'tid', 'clipLink', 'displayTitle', 'clip', 'title',
80 'description', 'channelId', 'createTime', 'duration', 'playCount',
81 'likeCount', 'commentCount', 'tagList', 'channel', 'name',
82 'clipChapterThumbnailList', 'thumbnailUrl', 'timeInSec', 'isDefault',
83 'videoOutputList', 'width', 'height', 'kbps', 'profile', 'label'])
86 api_json
= self
._download
_json
(
87 api_base
, video_id
, 'Downloading video info')
89 clip_link
= api_json
['clipLink']
90 clip
= clip_link
['clip']
92 title
= clip
.get('title') or clip_link
.get('displayTitle')
95 for fmt
in clip
.get('videoOutputList') or []:
96 profile_name
= fmt
.get('profile')
97 if not profile_name
or profile_name
== 'AUDIO':
100 'profile': profile_name
,
101 'fields': '-*,code,message,url',
104 fmt_url_json
= self
._download
_json
(
105 cdn_api_base
, video_id
, query
=query
,
106 note
='Downloading video URL for profile %s' % profile_name
)
107 except ExtractorError
as e
:
108 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
109 resp
= self
._parse
_json
(e
.cause
.read().decode(), video_id
)
110 if resp
.get('code') == 'GeoBlocked':
111 self
.raise_geo_restricted()
113 fmt_url
= traverse_obj(fmt_url_json
, ('videoLocation', 'url'))
119 'format_id': profile_name
,
120 'width': int_or_none(fmt
.get('width')),
121 'height': int_or_none(fmt
.get('height')),
122 'format_note': fmt
.get('label'),
123 'filesize': int_or_none(fmt
.get('filesize')),
124 'tbr': int_or_none(fmt
.get('kbps')),
126 self
._sort
_formats
(formats
)
129 for thumb
in clip
.get('clipChapterThumbnailList') or []:
131 'url': thumb
.get('thumbnailUrl'),
132 'id': str(thumb
.get('timeInSec')),
133 'preference': -1 if thumb
.get('isDefault') else 0
135 top_thumbnail
= clip
.get('thumbnailUrl')
138 'url': top_thumbnail
,
145 'description': strip_or_none(clip
.get('description')),
146 'uploader': traverse_obj(clip_link
, ('channel', 'name')),
147 'uploader_id': str_or_none(clip_link
.get('channelId')),
148 'thumbnails': thumbs
,
149 'timestamp': unified_timestamp(clip_link
.get('createTime')),
150 'duration': int_or_none(clip
.get('duration')),
151 'view_count': int_or_none(clip
.get('playCount')),
152 'like_count': int_or_none(clip
.get('likeCount')),
153 'comment_count': int_or_none(clip
.get('commentCount')),
155 'tags': clip
.get('tagList'),