4o1x5.dev/content/post/guides/ host-your-own-spotify/index.hu.md
2005 d62f27346c changes
- rewrote about me
- tried to translate my latest post to my native language but failed
2024-07-18 02:17:53 +02:00

8.7 KiB

title description date image categories tags draft writingTime
Minek a spotify? Jellyfin a self-hosted spotify alternatíva. 2024-07-17 07:00:00+0000 feishin.png
Nix
Piracy
Jellyfin
Music
Homelab
Selfhost
true 1h 40m

Bevezető

Már 2024 elején lemondtam az utolsó előfizetésemet, a Spotify-t. Bár mértéktelen zenét hallgatok a nap 90 százalékában nem volt egyáltalán nehéz átálnom. A streamelés helyett inkább letöltöm a zenét (ami amúgy a 2000-es évekre emlékeztet de még meglepően népszerű) és a telefonom és gépem között szinkronizálom és úgy hallgatom. Vagy legalábbis így tettem 6-7 hónapig amiután visszaáltam a streamelésre de úgy ahogy gondolnád. Spotify, deezer és Tidal helyett Jellyfin-t használom és a saját szerveremről hallgatom az interneten keresztül.

Letölteni, micsoda?

Igen, meglepő nem? Hihetetlen sok ember van még aki lopja kölcsönzi a zenét. Van is erre egy egész peer-to-peer platform amit Soulseek-nek hívnak. Én is innen szerzem a zenéim többségét.

My main reason is privacy. I have yet to find a platform that respects my privacy and allows me to buy any kind of albums/songs with Bitcoin or Monero, therefore my last resort is to pirate. I could buy the original CD's but most artists I listen to don't have one, and I loath ripping.
Everyone has their own opinion about piracy, and I think in my case it's a 100% justified.

Jellyfin

Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. It is an alternative to the proprietary Emby and Plex, to provide media from a dedicated server to end-user devices via multiple apps.

Jellyfin is a really great mediaserver, It has many clients and supports almost any kind of media, ranging from visual to audible.
I have been using it for about two years now, but recently I just realized I could stream my music from there instead of syncing my music to all my devices. For the past few days It has been a pleasureful experience and I have no complaints.

Feishin desktop

Feishin is a rewrite of sonixd, a client for subsonic.
It's a really clean client for jellyfin, I found it in nixpkgs and I use it daily.
It almost all the features I need and a modern spotify-like UI. Sadly it's missing a download feature, meaning I cannot download music then listen to it on the road. Streaming flacs is really inefficient if you are using mobile data or some public wifi. I travel a lot meaning this is kind of a deal breaker, but I can just use my phone. Here is a video of how it looks like in it's fullscreen mode:

Finamp mobile

Finamp is an open-source jellyfin music client for Android.
It's one of the most feature rich clients out there, supporting many features also found in the mobile Spotify client.
I don't really like it's design as It doesn't really look like Spotify but that probably due to their focus not being on that. Regardless Its clean.

Song focus List of songs

Self-hosting

Define a domain for the nix server

networking.domain = "example.com";

Jellyfin

Nixpkgs has jellyfin options so we can deploy it that way. It's really straight-forward and seamless.
This example also includes a nginx configuration, since I'm assuming you want to access it from remote locations and maybe share it with friends.

{ pkgs, config, ... }: {

  services.jellyfin = {
    enable = true;
    # Setting the home directory
    # might need to create with mkdir /home/jellyfin
    dataDir = "/home/jellyfin";
  };
  services.nginx = {
    virtualHosts = {
      "jelly.${config.networking.domain}" = {
        forceSSL = true;
        enableACME = true;

        locations."/" = {
          extraConfig = ''
            proxy_pass http://localhost:8096;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Protocol $scheme;
            proxy_set_header X-Forwarded-Host $http_host;
          '';

        };
        # Enable socket for features like syncPlay and live view in the admin panel
        locations."/socket" = {
          extraConfig = ''
            proxy_pass http://localhost:8096;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Protocol $scheme;
            proxy_set_header X-Forwarded-Host $http_host;
          '';
        };
      };
    };
  };
}

After this you can head to jelly.yourdomain.com and run the setup.
Keep in mind this is a really basic setup, all data will be stored at /home/jellyfin including the SQLite database.

slskd

slskd is a fully featured modern client-server client for soulseek. You can log in to it's panel and download files from the network.
I had some problems with permissions when I was trying to use the native version from nixpkgs, so instead I just made an oci-container that uses linux namespaces to run applications.

Create directories

mkdir /home/jellyfin/Music
mkdir /home/jellyfin/Music/unsorted

** Create the service** Don't forget to change the credentials like your soulseek username and password. And also the slskd login username and password.

{ pkgs, config, ... }: {

  # Define the slskd container
  virtualisation.oci-containers.containers = {
    slskd = {
      image = "slskd/slskd";
      ports = [
        "5030:5030" # panel
        "50300:50300" # soulseek
      ];
      volumes = [
        # you can use picard or similar applications to sort them, that's why I link it to unsorted
        "/home/jellyfin/Music/unsorted:/downloads"
        "/home/jellyfin/Music:/music"
      ];

      environment = {
        SLSKD_SHARED_DIR = "/music";
        SLSKD_DOWNLOADS_DIR = "/downloads";
        # these will be used to login to slskd at `soulseek.example.com`
        SLSKD_USERNAME = "slskd username";
        SLSKD_PASSWORD = "slskd password";
        # This is your soulseek login, if you don't have an account don't worry, just type in anything here and it will create an account.
        SLSKD_SLSK_USERNAME = "soulseek login name";
        SLSKD_SLSK_PASSWORD = "soulseek login name";
        SLSKD_SLSK_LISTEN_IP_ADDRESS = "0.0.0.0";
      };
    };
  };
  # Open the ports for slskd so users can download from you
  networking.firewall = {
    enable = true;
    allowedTCPPorts = [
      50300
    ];
    allowedUDPPorts = [
      50300
    ];
  };


  services.nginx = {
    virtualHosts = {
      "soulseek.${config.networking.domain}" = {
        forceSSL = true;
        enableACME = true;
        locations."/" = {
          extraConfig = ''
            proxy_pass http://localhost:5030;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
            proxy_request_buffering off;
          '';
        };
      };
    };
  };
}

Don't forget to open up the ports on your router so that users can download from you!

Usage

Create a music library for jellyfin

Head to the defined jellyfin domain, and log in with the credentials you have given. On the top right click on the profile icon and head to Dashboard -> Libraries -> Add Media Library and add a new music library like in the picture.

Download music

Head to the soulseek domain you have defined, and log into slskd.
Slskd is really easy to use, upon entering you are greeted with the search bar, type in anything and hit enter. Slskd will search other peers on the network for the string and return files.

After hitting download slskd will put it in /home/jellyfin/Music/unsorted. Jellyfin will automatically scan you library every 3 hours bot you can override this by clicking Scan All Libraries in the Dashboard

Connect a client.

Download a client, I recommend the ones I mentioned and connect to your server.
For the server URL type in jelly.yourdomain.com.

Enjoy