variables: secretfile.yml

web_server: no

schedules:
  - tasks: '*'
    interval:
      minutes: 30

templates:
  global:
    pathscrub: windows
    
    metainfo_series: yes
    thetvdb_lookup: yes
    trakt_lookup: yes
    parsing:
      series: guessit
    
    manipulate:
      - title:
          replace:
            regexp: '&#039;'
            format: "'"

    transmission:
      host: '{? transmlogin.host ?}'
      port: 9091
      username: '{? transmlogin.username ?}'
      password: '{? transmlogin.password ?}'
      magnetization_timeout: 15
      ratio: 3

  tvshows:
    quality: 720p
    set:
      path: /media/video/TV series/{{series_name_rus}} [{{trakt_series_name}}] ({{trakt_series_year}})/Season {{series_season}}/
  
  notifycation:
    notify:
      entries:
        message: |+
          {% if episode_name_rus is defined -%}
          *{{series_name_rus}} / {{episode_name_rus}}*
          _{{series_season}} сезон {{series_episode}} серия_
          рейтинг: {{tvdb_ep_rating}}
          [Постер]({{tvdb_banner}})
          {{series_name_rus}} \[{{trakt_series_name}}] ({{trakt_series_year}})
          {% else -%}
          *{{series_name_rus}} / {{trakt_ep_name}}*
          _{{series_season}} сезон {{series_episode}} серия_
          рейтинг: {{tvdb_ep_rating}}
          [Постер]({{tvdb_banner}})
          {{series_name_rus}} \[{{trakt_series_name}}] ({{trakt_series_year}})
          {%- endif -%}
        via:
          - telegram:
             bot_token: '{? telegram.bottoken ?}'
             parse_mode: markdown
             recipients:
               - username: '{? telegram.user1.username ?}'
               - username: '{? telegram.user2.username ?}'
               - username: '{? telegram.user3.username ?}'

  clean:
    clean_transmission:
      host:  '{? transmlogin.host ?}'
      port: 9091
      username: '{? transmlogin.username ?}'
      password: '{? transmlogin.password ?}'
      finished_for: 30 days

tasks:
  LostFilm:
    lostfilm: yes
    headers:
      cookie: '{? lostfilm.cookie_new ?}'
    template:
      - tvshows
      - notifycation
    include: lostfilm.yml

  NewStudio:
    template:
      - tvshows
      - notifycation
    rss: http://newstudio.tv/rss.php?user=xxx&pass=xxx
    manipulate:
      - series_name_rus:
          from: title
          extract: (.*)\s*\(Сезон\s*\d+[,\s*Серия\s*\d+]*[-\d+]*\)\s*\/\s*.+\s*\(\d+\)\s*.+
      - title:
          replace:
            regexp: .*\s*\(Сезон\s*(\d+),\s*Серия\s*(\d+)\)\s*\/\s*(.+)\s*(\(\d+\))\s*(.+)
            format: \3 \4 S\1E\2 \5
    include: newstudio.yml

  services:
    template:
      - clean