# Contributor: Jason Qiu <jasonwqiu@gmail.com>

_realname=streamlink
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=6.9.0
pkgrel=1
pkgdesc="A CLI utility that extracts streams from various services and pipes them into a video player of choice. (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: streamlink'
  'pypi: streamlink'
)
msys2_repository_url='https://github.com/streamlink/streamlink/'
url='https://streamlink.github.io/'
license=('spdx:BSD-2-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python-"{certifi,isodate,lxml,pycountry,pycryptodome,pysocks,requests,trio,trio-websocket,typing_extensions,urllib3,websocket-client})
makedepends=("${MINGW_PACKAGE_PREFIX}-python-"{build,installer,setuptools,wheel})
optdepends=("${MINGW_PACKAGE_PREFIX}-ffmpeg: Required to play streams that are made up of separate audio and video streams, eg. YouTube 1080p+")
options=('!strip')
source=("https://github.com/${_realname}/${_realname}/releases/download/${pkgver}/${_realname}-${pkgver}.tar.gz"{,.asc})
sha256sums=('2ca9b0b17b80bc9d09a8422c390cb38d819af5566493960bf210d8fee221c17f'
            'SKIP')
validpgpkeys=('CDAC41B9122470FAF357A9D344448A298D5C3618') # Streamlink signing key <streamlink@protonmail.com>

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
