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
6720: Pressing enter uses default format #7101
Conversation
Let me know what you think of the changes |
Moving of the Easy to read and understand: req_format = input(self._format_screen('\nEnter format selector (press ENTER for default, or CTRL+C to quit): ', self.Styles.EMPHASIS)) Not so easy to read and understand: req_format = input(' '.join((
self._format_screen('\nEnter format selector', self.Styles.EMPHASIS),
'(Press ENTER for default, or Ctrl+C to quit)',
self._format_screen(': ', self.Styles.EMPHASIS))
)) Does using join on an empty string with a space, and using two _format_screen() give benefits in Python that I am not aware of? If the line was too long, we could separate the long text into a helper variable, but it was probably is fine the way it was. prompt = '\nEnter format selector (press ENTER for default, or CTRL+C to quit): '
req_format = input(self._format_screen(prompt, self.Styles.EMPHASIS)) |
Take note that we are applying emphasis to just the parts that are not in the braces. We deliberately use |
I am afraid I do not understand what you mean by "(...) take emphasis away from the braced part". Could you elaborate on what you mean? Is this a specific coding convention, or is there a functional purpose to this? I agree regarding hanging brace, I recall reading the contribution docs about that avoiding hanging paranthesis. π |
We are calling
I think we should go one further and use |
Extracting the emphasis into a function is overkill. Having to write the style to format with does not make it more unreadable imo. If thats reverted it LGTM |
While I appreciate your viewpoint and will duly revert the changes, I have a suggestion that could enhance our coding practices moving forward. To maintain a clean codebase and ensure easier code maintenance, I propose we adopt a strategy of separating concerns (YoutubeDL.py appears to do a little of everything). Specifically, we could introduce a dedicated class and corresponding functions to manage formatting tasks. This approach would mitigate the reliance on a multipurpose function, which can potentially augment complexity and demand a higher level of knowledge for utilization. In the context of the function in question, its use cases appear to be quite limited, with only two observable uses: one involving FILENAME, and a few instances with self.Styles.EMPHASIS. These observations further endorse the implementation of dedicated functions for each distinct task. πΊ |
Thats already semi in progress. There are two big networking PRs, partially getting merged bit by bit into the codebase, there is #5680 doing the formatting and output separation. It just takes time and is a chore since the reworks are big and reviews take time, and we need to keep compat (somewhat) on the side... |
ee280c7
to
7aeda6c
Compare
Authored by: ivanskodje, pukkandan Closes yt-dlp#6720
IMPORTANT: PRs without the template will be CLOSED
Description of your pull request and other information
Original Issue Description:
Fixes #6720
PLEASE FOLLOW THE GUIDE BELOW
x
into all the boxes[ ]
relevant to your pull request (like [x])-->
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 all of the following options that apply:
What is the purpose of your pull request?
Copilot Summary
π€ Generated by Copilot at 7239233
Summary
πποΈπ
Add default format spec option and debug message to interactive format selection mode in
yt_dlp/YoutubeDL.py
Walkthrough