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

[Feature request] Change extractor.*.keywords to be format string #5621

Closed
shrublet opened this issue May 21, 2024 · 5 comments
Closed

[Feature request] Change extractor.*.keywords to be format string #5621

shrublet opened this issue May 21, 2024 · 5 comments

Comments

@shrublet
Copy link

I'm unsure if this is feasible, but I find the keywords to not be as useful as I'd like since you're limited to only using plain strings. My personal use-case is normalizing certain keywords for use within a post-processor (which I currently do within the post-processor), but this would be useful too for normalizing values used within the config too. I currently have many filters and options in different sub/categories that only slightly differ due to different keywords per site, but allowing keywords to be derived from keywords would thusly allow standardization and simplification of the configuration file.

@mikf
Copy link
Owner

mikf commented May 21, 2024

So something like yt-dlp's --parse-metadata and --replace-in-metadata?

It is possible to achieve a similar function like those with a metadata post processor in modify mode.

    {
        "name": "metadata",
        "mode": "modify",
        "event": "prepare",
        "fields": {
            "title": "{tag_string[:10]}"
        }
    }

Not really command-line friendly, but it might be possible to add a command-line option similar to --parse-metadata that makes use of this.

due to different keywords per site

Using the same name for the same type of fields across all sites is something I'd like to do for v2.0, so ... Soon ™️

@shrublet
Copy link
Author

shrublet commented May 23, 2024

    {
        "name": "metadata",
        "mode": "modify",
        "event": "prepare",
        "fields": {
            "title": "{tag_string[:10]}"
        }
    }

Basically exactly what I needed, thank you so much! Totally missed this in the docs. In conjunction with keywords, I can define some template keywords and map values from other keywords as well as do whatever operations on it. Ok don't need to define them first or else they keep getting reinserted with their filler values. I wasn't sure if modify worked without the values existing already, but it does :). Awesome!

Using the same name for the same type of fields across all sites is something I'd like to do for v2.0, so ... Soon ™️

No rush! Thank you for entertaining my inquiry. I'll keep this issue open though in case you still wish to implement this or something similar to --parse-metadata. Much appreciated again.

mikf added a commit that referenced this issue May 23, 2024
to allow evaluating 'keywords' values as format strings
@mikf
Copy link
Owner

mikf commented May 23, 2024

I've added a keywords-eval option which evaluates keywords values as format strings when enabled. This provides kind of the same functionality as "mode": "modify", but this should be less verbose.

@shrublet
Copy link
Author

Awesome! My only issue with using "mode": "modify" was that these keywords were only available once the post-processor was run (i.e. I couldn't see the values with a DataJob/using -K or -j in the command line). I presume the keywords with keywords-eval would be evaluated before post-processor initialization and thusly available in the aforementioned scenarios? Thank you so much for the quick implementation.

@mikf
Copy link
Owner

mikf commented May 25, 2024

i.e. I couldn't see the values with a DataJob/using -K or -j in the command line

DataJob/-K/-j don't run post processors. keywords get evaluated independently and before any post processors, but still after --filter.

@mikf mikf closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants