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 crash in _report_ignoring_subs #32762

Merged
merged 6 commits into from
Apr 5, 2024

Conversation

salty-horse
Copy link
Contributor

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl 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?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

When subs are not available and _report_ignoring_subs is called, it crashes because it passes an argument to bug_reports_message, which accepts none.

I changed it to be appended to the message, like what's done in other places.
Now the message is like this:

WARNING: [youtube] Ignoring subtitle tracks found in the DASH manifest; if any subtitle tracks are missing, ; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

The ", ;" is not correct but I don't know if you want to get rid of the semicolon. The important thing is that it doesn't crash, and the file can be downloaded.

@dirkf
Copy link
Contributor

dirkf commented Apr 5, 2024

Thanks, good catch.

There was supposed to be a matching change to utils.py: I'd prefer to add that rather than change the code in extractor/common.py.

Would you like to revert your change and apply the missing change (adapted from yt-dlp) instead?

--- old/youtube-dl/youtube_dl/utils.py
+++ new/youtube-dl/youtube_dl/utils.py
@@ -2371,15 +2371,24 @@
         return YoutubeDLHTTPSHandler(params, context=context, **kwargs)
 
 
-def bug_reports_message():
+def bug_reports_message(before=';'):
     if ytdl_is_updateable():
         update_cmd = 'type  youtube-dl -U  to update'
     else:
-        update_cmd = 'see  https://yt-dl.org/update  on how to update'
-    msg = '; please report this issue on https://yt-dl.org/bug .'
-    msg += ' Make sure you are using the latest version; %s.' % update_cmd
-    msg += ' Be sure to call youtube-dl with the --verbose flag and include its complete output.'
-    return msg
+        update_cmd = 'see  https://github.com/ytdl-org/youtube-dl/#user-content-installation  on how to update'
+
+    msg = (
+        ' please report this issue on https://github.com/ytdl-org/youtube-dl/issues ,'
+        ' using the appropriate issue template.'
+        ' Make sure you are using the latest version; %s.'
+        ' Be sure to call youtube-dl with the --verbose option and include the complete output.'
+    ) % update_cmd
+
+    before = (before or '').rstrip()
+    if not before or before.endswith(('.', '!', '?')):
+        msg = msg[0].title() + msg[1:]
+
+    return (before + ' ' if before else '') + msg
 
 
 class YoutubeDLError(Exception):

@salty-horse
Copy link
Contributor Author

salty-horse commented Apr 5, 2024

@dirkf That makes much more sense!

I'm uncomfortable with copy-pasting someone else's code without credit - I'd much rather you commit it as originally intended.

Copy link
Contributor

@dirkf dirkf left a comment

Choose a reason for hiding this comment

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

With my maintainer superpower, I (will) have added some commits into your PR branch to make my suggested change.

It would be a great help if you'd be able to pull the latest version of the branch and test that the issue is fixed (since I'm deep in the mind-numbing twaddle that fixing the TikTok extractor brings).

Once it's OK, I can merge the PR as a single commit credited to us jointly with acknowledgments to yt-dlp, and then it can be in the next nightly build.

Revert and fix `utils.bug_reports_message()` (1)

skipci
youtube_dl/utils.py Outdated Show resolved Hide resolved
youtube_dl/utils.py Outdated Show resolved Hide resolved
@salty-horse
Copy link
Contributor Author

The video that caused the issues no longer does (probably because it was a live video on youtube, and after a while, I think they re-encode it in a different format.) But I forced the error, and it works fine.

My only suggestion is removing the whitespace before please report this issue, because it the error has a double space:
if any subtitle tracks are missing, please report this issue

youtube_dl/utils.py Outdated Show resolved Hide resolved
@dirkf
Copy link
Contributor

dirkf commented Apr 5, 2024

Yes, the crash would only have been seen in this specific combination of circumstances:

  • the selected format is a DASH manifest
  • the manifest has subtitles
  • the extractor calls the original yt-dl DASH extraction API _extract_mpd_formats(), rather than the newer yt-dlp API _extract_mpd_formats_and_subtitles() (this might be all yt-dl extractors at the moment).

Many thanks for your help!

@dirkf dirkf merged commit 4ea59c6 into ytdl-org:master Apr 5, 2024
14 checks passed
@salty-horse salty-horse deleted the report_ignoring_subs_crash branch April 5, 2024 15:40
github-actions bot added a commit to hellopony/youtube-dl that referenced this pull request Apr 5, 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.

2 participants