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
Backports from youtube-dl #9523
Comments
Why not update #21 ? |
IMO its easier to track these in a new issue, especially since they were suppose to make it to last release but didnt |
I'm sure you'll feel free to propose any question/fix that comes up while doing this. |
I'm not sure if [utils] base for int_or_none should be ported. The applications would be Thoughts? |
I posit the simplified code and alignment with Related, I suggest |
That code is not pretty like it was before for several reasons imo. Id like to think what the others say, but I guess compat with youtube-dl would be a problem otherwise... @bashonly and I have been debating more traversal helpers as well, and |
Do we really need syntactic sugar for
Can you explain? btw, @dirkf. Any reason you set |
IMO yes, because in the extractors where we use this, we tend to use it in multiple places. There are already several extractors that define a
|
gotcha
I only found
Impl: diff --git a/yt_dlp/utils/_utils.py b/yt_dlp/utils/_utils.py
index a4f69385c..3225149ac 100644
--- a/yt_dlp/utils/_utils.py
+++ b/yt_dlp/utils/_utils.py
@@ -1944,6 +1944,15 @@ def urljoin(base, path):
return urllib.parse.urljoin(base, path)
+def curriable(func): # TODO: Better name?
+ @functools.wraps(func)
+ def wrapper(*args, **kwargs):
+ if args[:1] == (..., ):
+ return lambda x: func(x, *args[1:], **kwargs)
+ return func(*args, **kwargs)
+ return wrapper
+
+@curriable
def int_or_none(v, scale=1, default=None, get_attr=None, invscale=1):
if get_attr and v is not None:
v = getattr(v, get_attr, None) Usage |
When using a functional expression in a traversal, expressions can become extremely lisp-y with multiple nested parentheses: as a late convert to GvR's transformation of Lisp, I'm not unhappy with that, but simplifying such expressions is a good thing and the Existing uses with |
In fact, there are several tens of extractors that scale by 1000, maybe enough to justify a kilo = lambda fn: functools.partial(fn, scale=1000) But that's going to be evaluated in each traversal expression, unless pre-assigned which vitiates the shorthand, whereas a |
Looking at the list, the FFmpeg detection is much more sophisticated here but possibly the underlying problem described in ytdl-org/youtube-dl#32735 (comment) persists. |
We work around it in the CLI by setting ffmpeg location to a contextvar. Lines 965 to 968 in 89f535e
.globals module in the future. Some other issues like utils disobeying log level etc can also be addressed using it.
|
And #2191 (comment) ? |
Regarding the updated
Maybe a float literal should be accepted (as if |
Yes, that is still an issue. The proposed |
Tracking issue for youtube-dl backports
Core
range
for mpd fragmentsbase
forint_or_none
playlist_maxcount
expected valueExtractors
The text was updated successfully, but these errors were encountered: