diff --git a/.gitignore b/.gitignore index 952e53d..2c18aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *egg-info __pycache__ +hbd-cookies.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 4db1a89..2458f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +### 0.2.2 +- Confirm the download is complete by checking the expected size to what downloaded +- Fixed the platform filter + ### 0.2.1 - Fixed include & exclude logic being switched in v0.2.0 diff --git a/humblebundle_downloader/_version.py b/humblebundle_downloader/_version.py index fc79d63..020ed73 100644 --- a/humblebundle_downloader/_version.py +++ b/humblebundle_downloader/_version.py @@ -1 +1 @@ -__version__ = '0.2.1' +__version__ = '0.2.2' diff --git a/humblebundle_downloader/download_library.py b/humblebundle_downloader/download_library.py index 1779c5c..23d012a 100644 --- a/humblebundle_downloader/download_library.py +++ b/humblebundle_downloader/download_library.py @@ -306,6 +306,9 @@ class DownloadLibrary: space=' ' * (pb_width - done), ), end='\r') + if dl != total_length: + raise ValueError("Download did not complete") + def _load_cache_data(self, cache_file): try: with open(cache_file, 'r') as f: @@ -326,7 +329,9 @@ class DownloadLibrary: def _should_download_platform(self, platform): platform = platform.lower() - return self.platform_include and platform not in self.platform_include + if self.platform_include and platform not in self.platform_include: + return False + return True def _should_download_file_type(self, ext): ext = ext.lower() diff --git a/tests/test_download_library.py b/tests/test_download_library.py index 46bd440..a2ad0cc 100644 --- a/tests/test_download_library.py +++ b/tests/test_download_library.py @@ -1,6 +1,9 @@ from humblebundle_downloader.download_library import DownloadLibrary +### +# _should_download_file_type +### def test_include_logic_has_values(): dl = DownloadLibrary( 'fake_cookie_path', @@ -47,3 +50,36 @@ def test_exclude_logic_empty(): assert dl._should_download_file_type('df') is True assert dl._should_download_file_type('EPub') is True assert dl._should_download_file_type('mobi') is True + + +### +# _should_download_platform +### +def test_download_platform_filter_none(): + dl = DownloadLibrary( + 'fake_cookie_path', + 'fake_library_path', + platform_include=None, + ) + assert dl._should_download_platform('ebook') is True + assert dl._should_download_platform('audio') is True + + +def test_download_platform_filter_blank(): + dl = DownloadLibrary( + 'fake_cookie_path', + 'fake_library_path', + platform_include=[], + ) + assert dl._should_download_platform('ebook') is True + assert dl._should_download_platform('audio') is True + + +def test_download_platform_filter_audio(): + dl = DownloadLibrary( + 'fake_cookie_path', + 'fake_library_path', + platform_include=['audio'], + ) + assert dl._should_download_platform('ebook') is False + assert dl._should_download_platform('audio') is True