3 from __future__ import unicode_literals
5 from .common import InfoExtractor
13 class KakaoIE(InfoExtractor):
14 _VALID_URL = r'https?://tv.kakao.com/channel/(?P<channel>\d+)/cliplink/(?P<id>\d+)'
18 'url': 'http://tv.kakao.com/channel/2671005/cliplink/301965083',
19 'md5': '702b2fbdeb51ad82f5c904e8c0766340',
23 'title': '乃木坂46 バナナマン 「3期生紹介コーナーが始動!顔高低差GPも!」 『乃木坂工事中』',
24 'uploader_id': 2671005,
26 'timestamp': 1488160199,
27 'upload_date': '20170227',
30 'url': 'http://tv.kakao.com/channel/2653210/cliplink/300103180',
31 'md5': 'a8917742069a4dd442516b86e7d66529',
35 'description': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)\r\n\r\n[쇼! 음악중심] 20160611, 507회',
36 'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)',
37 'uploader_id': 2653210,
39 'timestamp': 1485684628,
40 'upload_date': '20170129',
44 def _real_extract(self, url):
45 video_id = self._match_id(url)
47 player_url = 'http://tv.kakao.com/embed/player/cliplink/' + video_id + \
48 '?service=kakao_tv&autoplay=1&profile=HIGH&wmode=transparent'
49 player_header = {'Referer': player_url}
51 impress = self._download_json(
52 'http://tv.kakao.com/api/v1/ft/cliplinks/%s/impress' % video_id,
53 video_id, 'Downloading video info',
55 'player': 'monet_html5',
58 'service': 'kakao_tv',
61 'fields': 'clipLink,clip,channel,hasPlusFriend,-service,-tagList'
62 }, headers=player_header)
64 clipLink = impress['clipLink']
65 clip = clipLink['clip']
69 'title': clip['title'],
70 'description': clip.get('description'),
71 'uploader': clipLink.get('channel', {}).get('name'),
72 'uploader_id': clipLink.get('channelId'),
73 'duration': int_or_none(clip.get('duration')),
74 'view_count': int_or_none(clip.get('playCount')),
75 'like_count': int_or_none(clip.get('likeCount')),
76 'comment_count': int_or_none(clip.get('commentCount')),
79 tid = impress.get('tid', '')
80 raw = self._download_json(
81 'http://tv.kakao.com/api/v1/ft/cliplinks/%s/raw' % video_id,
82 video_id, 'Downloading video formats info',
84 'player': 'monet_html5',
87 'service': 'kakao_tv',
92 }, headers=player_header, fatal=False)
95 for fmt in raw.get('outputList', []):
97 profile_name = fmt['profile']
98 fmt_url_json = self._download_json(
99 'http://tv.kakao.com/api/v1/ft/cliplinks/%s/raw/videolocation' % video_id,
100 video_id, 'Downloading video URL for profile %s' % profile_name,
102 'service': 'kakao_tv',
105 'profile': profile_name
106 }, headers=player_header, fatal=False)
108 if fmt_url_json is None:
111 fmt_url = fmt_url_json['url']
114 'format_id': profile_name,
115 'width': int_or_none(fmt.get('width')),
116 'height': int_or_none(fmt.get('height')),
117 'format_note': fmt.get('label'),
118 'filesize': int_or_none(fmt.get('filesize'))
123 self._sort_formats(formats)
124 video_info['formats'] = formats
126 top_thumbnail = clip.get('thumbnailUrl')
128 for thumb in clip.get('clipChapterThumbnailList', []):
130 'url': thumb.get('thumbnailUrl'),
131 'id': compat_str(thumb.get('timeInSec')),
132 'preference': -1 if thumb.get('isDefault') else 0
134 video_info['thumbnail'] = top_thumbnail
135 video_info['thumbnails'] = thumbs
137 upload_date = unified_timestamp(clipLink.get('createTime'))
138 video_info['timestamp'] = upload_date