Name:           youtube-dl
Version:        2020.06.16.1
Release:        1%{?dist}
Summary:        A small command-line program to download online videos
License:        Unlicense
URL:            https://yt-dl.org
Source0:        https://github.com/rg3/youtube-dl/releases/download/%{version}/youtube-dl-%{version}.tar.gz
Source1:        https://github.com/rg3/youtube-dl/releases/download/%{version}/youtube-dl-%{version}.tar.gz.sig
# 2016-06-09:
# Merged GPG keys from https://rg3.github.io/youtube-dl/download.html in one file
# gpg --export  --export-options export-minimal "428D F5D6 3EF0 7494 BB45 5AC0 EBF0 1804 BCF0 5F6B" \
# "ED7F 5BF4 6B3B BED8 1C87 368E 2C39 3E0F 18A9 236D" \
# "7D33 D762 FD6C 3513 0481 347F DB4B 54CB A482 6A18" > youtube-dl-gpgkeys.gpg
Source2:        youtube-dl-gpgkeys.gpg
Source3:        %{name}.conf
BuildRequires:  python3-devel
# Tests failed because of no connection in Koji.
# BuildRequires:  python-nose
BuildArch:      noarch
# For source verification with gpgv
BuildRequires:  gnupg2


%description
Small command-line program to download videos from YouTube and other sites.


%prep
gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0}
%setup -qn %{name}
# remove pre-built file
rm youtube-dl
cp -a setup.py setup.py.installpath
# Remove files that are installed to the wrong path
sed -i '/youtube-dl.bash-completion/d' setup.py
sed -i '/youtube-dl.fish/d' setup.py
sed -i '/README.txt/d' setup.py
# Remove interpreter shebang from module files.
find youtube_dl -type f -exec sed -i -e '1{/^\#!\/usr\/bin\/env python$/d;};' {} +


%build
%{__python3} setup.py build


%install
%{__python3} setup.py install --optimize 2 --root %{buildroot}
mkdir -p %{buildroot}%{_sysconfdir}
install -pm644 %{S:3} %{buildroot}%{_sysconfdir}
mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d/
install -pm644 youtube-dl.bash-completion %{buildroot}%{_sysconfdir}/bash_completion.d/youtube-dl
mkdir -p %{buildroot}%{_datadir}/zsh/site-functions/
install -pm644 youtube-dl.zsh %{buildroot}%{_datadir}/zsh/site-functions/_youtube-dl


%files
%doc README.md
%{python3_sitelib}/youtube_dl/
%{python3_sitelib}/youtube_dl*.egg-info
%license LICENSE
%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*
%config(noreplace) %{_sysconfdir}/%{name}.conf
%{_sysconfdir}/bash_completion.d/%{name}
%{_datadir}/zsh/site-functions/_youtube-dl


%changelog
