Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues fixed with KeyError 'ciper' (Sourcery refactored) #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pytube/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ def apply_descrambler(stream_data: Dict, key: str) -> None:
{'foo': [{'bar': '1', 'var': 'test'}, {'em': '5', 't': 'url encoded'}]}

"""
otf_type = "FORMAT_STREAM_TYPE_OTF"

Comment on lines -276 to -277
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function apply_descrambler refactored with the following changes:

  • Move assignments closer to their usage (move-assign)

if key == "url_encoded_fmt_stream_map" and not stream_data.get(
"url_encoded_fmt_stream_map"
):
Expand All @@ -284,6 +282,8 @@ def apply_descrambler(stream_data: Dict, key: str) -> None:
"adaptiveFormats"
]
)
otf_type = "FORMAT_STREAM_TYPE_OTF"

try:
stream_data[key] = [
{
Expand All @@ -298,7 +298,7 @@ def apply_descrambler(stream_data: Dict, key: str) -> None:
]
except KeyError:
cipher_url = [
parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
parse_qs(formats[i]["signatureCipher"]) for i, data in enumerate(formats)
]
stream_data[key] = [
{
Expand Down