question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cipher regex error

See original GitHub issue

I get the following output when trying to download a video

Traceback (most recent call last):
  File "/local/targaryen/Documents/workspace/video_representation_learning/utils/video_utils.py", line 281, in download_video
    video = stream.download(video_path, filename=video_id)
  File "/local/targaryen/Documents/workspace/video_representation_learning/utils/video_utils.py", line 195, in download_video
    yt = pytube.YouTube(video_url)
  File "/raid/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/streams.py", line 228, in download
    self.on_progress(chunk, fh, bytes_remaining)
  File "/raid/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 88, in __init__
    self.prefetch_init()
  File "/raid/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/streams.py", line 272, in on_progress
    file_handler.write(chunk)
  File "/raid/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 97, in prefetch_init
    self.init()
  File "/raid/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 133, in init
    mixins.apply_signature(self.player_config_args, fmt, self.js)
  File "/raid/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/mixins.py", line 49, in apply_signature
    signature = cipher.get_signature(js, stream['s'])
KeyboardInterrupt
KeyError: 's'

The interesting/surprising thing is if I try to download the same video again, I don’t get the error. The video I’m trying to download is https://www.youtube.com/watch?v=VAAcbCb1meE&has_verified=1 This isn’t specific to this one video, it seems to happen on many.

I separately see a different error consistently on some videos.

Traceback (most recent call last):
  File "experiment_scripts/test_each_video.py", line 52, in test_video_id
    yt = pytube.YouTube(video_url)
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 88, in __init__
    self.prefetch_init()
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 97, in prefetch_init
    self.init()
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 130, in init
    mixins.apply_descrambler(self.player_config_args, fmt)
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/mixins.py", line 89, in apply_descrambler
    for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'

for video https://www.youtube.com/watch?v=YP05PC3ReW0&has_verified=1

  File "experiment_scripts/test_each_video.py", line 52, in test_video_id
    yt = pytube.YouTube(video_url)
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 88, in __init__
    self.prefetch_init()
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 97, in prefetch_init
    self.init()
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/__main__.py", line 130, in init
    mixins.apply_descrambler(self.player_config_args, fmt)
  File "/home/xkcd/miniconda3/envs/video-env/lib/python3.7/site-packages/pytube/mixins.py", line 89, in apply_descrambler
    for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'

for video https://www.youtube.com/watch?v=TRXwkqNGpWA&has_verified=1

They’re probably unrelated bugs, but they both have issues with the parsing I think.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:14

github_iconTop GitHub Comments

3reactions
danielgordon10commented, Jun 11, 2019
3reactions
Alexll82commented, Jun 3, 2019

I have the same problem:

Traceback (most recent call last): File "C:\Users\Alex\YandexDisk\python\pytube\pytube_1.py", line 6, in <module> yt = YouTube(line) File "C:\Users\Alex\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 88, in __init__ self.prefetch_init() File "C:\Users\Alex\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 97, in prefetch_init self.init() File "C:\Users\Alex\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 133, in init mixins.apply_signature(self.player_config_args, fmt, self.js) File "C:\Users\Alex\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\mixins.py", line 49, in apply_signature signature = cipher.get_signature(js, stream['s']) KeyError: 's'

This problem appear on different computers and different versions of python: Python 3.6, Python 3.7, win7, win8, pytube 9.5.0

Recommendations found on the Internet did not help. Modify the cipher.py file

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shift cipher in Python: error using ord - regex - Stack Overflow
I want to replace each character of a string by a different one, shifted over in the alphabet. I'm shifting by 2 in...
Read more >
getting regex error · Issue #333 · pytube/pytube - GitHub
Upon downloading a playlist, i get the regex error Exception in ... \nicto\PycharmProjects\idk\venv\lib\site-packages\pytube\cipher.py", ...
Read more >
get error code value - Regex Tester/Debugger
Test String. Request made to v1.2/reviews returned error: {"errors":[{"message":"User already submitted review for this SKU","code":196}]} ...
Read more >
Regular Expression error message - Microsoft Q&A
Hello,. I wanted to include a regular expression to detail the parameters for a password, but I wanted to include an error message...
Read more >
Regular expressions in q | Basics | q and kdb+ documentation
In a q regex pattern certain characters have special meaning: ? wildcard: matches any character * matches any sequence of characters [] embraces...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found