Quantcast
Channel: configuration - Forum - FlexGet
Viewing all articles
Browse latest Browse all 716

Factoring out common lines

$
0
0

@i-love-coding wrote:

Hi, I have a simple question for which haven't found yet the solution (I've been reading the FM but still...)

I have a config.yml like:

variables: variables.yml

templates:
  movies:
    transmission:
      host: localhost
      port: 9091
      username: USERNAME_HERE
      password: PASSWORD_HERE
      path: SOME_PATH
      include_subs: yes
      addpaused: no
      enabled: Yes

tasks:

  get720:
    rss: RSS_FEED_1
    accept_all: yes
    template: movies
    imdb_lookup: yes
    set:
      path: STORAGE_PATH_1
      content_filename: "{{ title|replace(' ','.') }}"
    exec:
      on_output:
        for_accepted:
          - echo 'Synopsis | {{ imdb_plot_outline }}' >> STORAGE_PATH_1/{{ title|replace(' ','.') }}.nfo
          - echo 'ITEM_2 | {{ imdb_ITEM_2 }}' >> STORAGE_PATH_1/{{ title|replace(' ','.') }}.nfo
          - echo 'ITEM_3 | {{ imdb_ITEM_3 }}' >> STORAGE_PATH_1/{{ title|replace(' ','.') }}.nfo
          - echo 'ITEM_4 | {{ imdb_ITEM_4 }}' >> STORAGE_PATH_1/{{ title|replace(' ','.') }}.nfo
					...
          - echo 'ITEM_N | {{ imdb_ITEM_N }}' >> STORAGE_PATH_1/{{ title|replace(' ','.') }}.nfo

  get1080:
    rss: RSS_FEED_2
    accept_all: yes
    template: movies
    imdb_lookup: yes
    set:
      path: STORAGE_PATH_2
      content_filename: "{{ title|replace(' ','.') }}"
    exec:
      on_output:
        for_accepted:
          - echo 'Synopsis | {{ imdb_plot_outline }}' >> STORAGE_PATH_2/{{ title|replace(' ','.') }}.nfo
          - echo 'ITEM_2 | {{ imdb_ITEM_2 }}' >> STORAGE_PATH_2/{{ title|replace(' ','.') }}.nfo
          - echo 'ITEM_3 | {{ imdb_ITEM_3 }}' >> STORAGE_PATH_2/{{ title|replace(' ','.') }}.nfo
          - echo 'ITEM_4 | {{ imdb_ITEM_4 }}' >> STORAGE_PATH_2/{{ title|replace(' ','.') }}.nfo
					...
          - echo 'ITEM_N | {{ imdb_ITEM_N }}' >> STORAGE_PATH_2/{{ title|replace(' ','.') }}.nfo

there are more tasks, and for each one the exec section is always the same, except for the STORAGE_PATH which varies...

So question is if there is a way to write the exec part just once, and have jinja2 or anything taking care of the difference

The ideal solution would be to parameterize it like a function, each section accepting a different STORAGE_PATH, but I know it isn't possible to parameterize a block of config lines (however something similar to that is what I'm looking for, no matter how it's achived)

This way if I introduce a change in the exec part I won't have to change every one of them which is prone to errors and tedious for several tasks

Thanks in advance !

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 716

Trending Articles