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

[ie/NBCStations]allow for new nbc_data syntax #12534

Merged
merged 2 commits into from
Mar 16, 2025

Conversation

refack
Copy link
Contributor

@refack refack commented Mar 4, 2025

Description of your pull request and other information

NBC affiliate sites seem to be using new Object.assign(nbc, {... syntax for assigning to the nbc global var

Fixes #

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 those that apply and remove the others:

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

What is the purpose of your pull request? Check those that apply and remove the others:

@@ -736,7 +736,7 @@ def _real_extract(self, url):
webpage = self._download_webpage(url, video_id)

nbc_data = self._search_json(
r'<script>\s*var\s+nbc\s*=', webpage, 'NBC JSON data', video_id)
r'<script>(?:\s*var\s+nbc\s*=|.+?Object\.assign\(nbc,\s*)', webpage, 'NBC JSON data', video_id)
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to avoid the .+? and do this

Suggested change
r'<script>(?:\s*var\s+nbc\s*=|.+?Object\.assign\(nbc,\s*)', webpage, 'NBC JSON data', video_id)
r'(?:<script>?:\s*var\s+nbc\s*=|Object\.assign\(nbc,)', webpage, 'NBC JSON data', video_id)

This comment was marked as resolved.

@bashonly bashonly self-assigned this Mar 5, 2025
@bashonly bashonly added the site-bug Issue with a specific website label Mar 5, 2025
@refack
Copy link
Contributor Author

refack commented Mar 5, 2025

For posterity, the new assign syntax is:

<script>if ("undefined" === typeof nbc) {var nbc = {};}; Object.assign(nbc, {"brand":"nbc",...

@bashonly bashonly merged commit ebac65a into yt-dlp:master Mar 16, 2025
6 checks passed
@refack refack deleted the nbcboston-fix branch March 16, 2025 22:29
iribeirocampos pushed a commit to iribeirocampos/yt-dlp that referenced this pull request Mar 18, 2025
subrat-lima pushed a commit to subrat-lima/yt-dlp that referenced this pull request Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-bug Issue with a specific website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants