Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The initialization process takes advantage of Python's
"call-by-reference evaluation," which allows dictionary transforms to
be applied in-place, instead of holding references to mutations at each
interstitial step.
:rtype: None
"""
logger.info('init started')
self.vid_info = {k: v for k, v in parse_qsl(self.vid_info)}
if self.age_restricted:
self.player_config_args = self.vid_info
else:
self.player_config_args = extract.get_ytplayer_config(
self.watch_html,
)['args']
# Fix for KeyError: 'title' issue #434
if 'title' not in self.player_config_args:
i_start = (
self.watch_html
.lower()
.index('<title>') + len('<title>')
)
i_end = self.watch_html.lower().index('</title>')
title = self.watch_html[i_start:i_end].strip()
index = title.lower().rfind(' - youtube')
title = title[:index] if index > 0 else title
self.player_config_args['title'] = title
The initialization process takes advantage of Python's
"call-by-reference evaluation," which allows dictionary transforms to
be applied in-place, instead of holding references to mutations at each
interstitial step.
:rtype: None
"""
PLog('init YouTube started')
self.vid_info = {k: v for k, v in parse_qsl(self.vid_info)}
if self.age_restricted:
self.player_config_args = self.vid_info
else:
self.player_config_args = extract.get_ytplayer_config(
self.watch_html,
)['args']
# Fix for KeyError: 'title' issue #434
if 'title' not in self.player_config_args:
i_start = (
self.watch_html
.lower()
.index('<title>') + len('<title>')
)
i_end = self.watch_html.lower().index('</title>')
title = self.watch_html[i_start:i_end].strip()
index = title.lower().rfind(' - youtube')
title = title[:index] if index > 0 else title
self.player_config_args['title'] = title
The initialization process takes advantage of Python's
"call-by-reference evaluation," which allows dictionary transforms to
be applied in-place, instead of holding references to mutations at each
interstitial step.
:rtype: None
"""
logger.info('init started')
self.vid_info = {k: v for k, v in parse_qsl(self.vid_info)}
if self.age_restricted:
self.player_config_args = self.vid_info
else:
self.player_config_args = extract.get_ytplayer_config(
self.watch_html,
)['args']
self.vid_descr = extract.get_vid_descr(self.watch_html)
# https://github.com/nficano/pytube/issues/165
stream_maps = ['url_encoded_fmt_stream_map']
if 'adaptive_fmts' in self.player_config_args:
stream_maps.append('adaptive_fmts')
# unscramble the progressive and adaptive stream manifests.
for fmt in stream_maps:
if not self.age_restricted and fmt in self.vid_info:
mixins.apply_descrambler(self.vid_info, fmt)
mixins.apply_descrambler(self.player_config_args, fmt)
try: