# Contributor: Hoang Nguyen <folliekazetani@protonmail.com>
# Contributor: Robert Sacks <robert@sacks.email>
maintainer="Hoang Nguyen <folliekazetani@protonmail.com>"
pkgname=streamlink
pkgver=7.0.0
pkgrel=0
pkgdesc="CLI for extracting streams from various websites to a video player of your choosing"
url="https://streamlink.github.io/"
arch="noarch"
license="BSD-2-Clause"
depends="
	python3
	py3-certifi
	py3-isodate
	py3-lxml
	py3-pycountry
	py3-pycryptodome
	py3-pysocks
	py3-requests
	py3-trio
	py3-trio-websocket
	py3-typing-extensions
	py3-urllib3
	py3-websocket-client
	"
makedepends="
	py3-setuptools
	py3-gpep517
	py3-installer
	py3-wheel
	"
checkdepends="
	py3-freezegun
	py3-mock
	py3-pytest
	py3-pytest-trio
	py3-requests-mock
	"
subpackages="
	$pkgname-pyc
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="https://github.com/streamlink/streamlink/releases/download/$pkgver/streamlink-$pkgver.tar.gz"

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
	TZ=UTC .testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
	install -Dm644 docs/_build/man/$pkgname.1 \
		"$pkgdir"/usr/share/man/man1/$pkgname.1

	install -Dm644 completions/bash/$pkgname \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 completions/zsh/_$pkgname \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
0d0834b19718862ac7efd16680920ec632b9c2db512c57e9eb4bc9bc6a27f7cbf0ceba557bbeb4c55a5e9680b5519961e526209ccc4b8499273daaf1cd837e4f  streamlink-7.0.0.tar.gz
"
