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

NameError in filter #2559

Closed
UlyssesZh opened this issue May 5, 2022 · 5 comments
Closed

NameError in filter #2559

UlyssesZh opened this issue May 5, 2022 · 5 comments

Comments

@UlyssesZh
Copy link

UlyssesZh commented May 5, 2022

target[src] and content[src] appear in the output of -K, but using them causes NameError (none of target, content, src is defined). Is this a bug? Or did I do something wrong?
I was trying to download something from DeviantArt by filtering by source url.

@mikf
Copy link
Owner

mikf commented May 5, 2022

-K shows the syntax used in format strings. In actual Python code (--filter), you need to put those key values in quotes to make them strings: target['src']. target.get('src') would also work.

@UlyssesZh
Copy link
Author

I see. I think it is better to clarify that in the output of -K.

@mikf
Copy link
Owner

mikf commented May 5, 2022

Do you have an idea or a suggestion how? The output is already cluttered as is.
I also kind of expect users to know the difference between format strings and Python expressions and how to access data when using "advanced" stuff in --filter.

Alternatively, you can use -j --range 1 to get a better(?) look at the actual data and how it is structured, or you specify a name for the download URL value and use that: -o url-metadata=dlurl --> --filter "print(dlurl)"

@UlyssesZh
Copy link
Author

Oh! I found a case where there is unexpected NameError. The minimum reproducing code is:

gallery-dl --filter "any(map(lambda s: extension, ['']))" deviantart.com/ayyasap

Output:

[deviantart][error] FilterError: Evaluating filter expression failed (NameError: name 'extension' is not defined)

@UlyssesZh
Copy link
Author

Do you have an idea or a suggestion how? The output is already cluttered as is.

What about this: in the output of -K, change

Keywords for filenames and --filter:
------------------------------------

into

Keywords for filenames and --filter (for use in filters, add quotes to the keys):
------------------------------------

or other wordings.

@mikf mikf closed this as completed Mar 25, 2023
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

No branches or pull requests

2 participants