# This example shows how to download and format a Soundcloud artist's
# discography with tags and album art. We will configure this to make
# the output directory formatted as:
#
#   /path/to/music
#       /The Be Sharps
#           /[2020] My first upload
#               01 - My first upload.mp3
#               folder.jpg
#           /[2021] My first album
#               01 - Track one.mp3
#               02 - Track two.mp3
#               folder.jpg
#       /Another artist
#           ...
#
configuration:
  working_directory: '.ytdl-sub-downloads'

presets:
  soundcloud_discography:
    # Download using the multi_url strategy
    download:
      download_strategy: "multi_url"
      urls:
        # The first URL will be all the artist's tracks.
        # Treat these as singles - an album with a single track
        - url: "{artist_url}/tracks"
          variables:
            track_number: "1"
            track_number_padded: "01"
            track_count: "1"
            album: "{title}"
            album_sanitized: "{title_sanitized}"
            album_year: "{upload_year}"
        # Set the second URL to the artist's albums. If a track belongs both
        # to an album and tracks (in the URL above), it will resolve to this
        # URL and include the album metadata we set below.
        - url: "{artist_url}/albums"
          variables:
            track_number: "{playlist_index}"
            track_number_padded: "{playlist_index_padded}"
            track_count: "{playlist_count}"
            album: "{playlist_title}"
            album_sanitized: "{playlist_title_sanitized}"
            album_year: "{playlist_max_upload_year}"

    # For advanced YTDL users only; set any YTDL parameter here.
    # Let us set the format to download the best mp3.
    ytdl_options:
      format: 'bestaudio[ext=mp3]'

    # For each song downloaded, set the file and thumbnail name here.
    # The output directory stores all artists in a shared {music_directory}.
    # We store the audio file in its respective {album_directory_name} folder
    # with the track number and title. The (thumbnail) album art is stored
    # in the album folder.
    #
    # Set maintain_download_archive=True. This will tell YTDL not to
    # re-download them on a successive invocation.
    output_options:
      output_directory: "{music_directory}"
      file_name: "{album_path}/{track_file_name}.{ext}"
      thumbnail_name: "{album_path}/folder.{thumbnail_ext}"
      maintain_download_archive: True

    # For each song downloaded, populate the audio file with music tags.
    # Tagging should work with most audio file formats. See
    # https://ytdl-sub.readthedocs.io/en/latest/config.html#music-tags
    # for more details.
    music_tags:
      tags:
        artist: "{artist}"
        albumartist: "{artist}"
        title: "{title}"
        album: "{album}"
        track: "{track_number}"
        year: "{album_year}"
        genre: "Unset"

    # Overrides is a section where we can define our own variables, and use them in
    # any other section. We define our music directory and album directory names here,
    # which gets reused above for the audio file name and album art path.
    overrides:
      album_directory_name: "[{album_year}] {album_sanitized}"
      track_file_name: "{track_number_padded} - {title_sanitized}"
      album_path: "{artist_sanitized}/{album_directory_name}"
      music_directory: "/path/to/music"