[kakao] Fix issues
This commit is contained in:
parent
cd0c661757
commit
82c9def6c6
@ -5,8 +5,9 @@ from __future__ import unicode_literals
|
|||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
int_or_none,
|
int_or_none,
|
||||||
|
compat_str,
|
||||||
|
unified_timestamp,
|
||||||
)
|
)
|
||||||
import datetime
|
|
||||||
|
|
||||||
|
|
||||||
class KakaoIE(InfoExtractor):
|
class KakaoIE(InfoExtractor):
|
||||||
@ -22,7 +23,8 @@ class KakaoIE(InfoExtractor):
|
|||||||
'title': '乃木坂46 バナナマン 「3期生紹介コーナーが始動!顔高低差GPも!」 『乃木坂工事中』',
|
'title': '乃木坂46 バナナマン 「3期生紹介コーナーが始動!顔高低差GPも!」 『乃木坂工事中』',
|
||||||
'uploader_id': 2671005,
|
'uploader_id': 2671005,
|
||||||
'uploader': '그랑그랑이',
|
'uploader': '그랑그랑이',
|
||||||
'upload_date': '20170227'
|
'timestamp': 1488160199,
|
||||||
|
'upload_date': '20170227',
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'http://tv.kakao.com/channel/2653210/cliplink/300103180',
|
'url': 'http://tv.kakao.com/channel/2653210/cliplink/300103180',
|
||||||
@ -34,7 +36,8 @@ class KakaoIE(InfoExtractor):
|
|||||||
'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)',
|
'title': '러블리즈 - Destiny (나의 지구) (Lovelyz - Destiny)',
|
||||||
'uploader_id': 2653210,
|
'uploader_id': 2653210,
|
||||||
'uploader': '쇼 음악중심',
|
'uploader': '쇼 음악중심',
|
||||||
'upload_date': '20170129'
|
'timestamp': 1485684628,
|
||||||
|
'upload_date': '20170129',
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ class KakaoIE(InfoExtractor):
|
|||||||
|
|
||||||
clipLink = impress['clipLink']
|
clipLink = impress['clipLink']
|
||||||
|
|
||||||
# Now we request Raw, which contains infos about video files.
|
# Raw contains informations regarding downloading video files.
|
||||||
tid = impress.get('tid', '')
|
tid = impress.get('tid', '')
|
||||||
raw = self._download_json(
|
raw = self._download_json(
|
||||||
'http://tv.kakao.com/api/v1/ft/cliplinks/%s/raw' % video_id,
|
'http://tv.kakao.com/api/v1/ft/cliplinks/%s/raw' % video_id,
|
||||||
@ -76,52 +79,51 @@ class KakaoIE(InfoExtractor):
|
|||||||
'tid': tid,
|
'tid': tid,
|
||||||
'profile': 'HIGH',
|
'profile': 'HIGH',
|
||||||
'dteType': 'PC',
|
'dteType': 'PC',
|
||||||
}, headers=player_header)
|
}, headers=player_header, fatal=False)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for fmt in raw['outputList']:
|
for fmt in raw.get('outputList', []):
|
||||||
profile_name = fmt['profile']
|
try:
|
||||||
# The following request is called when user changes the video quality.
|
profile_name = fmt['profile']
|
||||||
# We simulate it here.
|
# The following request is called when user changes the video quality.
|
||||||
fmt_url_json = self._download_json(
|
# We simulate it here.
|
||||||
'http://tv.kakao.com/api/v1/ft/cliplinks/%s/raw/videolocation' % video_id,
|
fmt_url_json = self._download_json(
|
||||||
video_id, 'Downloading video URL for profile %s' % profile_name,
|
'http://tv.kakao.com/api/v1/ft/cliplinks/%s/raw/videolocation' % video_id,
|
||||||
query={
|
video_id, 'Downloading video URL for profile %s' % profile_name,
|
||||||
'service': 'kakao_tv',
|
query={
|
||||||
'section': '',
|
'service': 'kakao_tv',
|
||||||
'tid': tid,
|
'section': '',
|
||||||
'profile': profile_name
|
'tid': tid,
|
||||||
}, headers=player_header)
|
'profile': profile_name
|
||||||
fmt_url = fmt_url_json['url']
|
}, headers=player_header, fatal=False)
|
||||||
|
fmt_url = fmt_url_json['url']
|
||||||
|
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': fmt_url,
|
'url': fmt_url,
|
||||||
'format_id': profile_name,
|
'format_id': profile_name,
|
||||||
'width': int_or_none(fmt.get('width')),
|
'width': int_or_none(fmt.get('width')),
|
||||||
'height': int_or_none(fmt.get('height')),
|
'height': int_or_none(fmt.get('height')),
|
||||||
'format_note': fmt.get('label', None),
|
'format_note': fmt.get('label'),
|
||||||
'filesize': int_or_none(fmt.get('filesize'))
|
'filesize': int_or_none(fmt.get('filesize'))
|
||||||
})
|
})
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
clip = clipLink['clip']
|
clip = clipLink['clip']
|
||||||
# Parse thumbnails.
|
# Parse thumbnails.
|
||||||
top_thumbnail = clip.get('thumbnailUrl', None)
|
top_thumbnail = clip.get('thumbnailUrl')
|
||||||
thumbs = []
|
thumbs = []
|
||||||
for thumb in clip.get('clipChapterThumbnailList', []):
|
for thumb in clip.get('clipChapterThumbnailList', []):
|
||||||
thumbs.append({
|
thumbs.append({
|
||||||
'url': thumb['thumbnailUrl'],
|
'url': thumb.get('thumbnailUrl'),
|
||||||
'id': str(thumb['timeInSec']),
|
'id': compat_str(thumb.get('timeInSec')),
|
||||||
'preference': -1 if thumb['isDefault'] else 0
|
'preference': -1 if thumb.get('isDefault') else 0
|
||||||
})
|
})
|
||||||
|
|
||||||
# Parse upload date.
|
# Parse upload date.
|
||||||
upload_date = None
|
upload_date = unified_timestamp(clipLink.get('createTime'))
|
||||||
try:
|
|
||||||
upload_date = datetime.datetime.strptime(clipLink['createTime'], '%Y-%m-%d %H:%M:%S')
|
|
||||||
upload_date = upload_date.strftime('%Y%m%d')
|
|
||||||
except (ValueError, KeyError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
@ -130,8 +132,8 @@ class KakaoIE(InfoExtractor):
|
|||||||
'thumbnail': top_thumbnail,
|
'thumbnail': top_thumbnail,
|
||||||
'thumbnails': thumbs,
|
'thumbnails': thumbs,
|
||||||
'description': clip.get('description'),
|
'description': clip.get('description'),
|
||||||
'uploader': clipLink['channel'].get('name'),
|
'uploader': clipLink.get('channel', {}).get('name'),
|
||||||
'upload_date': upload_date,
|
'timestamp': upload_date,
|
||||||
'uploader_id': clipLink.get('channelId'),
|
'uploader_id': clipLink.get('channelId'),
|
||||||
'duration': int_or_none(clip.get('duration')),
|
'duration': int_or_none(clip.get('duration')),
|
||||||
'view_count': int_or_none(clip.get('playCount')),
|
'view_count': int_or_none(clip.get('playCount')),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user