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

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

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 44 (1 by maintainers)

Commits related to this issue

Most upvoted comments

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 fixed, fixed rating + views as well

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

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

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!

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 .

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.

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.

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?