Catalog PyPI
Back to packageRELEASE DETAILS

1.1.1

PyPI

afetchx

# afetchx Asynchronously fetch image URLs using httpx. `afetchx` parses command-line arguments to determine the list of image URLs to fetch, the maximum number of concurrent connections, the cooldown time between requests, an optional JSON file containing URLs, and output options. It then fetches the images, saves them in the specified output directory, and prints the number of successfully downloaded images. ## Usage Invoke the script with ```bash python -m afetchx {args} ``` ## Command-line arguments - `-n`, `--max_connections`: Max number of concurrent connections (default: 5). - `-c`, `--cooldown`: Cooldown time between requests in seconds (default: 1.0). - `-j`, `--json`: Path to a JSON

Published3 Nov 2024
Direct dependencies5
Transitive dependenciesNot calculated

README

Version 1.1.1 documentation

afetchx

Asynchronously fetch image URLs using httpx.

afetchx parses command-line arguments to determine the list of image URLs to fetch, the maximum number of concurrent connections, the cooldown time between requests, an optional JSON file containing URLs, and output options. It then fetches the images, saves them in the specified output directory, and prints the number of successfully downloaded images.

Usage

Invoke the script with

python -m afetchx {args}

Command-line arguments

  • -n, --max_connections: Max number of concurrent connections (default: 5).
  • -c, --cooldown: Cooldown time between requests in seconds (default: 1.0).
  • -j, --json: Path to a JSON file containing URLs to fetch.
  • -o, --output-dir: Directory to save downloaded images (default: ./downloaded in the current working directory).
  • --filename-format: Lambda function as a string to format filenames based on the URL (e.g., "lambda url: url.split('/')[-1].split('.')[0] + '.png'").
  • urls: List of image URLs to fetch (positional arguments).

Note: You must satisfy exactly one of the following conditions

  1. Use the --json (-j) argument to specify a JSON file containing URLs.
  2. Provide one or more URLs directly as positional arguments.

Examples

Basic Usage

Download images from a JSON file with a cooldown of 1 second between each download and a maximum of 5 concurrent connections:

python -m afetchx -j urls.json -c 1.0 -n 5

Specify Output Directory

Download images from URLs provided as positional arguments and save them to a custom directory:

python -m afetchx -c 1.0 -n 5 -o ./downloaded_pictures "https://unsplash.it/256.jpg" "https://unsplash.it/512.jpg"

Use Custom Filename Format

Download images and apply a custom filename format based on the URL:

python -m afetchx -c 1.0 -n 5 --filename-format "lambda url: url.split('/')[-1].split('.')[0] + '.png'" "https://example.com/image1.png" "https://example.com/image2.jpg"

In this example, each downloaded image will be named according to the lambda function. The filename format option can be especially useful for sanitizing or modifying filenames before saving.

Error Handling

If both URLs and a JSON file are provided, the script will print an error and exit. Likewise, if neither URLs nor a JSON file are provided, the script will print an error and exit. Ensure exactly one source for URLs.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 5

Native requirements
5 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
tqdm
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.10",
  "evaluation": "NOT_EVALUATED"
}
tqdm<5.0.0,>=4.66.6runtime
httpx
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.10",
  "evaluation": "NOT_EVALUATED"
}
httpx<0.28.0,>=0.27.2runtime
argparse
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.10",
  "evaluation": "NOT_EVALUATED"
}
argparse<2.0.0,>=1.4.0runtime
aiofiles
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.10",
  "evaluation": "NOT_EVALUATED"
}
aiofiles<25.0.0,>=24.1.0runtime
pytest-asyncio
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": "<4.0,>=3.10",
  "evaluation": "NOT_EVALUATED"
}
pytest-asyncio<0.25.0,>=0.24.0runtime

Distribution files

2 collected
afetchx-1.1.1-py3-none-any.whl

bdist_wheel · 4.7 KB · Python py3

Source file
afetchx-1.1.1.tar.gz

sdist · 4.1 KB · Python source

Source file

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:02 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:3e73ea39557a4f64c005a55794bdcb2e685bc24880ba61cee44e8ace2629db83

Other collected versions

View all collected versions →