|
|
@ -77,25 +77,25 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
|
|
# Log in
|
|
|
|
# Log in
|
|
|
|
login_form_strs = {
|
|
|
|
login_form_strs = {
|
|
|
|
'continue': 'https://www.youtube.com/signin?action_handle_signin=true&feature=sign_in_button&hl=en_US&nomobiletemp=1',
|
|
|
|
'continue': 'https://www.youtube.com/signin?action_handle_signin=true&feature=sign_in_button&hl=en_US&nomobiletemp=1',
|
|
|
|
'Email': username,
|
|
|
|
'Email': username,
|
|
|
|
'GALX': galx,
|
|
|
|
'GALX': galx,
|
|
|
|
'Passwd': password,
|
|
|
|
'Passwd': password,
|
|
|
|
|
|
|
|
|
|
|
|
'PersistentCookie': 'yes',
|
|
|
|
'PersistentCookie': 'yes',
|
|
|
|
'_utf8': '霱',
|
|
|
|
'_utf8': '霱',
|
|
|
|
'bgresponse': 'js_disabled',
|
|
|
|
'bgresponse': 'js_disabled',
|
|
|
|
'checkConnection': '',
|
|
|
|
'checkConnection': '',
|
|
|
|
'checkedDomains': 'youtube',
|
|
|
|
'checkedDomains': 'youtube',
|
|
|
|
'dnConn': '',
|
|
|
|
'dnConn': '',
|
|
|
|
'pstMsg': '0',
|
|
|
|
'pstMsg': '0',
|
|
|
|
'rmShown': '1',
|
|
|
|
'rmShown': '1',
|
|
|
|
'secTok': '',
|
|
|
|
'secTok': '',
|
|
|
|
'signIn': 'Sign in',
|
|
|
|
'signIn': 'Sign in',
|
|
|
|
'timeStmp': '',
|
|
|
|
'timeStmp': '',
|
|
|
|
'service': 'youtube',
|
|
|
|
'service': 'youtube',
|
|
|
|
'uilel': '3',
|
|
|
|
'uilel': '3',
|
|
|
|
'hl': 'en_US',
|
|
|
|
'hl': 'en_US',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Convert to UTF-8 *before* urlencode because Python 2.x's urlencode
|
|
|
|
# Convert to UTF-8 *before* urlencode because Python 2.x's urlencode
|
|
|
@ -181,8 +181,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|
|
|
'next_url': '/',
|
|
|
|
'next_url': '/',
|
|
|
|
'action_confirm': 'Confirm',
|
|
|
|
'action_confirm': 'Confirm',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
req = compat_urllib_request.Request(self._AGE_URL,
|
|
|
|
req = compat_urllib_request.Request(
|
|
|
|
compat_urllib_parse.urlencode(age_form).encode('ascii'))
|
|
|
|
self._AGE_URL,
|
|
|
|
|
|
|
|
compat_urllib_parse.urlencode(age_form).encode('ascii')
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
self._download_webpage(
|
|
|
|
self._download_webpage(
|
|
|
|
req, None,
|
|
|
|
req, None,
|
|
|
@ -492,7 +494,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|
|
|
def gen_sig_code(idxs):
|
|
|
|
def gen_sig_code(idxs):
|
|
|
|
def _genslice(start, end, step):
|
|
|
|
def _genslice(start, end, step):
|
|
|
|
starts = '' if start == 0 else str(start)
|
|
|
|
starts = '' if start == 0 else str(start)
|
|
|
|
ends = (':%d' % (end+step)) if end + step >= 0 else ':'
|
|
|
|
ends = (':%d' % (end + step)) if end + step >= 0 else ':'
|
|
|
|
steps = '' if step == 1 else (':%d' % step)
|
|
|
|
steps = '' if step == 1 else (':%d' % step)
|
|
|
|
return 's[%s%s%s]' % (starts, ends, steps)
|
|
|
|
return 's[%s%s%s]' % (starts, ends, steps)
|
|
|
|
|
|
|
|
|
|
|
@ -530,7 +532,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|
|
|
def _parse_sig_js(self, jscode):
|
|
|
|
def _parse_sig_js(self, jscode):
|
|
|
|
funcname = self._search_regex(
|
|
|
|
funcname = self._search_regex(
|
|
|
|
r'\.sig\|\|([a-zA-Z0-9]+)\(', jscode,
|
|
|
|
r'\.sig\|\|([a-zA-Z0-9]+)\(', jscode,
|
|
|
|
'Initial JS player signature function name')
|
|
|
|
'Initial JS player signature function name')
|
|
|
|
|
|
|
|
|
|
|
|
jsi = JSInterpreter(jscode)
|
|
|
|
jsi = JSInterpreter(jscode)
|
|
|
|
initial_function = jsi.extract_function(funcname)
|
|
|
|
initial_function = jsi.extract_function(funcname)
|
|
|
@ -656,7 +658,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|
|
|
def _get_urls(_manifest):
|
|
|
|
def _get_urls(_manifest):
|
|
|
|
lines = _manifest.split('\n')
|
|
|
|
lines = _manifest.split('\n')
|
|
|
|
urls = filter(lambda l: l and not l.startswith('#'),
|
|
|
|
urls = filter(lambda l: l and not l.startswith('#'),
|
|
|
|
lines)
|
|
|
|
lines)
|
|
|
|
return urls
|
|
|
|
return urls
|
|
|
|
manifest = self._download_webpage(manifest_url, video_id, 'Downloading formats manifest')
|
|
|
|
manifest = self._download_webpage(manifest_url, video_id, 'Downloading formats manifest')
|
|
|
|
formats_urls = _get_urls(manifest)
|
|
|
|
formats_urls = _get_urls(manifest)
|
|
|
@ -723,10 +725,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|
|
|
age_gate = False
|
|
|
|
age_gate = False
|
|
|
|
for el_type in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
|
|
|
|
for el_type in ['&el=embedded', '&el=detailpage', '&el=vevo', '']:
|
|
|
|
video_info_url = (proto + '://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
|
|
|
|
video_info_url = (proto + '://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en'
|
|
|
|
% (video_id, el_type))
|
|
|
|
% (video_id, el_type))
|
|
|
|
video_info_webpage = self._download_webpage(video_info_url, video_id,
|
|
|
|
video_info_webpage = self._download_webpage(video_info_url, video_id,
|
|
|
|
note=False,
|
|
|
|
note=False,
|
|
|
|
errnote='unable to download video info webpage')
|
|
|
|
errnote='unable to download video info webpage')
|
|
|
|
video_info = compat_parse_qs(video_info_webpage)
|
|
|
|
video_info = compat_parse_qs(video_info_webpage)
|
|
|
|
if 'token' in video_info:
|
|
|
|
if 'token' in video_info:
|
|
|
|
break
|
|
|
|
break
|
|
|
@ -1017,23 +1019,23 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
|
|
|
|
self._sort_formats(formats)
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'id': video_id,
|
|
|
|
'uploader': video_uploader,
|
|
|
|
'uploader': video_uploader,
|
|
|
|
'uploader_id': video_uploader_id,
|
|
|
|
'uploader_id': video_uploader_id,
|
|
|
|
'upload_date': upload_date,
|
|
|
|
'upload_date': upload_date,
|
|
|
|
'title': video_title,
|
|
|
|
'title': video_title,
|
|
|
|
'thumbnail': video_thumbnail,
|
|
|
|
'thumbnail': video_thumbnail,
|
|
|
|
'description': video_description,
|
|
|
|
'description': video_description,
|
|
|
|
'categories': video_categories,
|
|
|
|
'categories': video_categories,
|
|
|
|
'subtitles': video_subtitles,
|
|
|
|
'subtitles': video_subtitles,
|
|
|
|
'duration': video_duration,
|
|
|
|
'duration': video_duration,
|
|
|
|
'age_limit': 18 if age_gate else 0,
|
|
|
|
'age_limit': 18 if age_gate else 0,
|
|
|
|
'annotations': video_annotations,
|
|
|
|
'annotations': video_annotations,
|
|
|
|
'webpage_url': proto + '://www.youtube.com/watch?v=%s' % video_id,
|
|
|
|
'webpage_url': proto + '://www.youtube.com/watch?v=%s' % video_id,
|
|
|
|
'view_count': view_count,
|
|
|
|
'view_count': view_count,
|
|
|
|
'like_count': like_count,
|
|
|
|
'like_count': like_count,
|
|
|
|
'dislike_count': dislike_count,
|
|
|
|
'dislike_count': dislike_count,
|
|
|
|
'formats': formats,
|
|
|
|
'formats': formats,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1167,7 +1169,7 @@ class YoutubePlaylistIE(YoutubeBaseInfoExtractor):
|
|
|
|
return self._extract_mix(playlist_id)
|
|
|
|
return self._extract_mix(playlist_id)
|
|
|
|
if playlist_id.startswith('TL'):
|
|
|
|
if playlist_id.startswith('TL'):
|
|
|
|
raise ExtractorError('For downloading YouTube.com top lists, use '
|
|
|
|
raise ExtractorError('For downloading YouTube.com top lists, use '
|
|
|
|
'the "yttoplist" keyword, for example "youtube-dl \'yttoplist:music:Top Tracks\'"', expected=True)
|
|
|
|
'the "yttoplist" keyword, for example "youtube-dl \'yttoplist:music:Top Tracks\'"', expected=True)
|
|
|
|
|
|
|
|
|
|
|
|
url = self._TEMPLATE_URL % playlist_id
|
|
|
|
url = self._TEMPLATE_URL % playlist_id
|
|
|
|
page = self._download_webpage(url, playlist_id)
|
|
|
|
page = self._download_webpage(url, playlist_id)
|
|
|
@ -1546,8 +1548,8 @@ class YoutubeFeedsInfoExtractor(YoutubeBaseInfoExtractor):
|
|
|
|
paging = 0
|
|
|
|
paging = 0
|
|
|
|
for i in itertools.count(1):
|
|
|
|
for i in itertools.count(1):
|
|
|
|
info = self._download_json(self._FEED_TEMPLATE % paging,
|
|
|
|
info = self._download_json(self._FEED_TEMPLATE % paging,
|
|
|
|
'%s feed' % self._FEED_NAME,
|
|
|
|
'%s feed' % self._FEED_NAME,
|
|
|
|
'Downloading page %s' % i)
|
|
|
|
'Downloading page %s' % i)
|
|
|
|
feed_html = info.get('feed_html') or info.get('content_html')
|
|
|
|
feed_html = info.get('feed_html') or info.get('content_html')
|
|
|
|
load_more_widget_html = info.get('load_more_widget_html') or feed_html
|
|
|
|
load_more_widget_html = info.get('load_more_widget_html') or feed_html
|
|
|
|
m_ids = re.finditer(r'"/watch\?v=(.*?)["&]', feed_html)
|
|
|
|
m_ids = re.finditer(r'"/watch\?v=(.*?)["&]', feed_html)
|
|
|
|