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.

pytube.exceptions.RegexMatchError: regex pattern

See original GitHub issue

While the downloads work fine for many videos it fails on some like this video:

https://www.youtube.com/watch?v=tOMPGQP1G8o

the error is :

File "/usr/local/lib/python2.7/dist-packages/pytube/cipher.py", line 252, in get_signature
    tplan = get_transform_plan(js)
  File "/usr/local/lib/python2.7/dist-packages/pytube/cipher.py", line 71, in get_transform_plan
    name = re.escape(get_initial_function_name(js))
  File "/usr/local/lib/python2.7/dist-packages/pytube/cipher.py", line 47, in get_initial_function_name
    return regex_search(pattern, js, group=1)
  File "/usr/local/lib/python2.7/dist-packages/pytube/helpers.py", line 41, in regex_search
    .format(pattern=p),
pytube.exceptions.RegexMatchError: regex pattern (yt\.akamaized\.net/\)\s*\|\|\s*.*?\s*c\s*&&\s*d\.set\([^,]+\s*,\s*(?:encodeURIComponent\s*\()?(?P<sig>[a-zA-Z0-9$]+)\() had zero matches

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
shostakuncommented, Jun 23, 2019

Based on what @Elite posted, I changed cipher.py line 40 to:

r'.*?\s*c\s*&&\s*d|a\.set\([^,]+\s*,\s*(?:encodeURIComponent'

and line 43 to:

r'\bc\s*&&\s*d|a\.set\([^,]+\s*,\s*(?:encodeURIComponent'

and this resolved the problem for at least one video. No time to test properly and make a pull request right now, though.

2reactions
stdedoscommented, Jun 29, 2019

Well … it is maintained. Just slowly.

If you try the latest version pip install git+https://github.com/nficano/pytube.git --upgrade, your video works for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Receiving "pytube.exceptions.RegexMatchError: regex pattern ...
Here is the code that I am using which is providing the error above. import sys import pytube link = input('Enter url: ')...
Read more >
[BUG] RegexMatchError ? · Issue #1199 · pytube ... - GitHub
Looking through the js that the regex is searching is some giant obfuscated mess that I am in no way qualified to deal...
Read more >
How to use the pytube.exceptions.RegexMatchError function ...
To help you get started, we've selected a few pytube.exceptions. ... if not results: raise RegexMatchError( 'regex pattern ({pattern}) had zero matches' ...
Read more >
pytube.exceptions — pytube 12.1.2 documentation
[docs]class RegexMatchError(ExtractError): """Regex pattern did not return any matches.""" def __init__(self, caller: str, pattern: Union[str, Pattern]): ...
Read more >
pytube.exceptions.RegexMatchError: __init__: could not find ...
RegexMatchError : __init__: could not find match for ^\w+\W. RegexMatchError python version: 3.8.10 pytube version: 11.0.2. Code: from pytube import ...
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