mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-06-30 19:12:49 -05:00
[naver] improve extraction
- improve geo-restriction handling - extract automatic captions - extract uploader metadata - extract VLive HLS formats
This commit is contained in:
@ -6,22 +6,18 @@ import time
|
||||
import itertools
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..compat import (
|
||||
compat_urllib_parse_urlencode,
|
||||
compat_str,
|
||||
)
|
||||
from .naver import NaverBaseIE
|
||||
from ..compat import compat_str
|
||||
from ..utils import (
|
||||
dict_get,
|
||||
ExtractorError,
|
||||
float_or_none,
|
||||
int_or_none,
|
||||
merge_dicts,
|
||||
remove_start,
|
||||
try_get,
|
||||
urlencode_postdata,
|
||||
)
|
||||
|
||||
|
||||
class VLiveIE(InfoExtractor):
|
||||
class VLiveIE(NaverBaseIE):
|
||||
IE_NAME = 'vlive'
|
||||
_VALID_URL = r'https?://(?:(?:www|m)\.)?vlive\.tv/video/(?P<id>[0-9]+)'
|
||||
_NETRC_MACHINE = 'vlive'
|
||||
@ -34,6 +30,7 @@ class VLiveIE(InfoExtractor):
|
||||
'title': "[V LIVE] Girl's Day's Broadcast",
|
||||
'creator': "Girl's Day",
|
||||
'view_count': int,
|
||||
'uploader_id': 'muploader_a',
|
||||
},
|
||||
}, {
|
||||
'url': 'http://www.vlive.tv/video/16937',
|
||||
@ -44,6 +41,7 @@ class VLiveIE(InfoExtractor):
|
||||
'creator': 'EXO',
|
||||
'view_count': int,
|
||||
'subtitles': 'mincount:12',
|
||||
'uploader_id': 'muploader_j',
|
||||
},
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
@ -187,45 +185,9 @@ class VLiveIE(InfoExtractor):
|
||||
'This video is only available for CH+ subscribers')
|
||||
long_video_id, key = video_info['vid'], video_info['inkey']
|
||||
|
||||
playinfo = self._download_json(
|
||||
'http://global.apis.naver.com/rmcnmv/rmcnmv/vod_play_videoInfo.json?%s'
|
||||
% compat_urllib_parse_urlencode({
|
||||
'videoId': long_video_id,
|
||||
'key': key,
|
||||
'ptc': 'http',
|
||||
'doct': 'json', # document type (xml or json)
|
||||
'cpt': 'vtt', # captions type (vtt or ttml)
|
||||
}), video_id)
|
||||
|
||||
formats = [{
|
||||
'url': vid['source'],
|
||||
'format_id': vid.get('encodingOption', {}).get('name'),
|
||||
'abr': float_or_none(vid.get('bitrate', {}).get('audio')),
|
||||
'vbr': float_or_none(vid.get('bitrate', {}).get('video')),
|
||||
'width': int_or_none(vid.get('encodingOption', {}).get('width')),
|
||||
'height': int_or_none(vid.get('encodingOption', {}).get('height')),
|
||||
'filesize': int_or_none(vid.get('size')),
|
||||
} for vid in playinfo.get('videos', {}).get('list', []) if vid.get('source')]
|
||||
self._sort_formats(formats)
|
||||
|
||||
view_count = int_or_none(playinfo.get('meta', {}).get('count'))
|
||||
|
||||
subtitles = {}
|
||||
for caption in playinfo.get('captions', {}).get('list', []):
|
||||
lang = dict_get(caption, ('locale', 'language', 'country', 'label'))
|
||||
if lang and caption.get('source'):
|
||||
subtitles[lang] = [{
|
||||
'ext': 'vtt',
|
||||
'url': caption['source']}]
|
||||
|
||||
info = self._get_common_fields(webpage)
|
||||
info.update({
|
||||
'id': video_id,
|
||||
'formats': formats,
|
||||
'view_count': view_count,
|
||||
'subtitles': subtitles,
|
||||
})
|
||||
return info
|
||||
return merge_dicts(
|
||||
self._get_common_fields(webpage),
|
||||
self._extract_video_info(video_id, long_video_id, key))
|
||||
|
||||
def _download_init_page(self, video_id):
|
||||
return self._download_webpage(
|
||||
|
Reference in New Issue
Block a user