]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/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/cliplinks/%s/'
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 display_id
= video_id
.rstrip('@my')
49 api_base
= self
._API
_BASE
_TMPL
% video_id
52 'Referer': update_url_query(
53 'http://tv.kakao.com/embed/player/cliplink/%s' % video_id
, {
54 'service': 'kakao_tv',
57 'wmode': 'transparent',
62 'player': 'monet_html5',
65 'service': 'kakao_tv',
69 '-*', 'tid', 'clipLink', 'displayTitle', 'clip', 'title',
70 'description', 'channelId', 'createTime', 'duration', 'playCount',
71 'likeCount', 'commentCount', 'tagList', 'channel', 'name',
72 'clipChapterThumbnailList', 'thumbnailUrl', 'timeInSec', 'isDefault',
73 'videoOutputList', 'width', 'height', 'kbps', 'profile', 'label'])
76 impress
= self
._download
_json
(
77 api_base
+ 'impress', display_id
, 'Downloading video info',
78 query
=query
, headers
=player_header
)
80 clip_link
= impress
['clipLink']
81 clip
= clip_link
['clip']
83 title
= clip
.get('title') or clip_link
.get('displayTitle')
85 query
['tid'] = impress
.get('tid', '')
88 for fmt
in clip
.get('videoOutputList', []):
90 profile_name
= fmt
['profile']
91 if profile_name
== 'AUDIO':
94 'profile': profile_name
,
97 fmt_url_json
= self
._download
_json
(
98 api_base
+ 'raw/videolocation', display_id
,
99 'Downloading video URL for profile %s' % profile_name
,
100 query
=query
, headers
=player_header
, fatal
=False)
102 if fmt_url_json
is None:
105 fmt_url
= fmt_url_json
['url']
108 'format_id': profile_name
,
109 'width': int_or_none(fmt
.get('width')),
110 'height': int_or_none(fmt
.get('height')),
111 'format_note': fmt
.get('label'),
112 'filesize': int_or_none(fmt
.get('filesize')),
113 'tbr': int_or_none(fmt
.get('kbps')),
117 self
._sort
_formats
(formats
)
120 for thumb
in clip
.get('clipChapterThumbnailList', []):
122 'url': thumb
.get('thumbnailUrl'),
123 'id': compat_str(thumb
.get('timeInSec')),
124 'preference': -1 if thumb
.get('isDefault') else 0
126 top_thumbnail
= clip
.get('thumbnailUrl')
129 'url': top_thumbnail
,
136 'description': strip_or_none(clip
.get('description')),
137 'uploader': clip_link
.get('channel', {}).get('name'),
138 'uploader_id': clip_link
.get('channelId'),
139 'thumbnails': thumbs
,
140 'timestamp': unified_timestamp(clip_link
.get('createTime')),
141 'duration': int_or_none(clip
.get('duration')),
142 'view_count': int_or_none(clip
.get('playCount')),
143 'like_count': int_or_none(clip
.get('likeCount')),
144 'comment_count': int_or_none(clip
.get('commentCount')),
146 'tags': clip
.get('tagList'),