templates:
  limited_series:
    configure_series:
      from:
        filesystem:
          path:
            - ~/media/vids/series
            # - ~/media/vids/features
          recursive: false
          retrieve: dirs
      settings:
        identified_by: ep
        path: '~/media/vids/series/{{ series_name }}'
        target: 1080p
        timeframe: 2 weeks
        parse_only: true
    exists_series:
      path: '~/media/vids/series/{{ series_name }}'
      allow_different_qualities: better
  feature_films:
    csv:
      url: 'file://%7e/media/vids/features/.films.csv'
      values:
        title: 1
        url: 2
    list_add:
      - entry_list: films
  porn_vids:
    csv:
      url: 'file://%7e/.xxx/.vids.csv'
      values:
        title: 1
        url: 2
    list_add:
      - entry_list: pornos
tasks:
  # @NOTE uncommenting aria2 block requires commenting out download and proxy blocks
  populate_folders:
    {% if download_mode == 'direct' %}
    proxy:
      https: 'socks5://<< tor.proxy.hostname >>:<< tor.proxy.port >>'
    {% endif %}
    if:
      - "'batch' in title.lower()": reject
    discover:
      what:
        - next_series_episodes:
            from_start: true
            backfill: false
      from:
        - nyaa:
            category: anime eng
            filter: trusted only
        - search_rss:
            url: 'https://nyaa.si/?f=2&c=1_2&q={{ search_term }}'
            link:
              - magneturi
              - link
            all_entries: false
        - eztv: true
      interval: 1 week
      limit: 80
    template: limited_series
    {% if flexget.download_mode == 'aria2' %}
    aria2:
      server: << aria.rpc.hostname >>
      port: << aria.rpc.port >>
      {% if aria.rpc.secret != None and aria.rpc.secret is defined %}
      secret: << aria.rpc.secret >>
      {% elif aria.rpc.credentials != None and aria.rpc.credentials is defined %}
      username: << aria.rpc.credentials.username >>
      password: << aria.rpc.credentials.password >>
      {% endif %}
      {% if mode == 'prod' %}
      scheme: << aria.rpc.scheme >>
      {% else %}
      scheme: http
      {% endif %}
      rpc_mode: json
      rpc_path: jsonrpc
      path: '~/downloads/media/vids/{{ series_name }}'
    {% else %}
    download:
      temp: ~/.tmp
      path: '~/downloads/flexget/vids/series/torrents/{{ series_name }}'
    {% endif %}
  # @NOTE uncommenting aria2 block requires commenting out download and proxy blocks
  fap_queue:
    {% if download_mode == 'direct' %}
    proxy:
      https: 'socks5://<< tor.proxy.hostname >>:<< tor.proxy.port >>'
    {% endif %}
    template: porn_vids
    {% if flexget.download_mode == 'aria2' %}
    aria2:
      server: << aria.rpc.hostname >>
      port: << aria.rpc.port >>
      {% if aria.rpc.secret != None and aria.rpc.secret is defined %}
      secret: << aria.rpc.secret >>
      {% endif %}
      {% if aria.rpc.credentials != None and aria.rpc.credentials is defined %}
      username: << aria.rpc.credentials.username >>
      password: << aria.rpc.credentials.password >>
      {% endif %}
      {% if mode == 'prod' %}
      scheme: << aria.rpc.scheme >>
      {% else %}
      scheme: http
      {% endif %}
      rpc_mode: json
      rpc_path: jsonrpc
      path: ~/downloads/.xxx/media/vids
    {% elif flexget.download_mode == 'direct' %}
    download:
      temp: ~/.tmp
      path: ~/downloads/.xxx/flexget/vids/torrents
    {% endif %}
  # @NOTE uncommenting aria2 block requires commenting out download and proxy blocks
  film_queue:
    {% if download_mode == 'direct' %}
    proxy:
      https: 'socks5://<< tor.proxy.hostname >>:<< tor.proxy.port >>'
    {% endif %}
    template: feature_films
    {% if flexget.download_mode == 'aria2' %}
    aria2:
      server: << aria.rpc.hostname >>
      port: << aria.rpc.port >>
      {% if aria.rpc.secret != None or aria.rpc.secret is defined %}
      secret: << aria.rpc.secret >>
      {% endif %}
      {% if aria.rpc.credentials != None or aria.rpc.credentials is defined %}
      username: << aria.rpc.credentials.username >>
      password: << aria.rpc.credentials.password >>
      {% endif %}
      {% if mode == 'prod' %}
      scheme: << aria.rpc.scheme >>
      {% else %}
      scheme: http
      {% endif %}
      rpc_mode: json
      rpc_path: jsonrpc
      path: ~/downloads/media/vids
    {% elif flexget.download_mode == 'direct' %}
    download:
      temp: ~/.tmp
      path: ~/downloads/flexget/vids/torrents
    {% endif %}