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.

[BUG] 'NoneType' object has no attribute 'span'

See original GitHub issue
arr = yt.streams.filter(only_video=True, file_extension='mp4')
line 292, in streams
    return StreamQuery(self.fmt_streams)
  File "...\Python39\lib\site-packages\pytube\__main__.py", line 177, in fmt_streams
    extract.apply_signature(stream_manifest, self.vid_info, self.js)
  File "...\Python39\lib\site-packages\pytube\extract.py", line 409, in apply_signature
    cipher = Cipher(js=js)
  File "...\Python39\lib\site-packages\pytube\cipher.py", line 44, in __init__
    self.throttling_array = get_throttling_function_array(js)
  File "...\Python39\lib\site-packages\pytube\cipher.py", line 323, in get_throttling_function_array
    str_array = throttling_array_split(array_raw)
  File "...\Python39\lib\site-packages\pytube\parser.py", line 158, in throttling_array_split
    match_start, match_end = match.span()
AttributeError: 'NoneType' object has no attribute 'span'

Pytube version: 11.0.1 Python 3.9.7

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:14
  • Comments:48 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
Ammadhashmicommented, Feb 1, 2022

Please re open this issue, I encountered the same error

13reactions
alexeichhorncommented, Nov 22, 2021

seems to happen, because YouTube added functions without parameters in the javascript. e.g.:

function(){for(var d=64,e=[];++d-e.length-32;){switch(d){case 58:d-=14;case 91:case 92:case 93:continue;case 123:d=47;case 94:case 95:case 96:continue;case 46:d=95}e.push(String.fromCharCode(d))}return e}

So in my opinion the best fix would be to allow the regex to accept these too. That is, change the regex function\([^)]+\) to function\([^)]*\). The * allows the function to have no parameters.

So https://github.com/pytube/pytube/blob/f06e0710dcf5089e582487fee94f7bb0afbf7ba9/pytube/parser.py#L152 should be changed to

func_regex = re.compile(r"function\([^)]*\)")

Any opinion about that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytube: AttributeError: 'NoneType' object has no attribute 'span'
The issue is that the regex expects a function with an argument, but I guess youtube added some src that includes non-paramterized functions....
Read more >
[BUG] 'NoneType' object has no attribute 'span' #1218 - GitHub
You can do this by running python -m pip install git+https://github.com/pytube/pytube . Sometimes, the pypi library repository is not up to date ...
Read more >
[Solved] AttributeError: 'NoneType' object has no attribute 'span'
To Solve AttributeError: 'NoneType' object has no attribute 'span' Error There are issue is that the regex expects a function with an argument...
Read more >
[Example code]-pytube: 'NoneType' object has no attribute 'span'
Found a fix on github: NoneType object has no attribute 'span'. Just replace the function get_throttling_function_name with:
Read more >
How do I fix : attributeerror: 'nonetype' object has no attribute ...
When ever you get a problems that involves a message such as " 'nonetype' object has no attribute ..." it means the same...
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