Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: remove arrow dependency (#1300)

NTFSvolumee1dac6fb99f9
diff --git a/cyberdrop_dl/database/transfer.py b/cyberdrop_dl/database/transfer.py
index a5b3b1046..0f9969b77 100644
--- a/cyberdrop_dl/database/transfer.py
+++ b/cyberdrop_dl/database/transfer.py
@@ -2,11 +2,11 @@ from __future__ import annotations
import contextlib
import sqlite3
+import time
from datetime import datetime
from pathlib import Path
from shutil import copy2
-import arrow
from rich.console import Console
from .tables.definitions import create_files, create_temp_hash
@@ -62,10 +62,10 @@ def transfer_v5_db_to_v6(db_path: Path) -> None:
folder, download_filename, file_size, hash, original_filename, referer = row
file_path = Path(folder, download_filename)
- if file_path.exists():
+ try:
file_date = int(file_path.stat().st_mtime)
- else:
- file_date = int(arrow.now().float_timestamp)
+ except (OSError, ValueError):
+ file_date = int(time.time())
data_to_insert_files.append((folder, download_filename, original_filename, file_size, referer, file_date))
data_to_insert_hash.append((folder, download_filename, "md5", hash))
diff --git a/cyberdrop_dl/scraper/filters.py b/cyberdrop_dl/scraper/filters.py
index 950dc4373..bc6cc339a 100644
--- a/cyberdrop_dl/scraper/filters.py
+++ b/cyberdrop_dl/scraper/filters.py
@@ -1,10 +1,10 @@
from __future__ import annotations
+import datetime
import inspect
from http import HTTPStatus
from typing import TYPE_CHECKING
-import arrow
from yarl import URL
import cyberdrop_dl.constants as constants
@@ -15,7 +15,6 @@ from cyberdrop_dl.utils.utilities import get_filename_and_ext
if TYPE_CHECKING:
from collections.abc import Sequence
- from datetime import date
from aiohttp import ClientResponse
@@ -44,12 +43,13 @@ def is_valid_url(scrape_item: ScrapeItem) -> bool:
return True
-def is_outside_date_range(scrape_item: ScrapeItem, before: date | None, after: date | None) -> bool:
+def is_outside_date_range(scrape_item: ScrapeItem, before: datetime.date | None, after: datetime.date | None) -> bool:
skip = False
item_date = scrape_item.completed_at or scrape_item.created_at
if not item_date:
return False
- if (after and arrow.get(item_date).date() < after) or (before and arrow.get(item_date).date() > before):
+ date = datetime.datetime.fromtimestamp(item_date).date()
+ if (after and date < after) or (before and date > before):
skip = True
return skip
diff --git a/poetry.lock b/poetry.lock
index 65eca5241..a4142f925 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -256,26 +256,6 @@ all-plugins = ["PGPy", "cryptography", "gntp", "paho-mqtt (!=2.0.*)", "smpplib"]
dev = ["babel", "coverage", "mock", "pytest", "pytest-cov", "pytest-mock", "ruff", "tox", "validate-pyproject"]
windows = ["pywin32"]
-[[package]]
-name = "arrow"
-version = "1.3.0"
-description = "Better dates & times for Python"
-optional = false
-python-versions = ">=3.8"
-groups = ["main"]
-files = [
- {file = "arrow-1.3.0-py3-none-any.whl", hash = "sha256:c728b120ebc00eb84e01882a6f5e7927a53960aa990ce7dd2b10f39005a67f80"},
- {file = "arrow-1.3.0.tar.gz", hash = "sha256:d4540617648cb5f895730f1ad8c82a65f2dad0166f57b75f3ca54759c4d67a85"},
-]
-
-[package.dependencies]
-python-dateutil = ">=2.7.0"
-types-python-dateutil = ">=2.8.10"
-
-[package.extras]
-doc = ["doc8", "sphinx (>=7.0.0)", "sphinx-autobuild", "sphinx-autodoc-typehints", "sphinx_rtd_theme (>=1.3.0)"]
-test = ["dateparser (==1.*)", "pre-commit", "pytest", "pytest-cov", "pytest-mock", "pytz (==2021.1)", "simplejson (==3.*)"]
-
[[package]]
name = "asyncpraw"
version = "7.8.1"
@@ -2688,18 +2668,6 @@ files = [
{file = "truststore-0.10.4.tar.gz", hash = "sha256:9d91bd436463ad5e4ee4aba766628dd6cd7010cf3e2461756b3303710eebc301"},
]
-[[package]]
-name = "types-python-dateutil"
-version = "2.9.0.20250708"
-description = "Typing stubs for python-dateutil"
-optional = false
-python-versions = ">=3.9"
-groups = ["main"]
-files = [
- {file = "types_python_dateutil-2.9.0.20250708-py3-none-any.whl", hash = "sha256:4d6d0cc1cc4d24a2dc3816024e502564094497b713f7befda4d5bc7a8e3fd21f"},
- {file = "types_python_dateutil-2.9.0.20250708.tar.gz", hash = "sha256:ccdbd75dab2d6c9696c350579f34cffe2c281e4c5f27a585b2a2438dd1d5c8ab"},
-]
-
[[package]]
name = "typing-extensions"
version = "4.14.1"
@@ -3125,4 +3093,4 @@ propcache = ">=0.2.1"
[metadata]
lock-version = "2.1"
python-versions = ">=3.11,<4"
-content-hash = "ee7de78558c44af4fcfae7ec32353a6e4f5a3c6db8565041f61e7ad4b3d41e44"
+content-hash = "8b0908f6ab7cb747169855454b13926123d5d1e0e831ec1d543c9e7ef5ab0ea4"
diff --git a/pyproject.toml b/pyproject.toml
index d059011c5..c7858ec36 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -8,7 +8,6 @@ dependencies = [
"aiolimiter >=1.2.1",
"aiosqlite==0.17.0",
"apprise >=1.9.4",
- "arrow >=1.3.0",
"asyncpraw >=7.8.1",
"beautifulsoup4 ==4.13.4", # TODO: Fix "replaced with REPLACEMENT CHARACTER" warnings for 4.13.5 [bug=2112242]
"browser-cookie3 >=0.20.1",