%{?!%python3_version:%global python3_version 3.6}

%global commit0 3885ed8b92c5b6c90b17b27342acadb0a84b946c
%global shortcommit0 %(c=%{commit0}; echo ${c:0:10})

%global rel_date 20210202

Name:           subdownloader
Version:        2.2.0
Release:        0.2.%{rel_date}git%{shortcommit0}%{?dist}
Summary:        SubDownloader is a Free Open-Source tool written in Python for automatic download/upload of subtitles for video files
License:        GPLv3
Url:            https://github.com/subdownloader/subdownloader

#Source0:         https://github.com/subdownloader/subdownloader/archive/%%{version}.tar.gz
#Patch1:         https://github.com/sergiomb2/subdownloader/compare/2.1.0...%%{shorthash}.diff
Source0:          https://github.com/subdownloader/%{name}/archive/%{commit0}/%{name}-%{shortcommit0}.tar.gz
Patch1:         subdownloader-locale.patch

BuildArch:      noarch

BuildRequires:	gettext
BuildRequires:  python3-devel
BuildRequires:  python3-rpm-macros
BuildRequires:  python3-setuptools
BuildRequires:  desktop-file-utils
BuildRequires:  %{py3_dist sphinx}
BuildRequires:  /usr/bin/pyuic5

Requires:  python3-qt5
Requires:  %{py3_dist progressbar2}

%if 0%{?fedora} || 0%{?rhel} > 7
Requires:  %{py3_dist pymediainfo}
Requires:  %{py3_dist argcomplete}
%endif

%description
SubDownloader is a Free Open-Source tool written in Python for automatic download/upload of subtitles for video files. It uses some smart hashing algorithms to work fast


%prep
%autosetup -n %{name}-%{commit0} -p1

%build
scripts/gui/generate.py -F
%py3_build

%install
%py3_install

desktop-file-install %{name}.desktop --dir=%{buildroot}%{_datadir}/applications

%find_lang %{name} --all-name
cat %{name}.lang

%check
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop


#files -f %{name}.lang
%files
%doc README.md ChangeLog
%license COPYING
%{python3_sitelib}/%{name}
%{python3_sitelib}/*.egg-info
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop


# Must i generate langpacks??
#{python3_sitelib}/%%{name}/languages/*.py
#{python3_sitelib}/%%{name}/languages/__pycache__/*.pyc

# I really dont know if its right
#{python3_sitelib}/%%{name}/client/locale/*/%%{name}*.po
#{python3_sitelib}/%%{name}/client/locale/%%{name}*.pot

#{python3_sitelib}/%%{name}/provider/*.py
#{python3_sitelib}/%%{name}/provider/__pycache__/*.pyc

#exclude %%{python3_sitelib}/%%{name}-%%{version}-py%%{python3_version}.egg/*

%changelog
* Fri Sep 04 2020 Xoloitzcuintle <xoloitzcuintle_god@protonmail.com> - 2.1.0-2
- rebuilt


* Sat Aug 29 2020 Xoloitzcuintle <xoloitzcuintle_god@protonmail.com> - 2.1.0
- Initial package