# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=py3-pytube
#_pkgreal is used by apkbuild-pypi to find modules at PyPI
_pkgreal=pytube
pkgver=15.0.0
pkgrel=2
pkgdesc="Python 3 library for downloading YouTube Videos."
url="https://pypi.python.org/project/pytube"
arch="noarch"
license="Unlicense"
checkdepends="py3-pytest"
makedepends="py3-setuptools py3-gpep517 py3-wheel"
source="$pkgname-$pkgver.tar.gz::https://github.com/pytube/pytube/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgreal-$pkgver"
subpackages="$pkgname-pyc"

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 "$builddir"/.dist/*.whl
	# all failure due to: generator raised StopIteration
	.testenv/bin/python3 -m pytest -v \
		--ignore tests/test_streams.py \
		--ignore tests/test_query.py \
		-k 'not test_streaming and not test_info_url_age_restricted and not test_js_url and not test_non_age_restricted and not test_not_is_private and not test_recording_available and not test_publish_date and not test_video_keywords and not test_js_caching and not test_channel_id and not test_channel_url'
}

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

sha512sums="
fc28d87c56bae9da3def68224a03687cc521c26e6f38dd41abe81e84f91bb2cab73dc8c7dbbc388787cf066f7d7304c78162cc60c544b99e75187b760c64b4a3  py3-pytube-15.0.0.tar.gz
"
