Skip to content

Add Jinja templating to Transmission labels#3886

Merged
gazpachoking merged 8 commits intoFlexget:developfrom
g-regor:transmission-labels
Dec 5, 2023
Merged

Add Jinja templating to Transmission labels#3886
gazpachoking merged 8 commits intoFlexget:developfrom
g-regor:transmission-labels

Conversation

@g-regor
Copy link
Copy Markdown
Contributor

@g-regor g-regor commented Nov 21, 2023

Motivation for changes:

With this, some series properties can be automatically added as a label

Detailed changes:

  • labels can be either a string or a list of strings
  • If a label contains a comma, it's split into multiple labels
  • Commas from rendered Jinja templates are removed (Transmission doesn't allow them)
  • Whitespace is trimmed and empty labels are removed
  • Labels defined in the series entry are concatenated with the labels defined under transmission, instead of overridden

Config usage if relevant (new plugin or updated schema):

tasks:
  Task-name:
    transmission:
      ...
      labels: "Source: xyz, Series: {{series_name}}, Quality: {{quality}}"
    series:
      - "The Show":
          set:
            labels:
              - Drama
              - Funny

This results in ["Source: xyz", "Series: The Show", "Quality: 1080p", "Drama", "Funny"]

@ianstalk
Copy link
Copy Markdown
Contributor

Are you certain that Transmission doesn't support commas in labels? Also I would update the docstring.

@g-regor
Copy link
Copy Markdown
Contributor Author

g-regor commented Nov 29, 2023

Are you certain that Transmission doesn't support commas in labels?

Yes

@gazpachoking
Copy link
Copy Markdown
Member

gazpachoking commented Dec 4, 2023

I'm good with this, the only thing I'm dubious about is the string formatted comma delimited multi-label configuration. I think we should just require multiple labels to be in a list.
i.e. Instead of this:

      labels: "Source: xyz, Series: {{series_name}}, Quality: {{quality}}"

require this:

      labels:
        - "Source: xyz"
        - "Series: {{series_name}}"
        - "Quality: {{quality}}"

@g-regor
Copy link
Copy Markdown
Contributor Author

g-regor commented Dec 4, 2023

So, is concatenating labels from config and entry ok, since it's goes against how that usually works?

@gazpachoking
Copy link
Copy Markdown
Member

So, is concatenating labels from config and entry ok, since it's goes against how that usually works?

Yeah, I guess that's good. Seems like it's a bit more flexible than just overriding config labels with entry labels.

@g-regor
Copy link
Copy Markdown
Contributor Author

g-regor commented Dec 4, 2023

Are certain fields always available in templates?
Can "quality" not be there?

The documentation says that it will produce an empty string, but I noticed that invalid fields cause an exception.
And in code, it actually just captures the exception and logs the error.

It should probably be done here the same.
And should the label just be ignored or left unrendered?

@gazpachoking
Copy link
Copy Markdown
Member

The documentation says that it will produce an empty string, but I noticed that invalid fields cause an exception.
And in code, it actually just captures the exception and logs the error.

Yeah, that documentation is probably oversimplified/innacurate depending on where templates are being used. I'd say we should catch errors and log a warning then ignore that label for ones that the rendering failed here.

@gazpachoking gazpachoking merged commit 7c854fd into Flexget:develop Dec 5, 2023
@gazpachoking
Copy link
Copy Markdown
Member

Looks good. Thanks for this!

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.

3 participants