<!-- https://refryt.top/build.html -->

# Build from source

refryt is Rust and [egui](https://github.com/emilk/egui), with [mpv](https://mpv.io/) for playback. This is the short version; [docs/BUILDING.md](https://github.com/gridoe/refryt/blob/main/docs/BUILDING.md) has every detail.

## Prerequisites

- **Rust 1.90+** (see `rust-version` in `Cargo.toml`)
- **libmpv**, the [mpv](https://mpv.io/) development libraries. refryt plays audio through it.
- **[yt-dlp](https://github.com/yt-dlp/yt-dlp)**, optional: the fallback for songs YouTube's `player` endpoint won't hand over, plus the video view and downloads. Songs play without it.
- **[just](https://github.com/casey/just)**, optional: the `Justfile` has a command for everything below.

```
git clone https://github.com/gridoe/refryt
cd refryt
```

## Everyday development

```
just              # cargo run, dev profile
just search "some song"
just release      # optimised run, for judging real performance
just check        # fmt --check + clippy + tests, what CI runs
```

Without `just`: `cargo run -p refryt --bin refryt`.

## Packaging

### Linux: AppImage

```
just appimage          # or: ./scripts/build-appimage.sh
just appimage-install  # to ~/.local/bin with a desktop entry
```

Bundles the release binary, every shared library short of glibc (libmpv included), a fresh yt-dlp and the icon into `dist/refryt-<version>-x86_64.AppImage`. Needs `python3` with Pillow and `curl`; no root required.

### Linux: Flatpak

```
just flatpak           # or: ./scripts/build-flatpak.sh
flatpak install --user dist/refryt-<version>-x86_64.flatpak
```

Built from `packaging/flatpak/`. Needs `flatpak-builder`, the GNOME 49 Platform and Sdk, and the `rust-stable` Sdk extension. The first build compiles libmpv and friends, so it takes a while.

### macOS: app bundle

```
brew install rustup just mpv dylibbundler
just macos             # or: ./scripts/build-macos.sh
```

Writes `dist/Refryt.app`, plus a zip and a DMG, with libmpv and yt-dlp bundled and an ad-hoc signature. On another Mac, clear the quarantine flag with `xattr -cr Refryt.app`.

### Windows: cross-compiled from Linux

```
sudo pacman -S mingw-w64-gcc mingw-w64-crt mingw-w64-headers mingw-w64-winpthreads mingw-w64-binutils
rustup target add x86_64-pc-windows-gnu
./scripts/build-windows.sh
```

Produces a portable zip, and with Wine and [Inno Setup](https://jrsoftware.org/isinfo.php) installed, a real installer. `ARCH=aarch64` builds Windows on ARM using llvm-mingw. See [BUILDING.md](https://github.com/gridoe/refryt/blob/main/docs/BUILDING.md#windows-cross-compiled-from-linux) for the setup.

## Contributing

Bugs and ideas go to the [issue tracker](https://github.com/gridoe/refryt/issues). [CONTRIBUTING.md](https://github.com/gridoe/refryt/blob/main/CONTRIBUTING.md) says what to include. Releases are cut by pushing a `v*` tag; the process is in [BUILDING.md](https://github.com/gridoe/refryt/blob/main/docs/BUILDING.md#releasing).

## Credits

- **[Sonora](https://github.com/sonorahq/sonora)** and its [`ytmusic-rs`](https://github.com/sonorahq/ytmusic-rs): asking YouTube's `player` endpoint as the visionOS client for direct stream URLs.
- **[yt-dlp](https://github.com/yt-dlp/yt-dlp)**: the fallback resolver, and the reference for how YouTube gates anonymous clients.
- **[youtui](https://github.com/nick42d/youtui)**: `ytmapi-rs` for the InnerTube API, and its `rusty_ytdl` fork.
- **[ytmdesktop](https://github.com/ytmdesktop/ytmdesktop)**: what happens when the queue runs out.
- **Spotify's desktop app**: the shortcuts, select-then-play clicks, and the shape of the album, playlist and artist pages.
- **[LRCLIB](https://lrclib.net)**: the synced lyrics.
- **Theme palettes**: [Catppuccin](https://github.com/catppuccin/palette), [Nord](https://www.nordtheme.com/docs/colors-and-palettes), [Gruvbox](https://github.com/morhetz/gruvbox), [Tokyo Night](https://github.com/folke/tokyonight.nvim), [Dracula](https://spec.draculatheme.com), [Rosé Pine](https://github.com/rose-pine/palette), [Everforest](https://github.com/sainnhe/everforest), [Solarized](https://ethanschoonover.com/solarized) and Spotify's own colours.
