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

Before creating an issue

Please confirm that you are on the latest version of pytube by installing from the source. 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, and your issue may have been fixed already!

Describe the bug A clear and concise description of what the bug is.

To Reproduce Please provide the following information:

  • The video or playlist url that is causing the error.
  • The code where the problem is occurring.

Expected behavior A clear and concise description of what you expected to happen.

Output If pytube raises an exception, please provide the full traceback for the exception.

System information Please provide the following information:

  • Python version (run python --version)
  • Pytube version (run print(pytube.__version__) in python)
  • Command used to install pytube

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Github is becoming a cesspool of idiots who can’t read, can’t write, can’t understand anything.

Don’t act surprised when developers leave this platform if people keep spamming like this.

name = re.escape(get_throttling_function_name(js))

# print(js)
name = "hha"

name = re.escape(get_throttling_function_name(js))

# print(js)
name = "hha"

Is it permanent fix or for only short time fix?

Got the same issue

yes I know 😄 but to statically assign a value like “hha” only because it solves the current problem should not be way of handling bugs. What if in the future instead of “hha” the value is “foo”? Then this would mean you need to adjust this line again with the new value. And this can go on and on…

statically assign “hha” as value to name should not be the correct way of handling this bug. I extended the get_throttling_function_name(js: str) like following:

def get_throttling_function_name(js: str) -> str:
    """Extract the name of the function that computes the throttling parameter.

    :param str js:
        The contents of the base.js asset file.
    :rtype: str
    :returns:
        The name of the function used to compute the throttling parameter.
    """
    function_patterns = [
        # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
        # a.C&&(b=a.get("n"))&&(b=Dea(b),a.set("n",b))}};
        # In above case, `Dea` is the relevant function name
        r'a\.[A-Z]&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\)',
    ]
    logger.debug('Finding throttling function name')
    for pattern in function_patterns:
        regex = re.compile(pattern)
        function_match = regex.search(js)
        if function_match:
            logger.debug("finished regex search, matched: %s", pattern)
            function_name = function_match.group(1)
            is_Array = True if '[' or ']' in function_name else False
            if is_Array:
                index = int(re.findall(r'\d+', function_name)[0])
                name = function_name.split('[')[0]
                pattern = r"var %s=\[(.*?)\];" % name
                regex = re.compile(pattern)
                return regex.search(js).group(1).split(',')[index]
            else:
                return function_name

    raise RegexMatchError(
        caller="get_throttling_function_name", pattern="multiple"
    )

The issue I guess is, the regex on line 269 is not expecting an array with it’s according index. I know this is not the most generic or best way of handling this kind of issue, but it gives an idea in which direction it should be handled.

cipher.py

name = “hha” no found

image

index = js.index(‘function(a){var b=a.split(“”)’) name = js[index-4:index-1]

can you help, cant fix

name = re.escape(get_throttling_function_name(js))

# print(js)
name = "hha"

This really worked man !! How the heck did you figured out this ?

name = re.escape(get_throttling_function_name(js))

# print(js)
name = "hha"

it 's work thanks , i am really interested

How do you know about “hha”?