{ pkgs, ... }:

{
  home.packages = with pkgs; [

  ];
  services.mopidy = {
    enable = true;
    # extensionPackages = [
    #   (pkgs.mopidy-tidal.overrideAttrs (old: rec {
    #     pname = "Mopidy-Tidal";
    #     version = "0.3.2";
    #     src = pkgs.python311Packages.fetchPypi {
    #       inherit pname version;
    #       sha256 = "7a4aa1ccac94d96a9339e451d5949903dc96dd45ec2c1b02d8193a159ad08267";
    #     };
    #     postPatch = ''
    #       substituteInPlace setup.py
    #     '';
    #   }))
    # ];
    settings = {
      audio = {
        output = "autoaudiosink";
        mixer = "software";
        mixer_volume = 100;
      };
      file = {
        media_dirs = [ "/mnt/share/Music/" ];
        metadata_timeout = 5000;
        follow_symlinks = true;
        show_dotfiles = false;
        excluded_file_extensions = [ ".html" ".zip" ".nfo" ".txt" ".jpg" ".jpeg" ".png" ".pdf" ".log" ];
      };
      http = {
        enabled = true;
        hostname = "launchpad.local";
        port = 6680;
        default_app = "mopidy";
      };
      stream = {
        enabled = true;
        protocols = [ "http" "https" "mms" "rtmp" "rtmps" "rtsp" ];
        timeout = 5000;
      };
      logging = {
        verbosity = 1;
        format = "%(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s";
        color = true;
      };
      # autoplay = {
      #   enabled = true;
      #   save_interval = 10;
      #   tracklist.uris = "auto";
      #   tracklist.index = "auto";
      #   tracklist.consume = "auto";
      #   tracklist.random = "auto";
      #   tracklist.repeat = "auto";
      #   tracklist.single = "auto";
      #   playback.state = "auto";
      #   playback.time_position = "auto";
      #   mixer.volume = 100;
      #   mixer.mute = false;
      # };
      tidal = {
        enabled = true;
        quality = "HI_RES_LOSSLESS";
        auth_method = "PKCE";
        lazy = true;
        login_method = "BLOCK"; # block auto hack
      };
      musicbox_webclient = {
        enabled = true;
        musicbox = true;
        websocket_host = "launchpad.local";
        websocket_port = 6680;
        on_track_click = "ADD_THIS_BOTTOM";
      };
    };
  };
}

# sudo python3 -m pip install Mopidy-Beets
# sudo python3 -m pip install Mopidy-Tidal
# sudo python3 -m pip install Mopidy-Iris
# sudo python3 -m pip install Mopidy-Autoplay