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

[extractor/common] Fix _search_nuxt_data #6062

Merged
merged 2 commits into from
Feb 12, 2023

Conversation

LowSuggestion912
Copy link
Contributor

IMPORTANT: PRs without the template will be CLOSED

Description of your pull request and other information

Fixes _search_nuxt_data incorrectly handling strings containing commas.

For example

webpage = '''
<script>
window.__NUXT__=(function(a,b){return
  {str1:a,str2:b}}("cool,string","lame string"));
</script>
'''

print(self._search_nuxt_data(webpage, None, traverse=None))

should produce
{'str1': 'cool,string', 'str2': 'lame string'}

instead of
{'str1': 'cool', 'str2': 'string'}

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

Fix _search_nuxt_data incorrectly handling strings containing commas.

For example
```
<script>
window.__NUXT__=(function(a,b){return
  {str1:a,str2:b}}("cool,string","lame string"));
</script>
```

should produce
`{'str1': 'cool,string', 'str2': 'lame string'}`

instead of
`{'str1': 'cool', 'str2': 'string'}`
Copy link
Member

@Grub4K Grub4K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. The current result is even a bit more messed up, namely {'str1': '"cool', 'str2': 'string"'}

yt_dlp/extractor/common.py Outdated Show resolved Hide resolved
Co-authored-by: Simon Sawicki <accounts@grub4k.xyz>
@pukkandan pukkandan merged commit b23167e into yt-dlp:master Feb 12, 2023
@LowSuggestion912 LowSuggestion912 deleted the fix/_search_nuxt_data branch February 12, 2023 21:23
aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
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

Successfully merging this pull request may close these issues.

None yet

3 participants