Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
walpolsh opened this issue Apr 23, 2019 · 44 comments
Closed

Comments

@walpolsh
Copy link

walpolsh commented Apr 23, 2019

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

@GamingGeek
Copy link

Same issue here...

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```

@gcfrxbots
Copy link

gcfrxbots commented Apr 24, 2019

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

@ffabinhoo
Copy link

Same error here. Python 3.6

@j4tmr
Copy link

j4tmr commented Apr 24, 2019

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

@hasan-dot
Copy link

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

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

@ffabinhoo
Copy link

So do we have to wait for the update?

@minogame
Copy link

minogame commented Apr 24, 2019

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)), ])

@abdellatifLabr
Copy link

Same error here. Python 3.5

@Prithvi45
Copy link

Same here as well

@changyangloong
Copy link

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~

@rriley
Copy link

rriley commented Apr 24, 2019

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.

@ndg63276
Copy link

Yeah commenting out those lines seems to fix for me.

@DeeJayhX
Copy link

DeeJayhX commented Apr 24, 2019

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?

@RudreshVeerkhare
Copy link

Same error here...

@galaxyair
Copy link

Same error! Two weaks ago was working

@galaxyair
Copy link

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

@partriv
Copy link

partriv commented Apr 24, 2019

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

@ulfgj
Copy link

ulfgj commented Apr 24, 2019

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

@ghost
Copy link

ghost commented Apr 25, 2019

Same error! Two days ago was working!

@maks-us
Copy link

maks-us commented Apr 25, 2019

Same error! Pytube 9.4.0
This comment temporary solved the issue. #381 (comment)

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

@ghwn
Copy link

ghwn commented Apr 25, 2019

Same error as well. Python 3.7.3 and Pytube 9.4.0

@BenjaminMWargo
Copy link

Same error on 3.7.3

@x-1337-x
Copy link

x-1337-x commented Apr 25, 2019

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\pytube\extract.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.

@poohpeer
Copy link

Same for me 9.4.0. Python 3.7

@frankcell
Copy link

Same for me 9.4.0. Python 3.5

@nhatton96
Copy link

same for me 9.4.0 Python 2.7

@nanato12
Copy link

nanato12 commented Apr 26, 2019

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 😊😊

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.

@nanato12
Copy link

nanato12 commented Apr 26, 2019

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)),
        ])

@galaxyair
Copy link

Moreover, object like views,rating doesnt work

@lovavliet
Copy link

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?

@ulfgj
Copy link

ulfgj commented Apr 26, 2019

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)),

@lovavliet
Copy link

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

@gutohertzog
Copy link

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.

@formazione
Copy link

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

@hungnguyen95
Copy link

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.

@lovavliet
Copy link

This fix finally worked for me to! thank you!

ndg63276 pushed a commit to ndg63276/alexa-youtube that referenced this issue Apr 29, 2019
@ningjianli
Copy link

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!

@wahyubram82
Copy link

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.

@nficano
Copy link
Collaborator

nficano commented May 1, 2019

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.

@nficano
Copy link
Collaborator

nficano commented May 1, 2019

All fixed, fixed rating + views as well

@nficano nficano closed this as completed May 1, 2019
@ulfgj
Copy link

ulfgj commented May 1, 2019 via email

@stdedos
Copy link
Contributor

stdedos commented May 1, 2019

Fixed in 5f4016b

notdansullivan pushed a commit to WHalunen/pytube that referenced this issue May 2, 2019
Temporary fix to issue pytube#381. Updating pytube to handle Youtube's new, updated URLs. Simply commenting out the lines that throw an error when trying to download in video_info_url function.
@rola93
Copy link

rola93 commented May 7, 2019

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!

@zhangpeng0v0
Copy link

pip3 install -U pytube

great!!!

ndg63276 pushed a commit to ndg63276/alexa-youtube that referenced this issue Apr 23, 2022
ndg63276 pushed a commit to ndg63276/alexa-youtube that referenced this issue Apr 23, 2022
ndg63276 pushed a commit to ndg63276/alexa-youtube that referenced this issue Apr 23, 2022
ndg63276 pushed a commit to ndg63276/alexa-youtube that referenced this issue Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests