# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=ytdl-sub
pkgver=2025.04.03
pkgrel=0
pkgdesc="tool for downloading media with yt-dlp and creating metadata"
url="https://github.com/jmbannon/ytdl-sub"
arch="noarch"
license="GPL-3.0-only"
depends="
	ffmpeg
	py3-colorama
	py3-mediafile
	py3-mergedeep
	py3-yaml
	yt-dlp-core
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="py3-pytest py3-pytest-cov"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://codeload.github.com/jmbannon/ytdl-sub/tar.gz/refs/tags/$pkgver"
# tests connect out to the internet
options="!check"

prepare() {
	default_prepare

	# hardcoded incorrect version
	cat >>src/ytdl_sub/__init__.py <<-EOF
	__pypi_version__ = "$pkgver"
	__local_version__ = "$pkgver"
	EOF
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
b347799bd04e70426bf0caa28ef45912da1b5ca6fd78b33bf5721e464bb0edc5e04d90f4fc946d911bc8d26efb22c23acb5f52c7f058dc95ae9ed789a5f184e0  ytdl-sub-2025.04.03.tar.gz
"
