Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: fetch new changelog and delete old ones

NTFSvolume3be58534807e
diff --git a/cyberdrop_dl/ui/ui.py b/cyberdrop_dl/ui/ui.py
index fb6f7b164..9b723594b 100644
--- a/cyberdrop_dl/ui/ui.py
+++ b/cyberdrop_dl/ui/ui.py
@@ -23,6 +23,7 @@ from cyberdrop_dl.ui.prompts.settings_global_prompts import edit_global_settings
from cyberdrop_dl.ui.prompts.settings_hash_prompts import path_prompt
from cyberdrop_dl.ui.prompts.settings_user_prompts import create_new_config_prompt, edit_config_values_prompt
from cyberdrop_dl.ui.prompts.url_file_prompts import edit_urls_prompt
+from cyberdrop_dl.utils.utilities import check_latest_pypi
console = Console()
@@ -201,7 +202,7 @@ def program_ui(manager: Manager):
import_cyberdrop_v4_items_prompt(manager)
elif action == 11:
- changelog_path = manager.path_manager.config_dir.parent / f"CHANGELOG_{__version__}.md"
+ changelog_path = manager.path_manager.config_dir.parent / "CHANGELOG.md"
changelog_content = asyncio.run(_get_changelog(changelog_path))
with console.pager(links = True):
@@ -214,16 +215,21 @@ def program_ui(manager: Manager):
async def _get_changelog(changelog_path: Path):
url = "https://raw.githubusercontent.com/jbsparrow/CyberDropDownloader/refs/heads/master/CHANGELOG.md"
- if not changelog_path.is_file():
+ _ , lastest_version = await check_latest_pypi(log_to_console = False)
+ latest_changelog = changelog_path.with_name(f"{changelog_path.stem}_{lastest_version}{changelog_path.suffix}")
+ if not latest_changelog.is_file():
+ changelog_pattern = f"{changelog_path.stem}*{changelog_path.suffix}"
+ for old_changelog in changelog_path.parent.glob(changelog_pattern):
+ old_changelog.unlink()
try:
async with request("GET", url) as response:
response.raise_for_status()
- async with aiofiles.open(changelog_path, 'wb') as f:
+ async with aiofiles.open(latest_changelog, 'wb') as f:
await f.write(await response.read())
except Exception:
return "UNABLE TO GET CHANGELOG INFORMATION"
- changelog_lines = changelog_path.read_text(encoding="utf8").splitlines()
+ changelog_lines = latest_changelog.read_text(encoding="utf8").splitlines()
# remove keep_a_changelog disclaimer
changelog_content = "\n".join(changelog_lines[:4] + changelog_lines[6:])