# Copyright 2022-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Autogenerated by pycargoebuild 0.13.5

EAPI=8

CRATES="
"

inherit cargo

DESCRIPTION="Terminal Music and Podcast Player written in Rust"
HOMEPAGE="https://github.com/tramhao/termusic"
SRC_URI="
	https://github.com/tramhao/termusic/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
"
SRC_URI+="
	https://github.com/liuyujielol/gentoo-go-deps/releases/download/${P}/${P}-crates.tar.xz
"

LICENSE="MIT"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD GPL-3+ ISC
	LGPL-2.1 LGPL-3+ MIT MPL-2.0 Unicode-DFS-2016 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

IUSE="+symphonia gst mpv +yt-dlp"
REQUIRED_USE="^^ ( symphonia gst mpv )"

DEPEND="
	symphonia? (
		media-libs/alsa-lib
	)

	gst? (
		dev-libs/glib:2
		media-libs/gstreamer:1.0
		media-libs/gst-plugins-base:1.0
		media-libs/gst-plugins-bad:1.0
		media-libs/gst-plugins-good
		media-libs/gst-plugins-ugly
		media-plugins/gst-plugins-libav
	)
	mpv? (
		media-video/mpv[libmpv]
	)
	media-libs/libsixel
	dev-libs/protobuf
	sys-apps/dbus
"
RDEPEND="
	${DEPEND}
	yt-dlp? (
		media-video/ffmpeg
		net-misc/yt-dlp
	)
"

src_configure() {
	# default backend is *symphonia*
	# feature gates : *gst* *mpv*
	if use symphonia; then
		local myfeatures=(
			cover
		)
		cargo_src_configure
	else
		local myfeatures=(
			cover
			$(usev gst)
			$(usev mpv)
		)
		cargo_src_configure --no-default-features
	fi
}

src_install() {
	dobin "$(cargo_target_dir)/termusic"
	dobin "$(cargo_target_dir)/termusic-server"

	local DOCS=(
		CHANGELOG.md README.md
	)
	einstalldocs
}

pkg_postinst() {
	if [[ -z ${REPLACING_VERSIONS} ]]; then
		einfo "Configuration files for ${CATEGORY}/${PN} will be"
		einfo "written to \$HOME/.config/${PN} at first launch."
	fi

	einfo "For x11-terms/kitty, album cover support is built in"
	einfo "Using media-gfx/ueberzugpp or media-gfx/ueberzug for other terminals"
}
