Pytube: RegexMatchError: (\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]) had zero matches

Created on 24 Apr 2019  Â·  44Comments  Â·  Source: pytube/pytube

Tried adding the pattern into cipher.py to no effect... help please?

pytube==9.4.0, Python 3.7.1

Traceback (most recent call last):
  File "filename.py", line 13, in <module>
    yt = YouTube(link, on_progress_callback=progress_function)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/__main__.py", line 88, in __init__
    self.prefetch_init()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/__main__.py", line 96, in prefetch_init
    self.prefetch()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/__main__.py", line 170, in prefetch
    age_restricted=self.age_restricted,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/extract.py", line 121, in video_info_url
    group=0,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pytube/helpers.py", line 65, in regex_search
    .format(pattern=pattern),
pytube.exceptions.RegexMatchError: regex pattern (\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]) had zero matches

Most helpful comment

It looks like comment out the related part in codes as a temploary solution works for me.
# I'm not entirely sure whattrepresents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Hi,
Can you please elaborate on that?
Thanks~

Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Notice that we're just commenting out the stuff related to t. I don't know why this works, and I'm guessing there are other bad side-effects, but it got me through my needs for the day.

All 44 comments

Same issue here...

py Traceback (most recent call last): File "c:\users\geek\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\geek\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\Geek\AppData\Local\Programs\Python\Python37-32\Scripts\pytube.exe\__main__.py", line 9, in <module> File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\cli.py", line 58, in main display_streams(args.url) File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\cli.py", line 182, in display_streams yt = YouTube(url) File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\__main__.py", line 88, in __init__ self.prefetch_init() File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\__main__.py", line 96, in prefetch_init self.prefetch() File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\__main__.py", line 170, in prefetch age_restricted=self.age_restricted, File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\extract.py", line 121, in video_info_url group=0, File "c:\users\geek\appdata\local\programs\python\python37-32\lib\site-packages\pytube\helpers.py", line 65, in regex_search .format(pattern=pattern), pytube.exceptions.RegexMatchError: regex pattern (\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]) had zero matches

Also have this exact same error with the exact same log, tested on two different devices both running the newest version of Pytube. Worked perfectly fine yesterday.

This happens when I attempt YouTube(url)

Edit: In python 2.7.9

Same error here. Python 3.6

Same error occurs today. Does Youtube update its html content?

Same error occurs today. Does Youtube update its html content?

yeah it seems like this @jhd4tmr and library Regex match should be updated

So do we have to wait for the update?

It looks like comment out the related part in codes as a temploary solution works for me.

# I'm not entirely sure what ``t`` represents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Same error here. Python 3.5

Same here as well

It looks like comment out the related part in codes as a temploary solution works for me.

# I'm not entirely sure whattrepresents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Hi,
Can you please elaborate on that?
Thanks~

It looks like comment out the related part in codes as a temploary solution works for me.
# I'm not entirely sure whattrepresents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Hi,
Can you please elaborate on that?
Thanks~

Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Notice that we're just commenting out the stuff related to t. I don't know why this works, and I'm guessing there are other bad side-effects, but it got me through my needs for the day.

Yeah commenting out those lines seems to fix for me.

Same issue here. Python 3.7.2
@nficano can we get a pip upgrade pushed for this until the root cause is identified and corrected?

Same error here...

Same error! Two weaks ago was working

It looks like comment out the related part in codes as a temploary solution works for me.
# I'm not entirely sure whattrepresents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Hi,
Can you please elaborate on that?
Thanks~

Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Notice that we're just commenting out the stuff related to t. I don't know why this works, and I'm guessing there are other bad side-effects, but it got me through my needs for the day.

It is worked, but waiting for official fix

same problem here,and @rriley's fix worked. waiting for new production release, but this works for now. Thanks Ryan!

quick and dirty :D works! tnx. hoping for an official fix soon.

Same error! Two days ago was working!

Same error! Pytube 9.4.0
This comment temporary solved the issue. https://github.com/nficano/pytube/issues/381#issuecomment-486206164

It looks like the html doesn't contain expected elements any more.

Same error as well. Python 3.7.3 and Pytube 9.4.0

Same error on 3.7.3

yt = YouTube('https://www.youtube.com/watch?v=BLF-f4kUtAw')
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files (x86)\Python37-32\lib\site-packages\pytube__main__.py", line 88, in __init__
self.prefetch_init()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\pytube__main__.py", line 96, in prefetch_init
self.prefetch()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\pytube__main__.py", line 170, in prefetch
age_restricted=self.age_restricted,
File "C:\Program Files (x86)\Python37-32\lib\site-packages\pytubeextract.py", line 121, in video_info_url
group=0,
File "C:\Program Files (x86)\Python37-32\lib\site-packages\pytube\helpers.py", line 65, in regex_search
.format(pattern=pattern),
pytube.exceptions.RegexMatchError: regex pattern (\W[\'"]?t[\'"]?: ?\'"[\'"]) had zero matches

Python 3.7.3; Pytube 9.4.0

Had the same problem earlier, about a week or more ago, _some attempts were successful_, though. Today, no luck at all.

Same for me 9.4.0. Python 3.7

Same for me 9.4.0. Python 3.5

same for me 9.4.0 Python 2.7

Hi, I can resolve this error.
because I'm Japanese, my english might be funny.
I use Mac only.

for MAC with Python3.7

try this command
ls -l /Library/Frameworks/Python.framework/Versions/3.7/etc/openssl/

if result is empty, try this command.
sudo /Applications/Python\ 3.7/Install\ Certificates.command

and, try it one time
ls -l /Library/Frameworks/Python.framework/Versions/3.7/etc/openssl/

[result]
total 8
lrwxr-xr-x 1 root admin 52 4 26 10:16 cert.pem -> ../../lib/python3.7/site-packages/certifi/cacert.pem

Please try it :blush::blush:

Cause
OpenSSL installed as standard on macOS is too old.
installers for macOS included OpenSSL with Python 3.6 or later.
OpenSSL of the system is not referenced.

As a result, the root certificate installed on the OS is also not referenced.
TLS server certificate validation fails.

must do also this work.

Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Moreover, object like views,rating doesnt work

I had the same error as @walpolsh. After changing the extract.py the error disappears, but it is still not working. No I have the error:

Schermafbeelding 2019-04-26 om 16 07 38

I have python 3.7 installed and tried the things @nanato12 suggested. However it is still not working. Does anyone know what I should do?

I had the same error as @walpolsh. After changing the extract.py the error disappears, but it is still not working. No I have the error:

Schermafbeelding 2019-04-26 om 16 07 38

I have python 3.7 installed and tried the things @nanato12 suggested. However it is still not working. Does anyone know what I should do?

u sure you commented out all these lines?

        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)

as well as

        #('t', quote(t)),

@ulfgj yes I did, this is a new error that showed up after I commented out these lines

It looks like comment out the related part in codes as a temploary solution works for me.
Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Notice that we're just commenting out the stuff related to t. I don't know why this works, and I'm guessing there are other bad side-effects, but it got me through my needs for the day.

Worked fine here. Thanks.
Waiting for the official release.

I tried the #t thing... it works for some videos but for others not!? python 3.7

It looks like comment out the related part in codes as a temploary solution works for me.
# I'm not entirely sure whattrepresents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Hi,
Can you please elaborate on that?
Thanks~

Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Notice that we're just commenting out the stuff related to t. I don't know why this works, and I'm guessing there are other bad side-effects, but it got me through my needs for the day.

This solution is worked for some videos, others are not.
Waiting for official fix.

This fix finally worked for me to! thank you!

It looks like comment out the related part in codes as a temploary solution works for me.
# I'm not entirely sure whattrepresents. Looks to represent a # boolean. # t = regex_search( # r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html, # group=0, # ) params = OrderedDict([ ('video_id', video_id), ('el', '$el'), ('ps', 'default'), ('eurl', quote(watch_url)), ('hl', 'en_US'), # ('t', quote(t)), ])

Hi,
Can you please elaborate on that?
Thanks~

Go to extract.py line 116 and change the following to look like:

    else:
        # I'm not entirely sure what ``t`` represents. Looks to represent a
        # boolean.
        #t = regex_search(
        #    r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
        #    group=0,
        #)
        params = OrderedDict([
            ('video_id', video_id),
            ('el', '$el'),
            ('ps', 'default'),
            ('eurl', quote(watch_url)),
            ('hl', 'en_US'),
            #('t', quote(t)),
        ])

Notice that we're just commenting out the stuff related to t. I don't know why this works, and I'm guessing there are other bad side-effects, but it got me through my needs for the day.

Thanks! It works!

No one try to debugging the script?
regex error means, the script try to read youtube source code and search a link to get the video source.

I'm affraid youtube make the link not shown before we do something, example click the play button.
need time to learn how this script working...

if the author answer what kind of link he search in youtube, maybe we can help him faster. if not we should do a debugging process, that mean try every step of script and see what the result to understood how this script working.

Hi folks, sorry for not being responsive here, I have become incredibly busy in recent months and haven't been able to support the project as much as I would like. Let me look into this now. I'll post an update for everyone shortly.

All fixed, fixed rating + views as well

yay nick!

On Wed, 1 May 2019, 17:20 Nick Ficano, notifications@github.com wrote:

Closed #381 https://github.com/nficano/pytube/issues/381.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nficano/pytube/issues/381#event-2312092081, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AA7KIL7D6CQD6AKWWC72223PTGYJ7ANCNFSM4HH7G4CA
.

All fixed, fixed rating + views as well

for me it was not that obvious, so I let it here just in case...

It's already merged in master, so pip install -U pytube to get the corrected version (9.5.0)

Thank you!

pip3 install -U pytube

great!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stdedos picture stdedos  Â·  24Comments

xenonstride picture xenonstride  Â·  19Comments

RONNCC picture RONNCC  Â·  29Comments

ajayrandhawa picture ajayrandhawa  Â·  20Comments

sk1122 picture sk1122  Â·  18Comments