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.

Could not find match for config_patterns for certain urls

See original GitHub issue

Hi, I started using pyTube just recently and I am very happy with the functionality. I am using it to download music tracks from YouTube Music.

In most of my tests, it worked great, but with some urls I catch an exception:

pytube.exceptions.RegexMatchError: get_ytplayer_config: could not find match for config_patterns

For example it occurs with this track: https://www.youtube.com/watch?v=hbFQARBbZww

I am neither good at regex, nor do I really understand what to search for in the analyzed html. Do you maybe have a solution for this issue, or can you give me some hints about how to fix the issue myself?

Best regards, Lukas

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
ruizrcommented, Oct 17, 2020

Hi sirodus, I tried both versions mentioned in your comment, but both were unsuccessful.

r"'PLAYER_CONFIG':\s*({.*})});" r"'PLAYER_CONFIG':\s*({.*})}\);"

Could you please check if there is a typo or something in your comment if you were successful using the regex?

I modified the file “extract.py” in line 187 with the following (keep attention to open-close variables):

config_patterns = [
    r";ytplayer\.config\s*=\s*({.*?});",
    r";ytplayer\.config\s*=\s*({.+?});ytplayer",
    r";yt\.setConfig\(\{'PLAYER_CONFIG':\s*({.*})}\);",
    r";yt\.setConfig\(\{'PLAYER_CONFIG':\s*({.*})(,'EXPERIMENT_FLAGS'|;)",  # noqa: E501
r"'{PLAYER_CONFIG':\s*({.*})});" ]

and works like a charm!!!.

2reactions
siroduscommented, Sep 23, 2020

Hi, I spent an hour on it but found a solution, specially set up an account here to share it. In the pytube/extract.py file, add to the config_patterns list r"‘PLAYER_CONFIG’:\s*({.*})});" it’s supposed to look like this config_patterns = [ r";ytplayer\.config\s*=\s*({.*?});", r";ytplayer\.config\s*=\s*({.+?});ytplayer", r";yt\.setConfig\(\{'PLAYER_CONFIG':\s*({.*})}\);", r";yt\.setConfig\(\{'PLAYER_CONFIG':\s*({.*})(,'EXPERIMENT_FLAGS'|;)", # noqa: E501 r"'PLAYER_CONFIG':\s*({.*})}\);", ]

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytube error - get_ytplayer_config: could not find match for ...
This error (RegexMatchError: get_ytplayer_config: could not find match for config_patterns) is due to Pytube known issue.
Read more >
URL match patterns · Issue #373 · darkreader ... - GitHub
Implement user-friendly URL glob patterns with negation ability and some special behavior. Similar to globby, extension match patterns etc.
Read more >
Match patterns in extension manifests - Mozilla - MDN Web Docs
Match patterns are a way to specify groups of URLs: a match pattern matches a specific set of URLs. They are used in...
Read more >
Allow specific URL patterns - Firebase Help - Google Support
If you specify URL patterns, any URL that doesn't match one of the patterns will cause your Dynamic Links to return HTTP error...
Read more >
Chrome Extensions Match patterns - Chrome Developers
The following table shows some valid patterns. Note: urn scheme is available since Chrome 91. Pattern, What it does, Examples of matching URLs....
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