SUMMARY="A simple-to-use, cross-platform graphical interface for youtube-dl"
DESCRIPTION="YouTubeDL-GUI is a cross-platform graphical interface for \
youtube-dl, a downloader for online media sharing services like YouTube,\
 Vimeo, SoundCloud, Bandcamp, and more. It is based on Qt and aims to be\
 simple-to-use, while still providing various options like file formats \
and quality levels."
HOMEPAGE="https://github.com/JaGoLi/ytdl-gui"
COPYRIGHT="2020-2021 JaGoLi"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/JaGoLi/ytdl-gui/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="93ce39a00b2a66dbdfa7f7be21bee19f3f1ce0ad6f727464d9245e27072785a9"
SOURCE_FILENAME="ytdl-gui-$portVersion-tar.gz"
SOURCE_DIR="ytdl-gui-$portVersion"
ADDITIONAL_FILES="ytdl_gui.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	ytdl_gui$secondaryArchSuffix = $portVersion
	app:YouTubeDL_GUI$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:youtube_dl
	lib:libcrypto$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libmp4v2$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Network$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:cmake
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cmake -B build $cmakeDirArgs \
		-DCMAKE_INSTALL_BINDIR=$appsDir
	rm -rf $dataDir
	make build
}

INSTALL()
{
	make install -C build

	local APP_SIGNATURE="application/x-vnd.ytdl_gui"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/ytdl_gui.rdef.in > $sourceDir/ytdl_gui.rdef
	addResourcesToBinaries $sourceDir/ytdl_gui.rdef $appsDir/youtubedl-gui
	addAppDeskbarSymlink $appsDir/youtubedl-gui "YouTubeDL-GUI"
}
