presets:

  ###############################
  # All-in-one presets that require no config

  "Kodi TV Show Collection":
    preset:
      - "kodi_tv_show_collection"
      - "season_by_collection__episode_by_year_month_day"

  "Jellyfin TV Show Collection":
    preset:
      - "jellyfin_tv_show_collection"
      - "season_by_collection__episode_by_year_month_day"

  "Plex TV Show Collection":
    preset:
      - "plex_tv_show_collection"
      - "season_by_collection__episode_by_year_month_day"

  "Emby TV Show Collection":
    preset: "Jellyfin TV Show Collection"

    # Emby cannot read seasons from tv_show.nfo
    # Create explicit season NFOs in each season dir
    static_nfo_tags:
      nfo_name: "{season_directory_name_sanitized}/season.nfo"
      nfo_root: "season"
      tags:
        title: "{collection_season_name}"


  ##################
  # Legacy names

  kodi_tv_show_collection:
    preset:
      - "_kodi_tv_show"
      - "_tv_show_collection"

  jellyfin_tv_show_collection:
    preset:
      - "_jellyfin_tv_show"
      - "_tv_show_collection"

  plex_tv_show_collection:
    preset:
      - "_plex_tv_show"
      - "_tv_show_collection"

  ###############################

  _tv_show_collection_episode_ordering:
    overrides:
      tv_show_collection_episode_ordering: >-
        { %throw("Must specify tv_show_collection_episode_ordering") }

      "%episode_ordering_": >-
        { %eq( %lower(tv_show_collection_episode_ordering), $0 ) }

      episode_number_and_padded_: >-
        {
          %elif(
            %episode_ordering_( "upload-year-month-day" ),           [ %concat(upload_year_truncated, upload_month_padded, upload_day_padded, upload_date_index_padded), 8 ],
            %episode_ordering_( "upload-year-month-day-reversed" ),  [ %concat(upload_year_truncated_reversed, upload_month_reversed_padded, upload_day_reversed_padded, upload_date_index_reversed_padded), 8],
            %episode_ordering_( "release-year-month-day" ),          [ %concat(release_year_truncated, release_month_padded, release_day_padded, upload_date_index_padded), 8 ],
            %episode_ordering_( "release-year-month-day-reversed" ), [ %concat(release_year_truncated_reversed, release_month_reversed_padded, release_day_reversed_padded, upload_date_index_reversed_padded), 8],
            %episode_ordering_( "playlist-index" ),                  [ %concat(playlist_index), 6],
            %episode_ordering_( "playlist-index-reversed" ),         [ %concat(playlist_index_reversed), 6],
            %throw(
              'tv_show_collection_episode_ordering must be one of the following: "upload-year-month-day", "upload-year-month-day-reversed", "release-year-month-day", "release-year-month-day-reversed", "playlist-index", "playlist-index-reversed"'
            )
          )
        }

      episode_number: "{ %array_at(episode_number_and_padded_, 0) }"
      episode_number_padded: "{ %pad_zero( %int(episode_number), %int(%array_at(episode_number_and_padded_, 1))) }"
      episode_date_standardized: >-
        {
          %if(
            %contains(tv_show_collection_episode_ordering, "release"),
            release_date_standardized,
            upload_date_standardized
          )
        }

      tv_show_date_range_type: >-
        {
          %if(
            %contains(tv_show_collection_episode_ordering, "release"),
            "release_date",
            "upload_date"
          )
        }
        

  ### LEGACY PRESETS

  season_by_collection__episode_by_year_month_day:
    preset: "_tv_show_collection_episode_ordering"
    overrides:
      tv_show_collection_episode_ordering: "upload-year-month-day"

  season_by_collection__episode_by_year_month_day_reversed:
    preset: "_tv_show_collection_episode_ordering"
    overrides:
      tv_show_collection_episode_ordering: "upload-year-month-day-reversed"

  season_by_collection__episode_by_playlist_index:
    preset: "_tv_show_collection_episode_ordering"
    overrides:
      tv_show_collection_episode_ordering: "playlist-index"

  season_by_collection__episode_by_playlist_index_reversed:
    preset: "_tv_show_collection_episode_ordering"
    overrides:
      tv_show_collection_episode_ordering: "playlist-index-reversed"

  ##############

  _tv_show_collection:
    preset:
      - "_tv_show_collection_bilateral"
      - "_tv_show_collection_asserts"

    download:
      - url: "{ %array_at( %get_season_urls(collection_season_1_url), 0) }"
        variables:
          collection_season_number: "1"
          collection_season_name: "{collection_season_1_name}"
        playlist_thumbnails:
          # Use latest_entry first, then see if YT channel artwork exists
          # ONLY FOR SEASON 1! The channel artwork will be the show's artwork.
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
          - name: "{tv_show_poster_file_name}"
            uid: "avatar_uncropped"
          - name: "{tv_show_fanart_file_name}"
            uid: "banner_uncropped"
        source_thumbnails:
          - name: "{tv_show_poster_file_name}"
            uid: "avatar_uncropped"
          - name: "{tv_show_fanart_file_name}"
            uid: "banner_uncropped"
      - url: "{ %array_slice( %get_season_urls(collection_season_1_url), 1) }"
        variables:
          collection_season_number: "1"
          collection_season_name: "{collection_season_1_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_2_url), 0) }"
        variables:
          collection_season_number: "2"
          collection_season_name: "{collection_season_2_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_2_url), 1) }"
        variables:
          collection_season_number: "2"
          collection_season_name: "{collection_season_2_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_3_url), 0) }"
        variables:
          collection_season_number: "3"
          collection_season_name: "{collection_season_3_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_3_url), 1) }"
        variables:
          collection_season_number: "3"
          collection_season_name: "{collection_season_3_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_4_url), 0) }"
        variables:
          collection_season_number: "4"
          collection_season_name: "{collection_season_4_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_4_url), 1) }"
        variables:
          collection_season_number: "4"
          collection_season_name: "{collection_season_4_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_5_url), 0) }"
        variables:
          collection_season_number: "5"
          collection_season_name: "{collection_season_5_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_5_url), 1) }"
        variables:
          collection_season_number: "5"
          collection_season_name: "{collection_season_5_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_6_url), 0) }"
        variables:
          collection_season_number: "6"
          collection_season_name: "{collection_season_6_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_6_url), 1) }"
        variables:
          collection_season_number: "6"
          collection_season_name: "{collection_season_6_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_7_url), 0) }"
        variables:
          collection_season_number: "7"
          collection_season_name: "{collection_season_7_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_7_url), 1) }"
        variables:
          collection_season_number: "7"
          collection_season_name: "{collection_season_7_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_8_url), 0) }"
        variables:
          collection_season_number: "8"
          collection_season_name: "{collection_season_8_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_8_url), 1) }"
        variables:
          collection_season_number: "8"
          collection_season_name: "{collection_season_8_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_9_url), 0) }"
        variables:
          collection_season_number: "9"
          collection_season_name: "{collection_season_9_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_9_url), 1) }"
        variables:
          collection_season_number: "9"
          collection_season_name: "{collection_season_9_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_10_url), 0) }"
        variables:
          collection_season_number: "10"
          collection_season_name: "{collection_season_10_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_10_url), 1) }"
        variables:
          collection_season_number: "10"
          collection_season_name: "{collection_season_10_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_11_url), 0) }"
        variables:
          collection_season_number: "11"
          collection_season_name: "{collection_season_11_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_11_url), 1) }"
        variables:
          collection_season_number: "11"
          collection_season_name: "{collection_season_11_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_12_url), 0) }"
        variables:
          collection_season_number: "12"
          collection_season_name: "{collection_season_12_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_12_url), 1) }"
        variables:
          collection_season_number: "12"
          collection_season_name: "{collection_season_12_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_13_url), 0) }"
        variables:
          collection_season_number: "13"
          collection_season_name: "{collection_season_13_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_13_url), 1) }"
        variables:
          collection_season_number: "13"
          collection_season_name: "{collection_season_13_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_14_url), 0) }"
        variables:
          collection_season_number: "14"
          collection_season_name: "{collection_season_14_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_14_url), 1) }"
        variables:
          collection_season_number: "14"
          collection_season_name: "{collection_season_14_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_15_url), 0) }"
        variables:
          collection_season_number: "15"
          collection_season_name: "{collection_season_15_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_15_url), 1) }"
        variables:
          collection_season_number: "15"
          collection_season_name: "{collection_season_15_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_16_url), 0) }"
        variables:
          collection_season_number: "16"
          collection_season_name: "{collection_season_16_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_16_url), 1) }"
        variables:
          collection_season_number: "16"
          collection_season_name: "{collection_season_16_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_17_url), 0) }"
        variables:
          collection_season_number: "17"
          collection_season_name: "{collection_season_17_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_17_url), 1) }"
        variables:
          collection_season_number: "17"
          collection_season_name: "{collection_season_17_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_18_url), 0) }"
        variables:
          collection_season_number: "18"
          collection_season_name: "{collection_season_18_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_18_url), 1) }"
        variables:
          collection_season_number: "18"
          collection_season_name: "{collection_season_18_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_19_url), 0) }"
        variables:
          collection_season_number: "19"
          collection_season_name: "{collection_season_19_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_19_url), 1) }"
        variables:
          collection_season_number: "19"
          collection_season_name: "{collection_season_19_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_20_url), 0) }"
        variables:
          collection_season_number: "20"
          collection_season_name: "{collection_season_20_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_20_url), 1) }"
        variables:
          collection_season_number: "20"
          collection_season_name: "{collection_season_20_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_21_url), 0) }"
        variables:
          collection_season_number: "21"
          collection_season_name: "{collection_season_21_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_21_url), 1) }"
        variables:
          collection_season_number: "21"
          collection_season_name: "{collection_season_21_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_22_url), 0) }"
        variables:
          collection_season_number: "22"
          collection_season_name: "{collection_season_22_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_22_url), 1) }"
        variables:
          collection_season_number: "22"
          collection_season_name: "{collection_season_22_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_23_url), 0) }"
        variables:
          collection_season_number: "23"
          collection_season_name: "{collection_season_23_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_23_url), 1) }"
        variables:
          collection_season_number: "23"
          collection_season_name: "{collection_season_23_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_24_url), 0) }"
        variables:
          collection_season_number: "24"
          collection_season_name: "{collection_season_24_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_24_url), 1) }"
        variables:
          collection_season_number: "24"
          collection_season_name: "{collection_season_24_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_25_url), 0) }"
        variables:
          collection_season_number: "25"
          collection_season_name: "{collection_season_25_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_25_url), 1) }"
        variables:
          collection_season_number: "25"
          collection_season_name: "{collection_season_25_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_26_url), 0) }"
        variables:
          collection_season_number: "26"
          collection_season_name: "{collection_season_26_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_26_url), 1) }"
        variables:
          collection_season_number: "26"
          collection_season_name: "{collection_season_26_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_27_url), 0) }"
        variables:
          collection_season_number: "27"
          collection_season_name: "{collection_season_27_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_27_url), 1) }"
        variables:
          collection_season_number: "27"
          collection_season_name: "{collection_season_27_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_28_url), 0) }"
        variables:
          collection_season_number: "28"
          collection_season_name: "{collection_season_28_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_28_url), 1) }"
        variables:
          collection_season_number: "28"
          collection_season_name: "{collection_season_28_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_29_url), 0) }"
        variables:
          collection_season_number: "29"
          collection_season_name: "{collection_season_29_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_29_url), 1) }"
        variables:
          collection_season_number: "29"
          collection_season_name: "{collection_season_29_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_30_url), 0) }"
        variables:
          collection_season_number: "30"
          collection_season_name: "{collection_season_30_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_30_url), 1) }"
        variables:
          collection_season_number: "30"
          collection_season_name: "{collection_season_30_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_31_url), 0) }"
        variables:
          collection_season_number: "31"
          collection_season_name: "{collection_season_31_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_31_url), 1) }"
        variables:
          collection_season_number: "31"
          collection_season_name: "{collection_season_31_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_32_url), 0) }"
        variables:
          collection_season_number: "32"
          collection_season_name: "{collection_season_32_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_32_url), 1) }"
        variables:
          collection_season_number: "32"
          collection_season_name: "{collection_season_32_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_33_url), 0) }"
        variables:
          collection_season_number: "33"
          collection_season_name: "{collection_season_33_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_33_url), 1) }"
        variables:
          collection_season_number: "33"
          collection_season_name: "{collection_season_33_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_34_url), 0) }"
        variables:
          collection_season_number: "34"
          collection_season_name: "{collection_season_34_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_34_url), 1) }"
        variables:
          collection_season_number: "34"
          collection_season_name: "{collection_season_34_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_35_url), 0) }"
        variables:
          collection_season_number: "35"
          collection_season_name: "{collection_season_35_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_35_url), 1) }"
        variables:
          collection_season_number: "35"
          collection_season_name: "{collection_season_35_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_36_url), 0) }"
        variables:
          collection_season_number: "36"
          collection_season_name: "{collection_season_36_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_36_url), 1) }"
        variables:
          collection_season_number: "36"
          collection_season_name: "{collection_season_36_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_37_url), 0) }"
        variables:
          collection_season_number: "37"
          collection_season_name: "{collection_season_37_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_37_url), 1) }"
        variables:
          collection_season_number: "37"
          collection_season_name: "{collection_season_37_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_38_url), 0) }"
        variables:
          collection_season_number: "38"
          collection_season_name: "{collection_season_38_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_38_url), 1) }"
        variables:
          collection_season_number: "38"
          collection_season_name: "{collection_season_38_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_39_url), 0) }"
        variables:
          collection_season_number: "39"
          collection_season_name: "{collection_season_39_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_39_url), 1) }"
        variables:
          collection_season_number: "39"
          collection_season_name: "{collection_season_39_name}"

      - url: "{ %array_at( %get_season_urls(collection_season_40_url), 0) }"
        variables:
          collection_season_number: "40"
          collection_season_name: "{collection_season_40_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_40_url), 1) }"
        variables:
          collection_season_number: "40"
          collection_season_name: "{collection_season_40_name}"


      # Place season 0 at end
      - url: "{ %array_at( %get_season_urls(collection_season_0_url), 0) }"
        variables:
          collection_season_number: "0"
          collection_season_name: "{collection_season_0_name}"
        playlist_thumbnails:
          - name: "{season_poster_file_name}"
            uid: "latest_entry"
      - url: "{ %array_slice( %get_season_urls(collection_season_0_url), 1) }"
        variables:
          collection_season_number: "0"
          collection_season_name: "{collection_season_0_name}"


    output_directory_nfo_tags:
      tags:
        namedseason:
          - tag: "{collection_season_1_name}"
            attributes:
              number: "1"
          - tag: "{collection_season_2_name}"
            attributes:
              number: "2"
          - tag: "{collection_season_3_name}"
            attributes:
              number: "3"
          - tag: "{collection_season_4_name}"
            attributes:
              number: "4"
          - tag: "{collection_season_5_name}"
            attributes:
              number: "5"
          - tag: "{collection_season_6_name}"
            attributes:
              number: "6"
          - tag: "{collection_season_7_name}"
            attributes:
              number: "7"
          - tag: "{collection_season_8_name}"
            attributes:
              number: "8"
          - tag: "{collection_season_9_name}"
            attributes:
              number: "9"
          - tag: "{collection_season_10_name}"
            attributes:
              number: "10"
          - tag: "{collection_season_11_name}"
            attributes:
              number: "11"
          - tag: "{collection_season_12_name}"
            attributes:
              number: "12"
          - tag: "{collection_season_13_name}"
            attributes:
              number: "13"
          - tag: "{collection_season_14_name}"
            attributes:
              number: "14"
          - tag: "{collection_season_15_name}"
            attributes:
              number: "15"
          - tag: "{collection_season_16_name}"
            attributes:
              number: "16"
          - tag: "{collection_season_17_name}"
            attributes:
              number: "17"
          - tag: "{collection_season_18_name}"
            attributes:
              number: "18"
          - tag: "{collection_season_19_name}"
            attributes:
              number: "19"
          - tag: "{collection_season_20_name}"
            attributes:
              number: "20"
          - tag: "{collection_season_21_name}"
            attributes:
              number: "21"
          - tag: "{collection_season_22_name}"
            attributes:
              number: "22"
          - tag: "{collection_season_23_name}"
            attributes:
              number: "23"
          - tag: "{collection_season_24_name}"
            attributes:
              number: "24"
          - tag: "{collection_season_25_name}"
            attributes:
              number: "25"
          - tag: "{collection_season_26_name}"
            attributes:
              number: "26"
          - tag: "{collection_season_27_name}"
            attributes:
              number: "27"
          - tag: "{collection_season_28_name}"
            attributes:
              number: "28"
          - tag: "{collection_season_29_name}"
            attributes:
              number: "29"
          - tag: "{collection_season_30_name}"
            attributes:
              number: "30"
          - tag: "{collection_season_31_name}"
            attributes:
              number: "31"
          - tag: "{collection_season_32_name}"
            attributes:
              number: "32"
          - tag: "{collection_season_33_name}"
            attributes:
              number: "33"
          - tag: "{collection_season_34_name}"
            attributes:
              number: "34"
          - tag: "{collection_season_35_name}"
            attributes:
              number: "35"
          - tag: "{collection_season_36_name}"
            attributes:
              number: "36"
          - tag: "{collection_season_37_name}"
            attributes:
              number: "37"
          - tag: "{collection_season_38_name}"
            attributes:
              number: "38"
          - tag: "{collection_season_39_name}"
            attributes:
              number: "39"
          - tag: "{collection_season_40_name}"
            attributes:
              number: "40"

    overrides:
      collection_season_number_padded: "{ %pad_zero(%int(collection_season_number), 2) }"
      season_number: "{collection_season_number}"
      season_number_padded: "{collection_season_number_padded}"

      # Legacy name variable
      collection_season_1_name: "{s01_name}"
      collection_season_2_name: "{s02_name}"
      collection_season_3_name: "{s03_name}"
      collection_season_4_name: "{s04_name}"
      collection_season_5_name: "{s05_name}"
      collection_season_6_name: "{s06_name}"
      collection_season_7_name: "{s07_name}"
      collection_season_8_name: "{s08_name}"
      collection_season_9_name: "{s09_name}"
      collection_season_10_name: "{s10_name}"
      collection_season_11_name: "{s11_name}"
      collection_season_12_name: "{s12_name}"
      collection_season_13_name: "{s13_name}"
      collection_season_14_name: "{s14_name}"
      collection_season_15_name: "{s15_name}"
      collection_season_16_name: "{s16_name}"
      collection_season_17_name: "{s17_name}"
      collection_season_18_name: "{s18_name}"
      collection_season_19_name: "{s19_name}"
      collection_season_20_name: "{s20_name}"
      collection_season_21_name: "{s21_name}"
      collection_season_22_name: "{s22_name}"
      collection_season_23_name: "{s23_name}"
      collection_season_24_name: "{s24_name}"
      collection_season_25_name: "{s25_name}"
      collection_season_26_name: "{s26_name}"
      collection_season_27_name: "{s27_name}"
      collection_season_28_name: "{s28_name}"
      collection_season_29_name: "{s29_name}"
      collection_season_30_name: "{s30_name}"
      collection_season_31_name: "{s31_name}"
      collection_season_32_name: "{s32_name}"
      collection_season_33_name: "{s33_name}"
      collection_season_34_name: "{s34_name}"
      collection_season_35_name: "{s35_name}"
      collection_season_36_name: "{s36_name}"
      collection_season_37_name: "{s37_name}"
      collection_season_38_name: "{s38_name}"
      collection_season_39_name: "{s39_name}"
      collection_season_40_name: "{s40_name}"
      collection_season_0_name: "{s00_name}"

      # Legacy url variable
      collection_season_1_url: "{s01_url}"
      collection_season_2_url: "{s02_url}"
      collection_season_3_url: "{s03_url}"
      collection_season_4_url: "{s04_url}"
      collection_season_5_url: "{s05_url}"
      collection_season_6_url: "{s06_url}"
      collection_season_7_url: "{s07_url}"
      collection_season_8_url: "{s08_url}"
      collection_season_9_url: "{s09_url}"
      collection_season_10_url: "{s10_url}"
      collection_season_11_url: "{s11_url}"
      collection_season_12_url: "{s12_url}"
      collection_season_13_url: "{s13_url}"
      collection_season_14_url: "{s14_url}"
      collection_season_15_url: "{s15_url}"
      collection_season_16_url: "{s16_url}"
      collection_season_17_url: "{s17_url}"
      collection_season_18_url: "{s18_url}"
      collection_season_19_url: "{s19_url}"
      collection_season_20_url: "{s20_url}"
      collection_season_21_url: "{s21_url}"
      collection_season_22_url: "{s22_url}"
      collection_season_23_url: "{s23_url}"
      collection_season_24_url: "{s24_url}"
      collection_season_25_url: "{s25_url}"
      collection_season_26_url: "{s26_url}"
      collection_season_27_url: "{s27_url}"
      collection_season_28_url: "{s28_url}"
      collection_season_29_url: "{s29_url}"
      collection_season_30_url: "{s30_url}"
      collection_season_31_url: "{s31_url}"
      collection_season_32_url: "{s32_url}"
      collection_season_33_url: "{s33_url}"
      collection_season_34_url: "{s34_url}"
      collection_season_35_url: "{s35_url}"
      collection_season_36_url: "{s36_url}"
      collection_season_37_url: "{s37_url}"
      collection_season_38_url: "{s38_url}"
      collection_season_39_url: "{s39_url}"
      collection_season_40_url: "{s40_url}"
      collection_season_0_url: "{s00_url}"

      s01_name: ""
      s02_name: ""
      s03_name: ""
      s04_name: ""
      s05_name: ""
      s06_name: ""
      s07_name: ""
      s08_name: ""
      s09_name: ""
      s10_name: ""
      s11_name: ""
      s12_name: ""
      s13_name: ""
      s14_name: ""
      s15_name: ""
      s16_name: ""
      s17_name: ""
      s18_name: ""
      s19_name: ""
      s20_name: ""
      s21_name: ""
      s22_name: ""
      s23_name: ""
      s24_name: ""
      s25_name: ""
      s26_name: ""
      s27_name: ""
      s28_name: ""
      s29_name: ""
      s30_name: ""
      s31_name: ""
      s32_name: ""
      s33_name: ""
      s34_name: ""
      s35_name: ""
      s36_name: ""
      s37_name: ""
      s38_name: ""
      s39_name: ""
      s40_name: ""
      s00_name: ""

      s01_url: ""
      s02_url: ""
      s03_url: ""
      s04_url: ""
      s05_url: ""
      s06_url: ""
      s07_url: ""
      s08_url: ""
      s09_url: ""
      s10_url: ""
      s11_url: ""
      s12_url: ""
      s13_url: ""
      s14_url: ""
      s15_url: ""
      s16_url: ""
      s17_url: ""
      s18_url: ""
      s19_url: ""
      s20_url: ""
      s21_url: ""
      s22_url: ""
      s23_url: ""
      s24_url: ""
      s25_url: ""
      s26_url: ""
      s27_url: ""
      s28_url: ""
      s29_url: ""
      s30_url: ""
      s31_url: ""
      s32_url: ""
      s33_url: ""
      s34_url: ""
      s35_url: ""
      s36_url: ""
      s37_url: ""
      s38_url: ""
      s39_url: ""
      s40_url: ""
      s00_url: ""

      "%get_season_urls": >-
        { %if( %is_array( $0 ), $0, [ $0 ] ) }

      # $0 - season url variable
      # $1 - get the i'th url from the array
      "%get_season_url": >-
        { %array_at( %get_season_urls($0), $1, "" ) }

  _tv_show_collection_bilateral:
    preset:
      - "_url_bilateral_overrides"

    download:
      - url: "{ %array_apply( %get_season_urls(collection_season_1_url), %bilateral_url) }"
        variables:
          collection_season_number: "1"
          collection_season_name: "{collection_season_1_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_2_url), %bilateral_url) }"
        variables:
          collection_season_number: "2"
          collection_season_name: "{collection_season_2_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_3_url), %bilateral_url) }"
        variables:
          collection_season_number: "3"
          collection_season_name: "{collection_season_3_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_4_url), %bilateral_url) }"
        variables:
          collection_season_number: "4"
          collection_season_name: "{collection_season_4_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_5_url), %bilateral_url) }"
        variables:
          collection_season_number: "5"
          collection_season_name: "{collection_season_5_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_6_url), %bilateral_url) }"
        variables:
          collection_season_number: "6"
          collection_season_name: "{collection_season_6_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_7_url), %bilateral_url) }"
        variables:
          collection_season_number: "7"
          collection_season_name: "{collection_season_7_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_8_url), %bilateral_url) }"
        variables:
          collection_season_number: "8"
          collection_season_name: "{collection_season_8_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_9_url), %bilateral_url) }"
        variables:
          collection_season_number: "9"
          collection_season_name: "{collection_season_9_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_10_url), %bilateral_url) }"
        variables:
          collection_season_number: "10"
          collection_season_name: "{collection_season_10_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_11_url), %bilateral_url) }"
        variables:
          collection_season_number: "11"
          collection_season_name: "{collection_season_11_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_12_url), %bilateral_url) }"
        variables:
          collection_season_number: "12"
          collection_season_name: "{collection_season_12_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_13_url), %bilateral_url) }"
        variables:
          collection_season_number: "13"
          collection_season_name: "{collection_season_13_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_14_url), %bilateral_url) }"
        variables:
          collection_season_number: "14"
          collection_season_name: "{collection_season_14_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_15_url), %bilateral_url) }"
        variables:
          collection_season_number: "15"
          collection_season_name: "{collection_season_15_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_16_url), %bilateral_url) }"
        variables:
          collection_season_number: "16"
          collection_season_name: "{collection_season_16_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_17_url), %bilateral_url) }"
        variables:
          collection_season_number: "17"
          collection_season_name: "{collection_season_17_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_18_url), %bilateral_url) }"
        variables:
          collection_season_number: "18"
          collection_season_name: "{collection_season_18_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_19_url), %bilateral_url) }"
        variables:
          collection_season_number: "19"
          collection_season_name: "{collection_season_19_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_20_url), %bilateral_url) }"
        variables:
          collection_season_number: "20"
          collection_season_name: "{collection_season_20_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_21_url), %bilateral_url) }"
        variables:
          collection_season_number: "21"
          collection_season_name: "{collection_season_21_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_22_url), %bilateral_url) }"
        variables:
          collection_season_number: "22"
          collection_season_name: "{collection_season_22_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_23_url), %bilateral_url) }"
        variables:
          collection_season_number: "23"
          collection_season_name: "{collection_season_23_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_24_url), %bilateral_url) }"
        variables:
          collection_season_number: "24"
          collection_season_name: "{collection_season_24_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_25_url), %bilateral_url) }"
        variables:
          collection_season_number: "25"
          collection_season_name: "{collection_season_25_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_26_url), %bilateral_url) }"
        variables:
          collection_season_number: "26"
          collection_season_name: "{collection_season_26_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_27_url), %bilateral_url) }"
        variables:
          collection_season_number: "27"
          collection_season_name: "{collection_season_27_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_28_url), %bilateral_url) }"
        variables:
          collection_season_number: "28"
          collection_season_name: "{collection_season_28_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_29_url), %bilateral_url) }"
        variables:
          collection_season_number: "29"
          collection_season_name: "{collection_season_29_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_30_url), %bilateral_url) }"
        variables:
          collection_season_number: "30"
          collection_season_name: "{collection_season_30_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_31_url), %bilateral_url) }"
        variables:
          collection_season_number: "31"
          collection_season_name: "{collection_season_31_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_32_url), %bilateral_url) }"
        variables:
          collection_season_number: "32"
          collection_season_name: "{collection_season_32_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_33_url), %bilateral_url) }"
        variables:
          collection_season_number: "33"
          collection_season_name: "{collection_season_33_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_34_url), %bilateral_url) }"
        variables:
          collection_season_number: "34"
          collection_season_name: "{collection_season_34_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_35_url), %bilateral_url) }"
        variables:
          collection_season_number: "35"
          collection_season_name: "{collection_season_35_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_36_url), %bilateral_url) }"
        variables:
          collection_season_number: "36"
          collection_season_name: "{collection_season_36_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_37_url), %bilateral_url) }"
        variables:
          collection_season_number: "37"
          collection_season_name: "{collection_season_37_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_38_url), %bilateral_url) }"
        variables:
          collection_season_number: "38"
          collection_season_name: "{collection_season_38_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_39_url), %bilateral_url) }"
        variables:
          collection_season_number: "39"
          collection_season_name: "{collection_season_39_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      - url: "{ %array_apply( %get_season_urls(collection_season_40_url), %bilateral_url) }"
        variables:
          collection_season_number: "40"
          collection_season_name: "{collection_season_40_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

      # Season 0 at end (to download first)
      - url: "{ %array_apply( %get_season_urls(collection_season_0_url), %bilateral_url) }"
        variables:
          collection_season_number: "0"
          collection_season_name: "{collection_season_0_name}"
        download_reverse: False
        ytdl_options:
          playlist_items: "-1:0:-1"

  _tv_show_collection_asserts:
    overrides:
      url: ""
      assert_not_by_date: >-
        {
          %assert(
            %not( %bool(url) ),
            "Provided `url` to TV Show Collection preset when it expects `s01_url`. Perhaps you meant to use the `TV Show by Date` preset?"
          )
        }

####################################################################################################
# DEPRECATED SEASON PRESETS

  collection_season_1: {}
  collection_season_2: {}
  collection_season_3: {}
  collection_season_4: {}
  collection_season_5: {}
  collection_season_6: {}
  collection_season_7: {}
  collection_season_8: {}
  collection_season_9: {}
  collection_season_10: {}
  collection_season_11: {}
  collection_season_12: {}
  collection_season_13: {}
  collection_season_14: {}
  collection_season_15: {}
  collection_season_16: {}
  collection_season_17: {}
  collection_season_18: {}
  collection_season_19: {}
  collection_season_20: {}
  collection_season_21: {}
  collection_season_22: {}
  collection_season_23: {}
  collection_season_24: {}
  collection_season_25: {}
  collection_season_26: {}
  collection_season_27: {}
  collection_season_28: {}
  collection_season_29: {}
  collection_season_30: {}
  collection_season_31: {}
  collection_season_32: {}
  collection_season_33: {}
  collection_season_34: {}
  collection_season_35: {}
  collection_season_36: {}
  collection_season_37: {}
  collection_season_38: {}
  collection_season_39: {}
  collection_season_40: {}
