Skip to main content

Downloads all media assets from JSON files generated by DiscordChatExporter.

Project description

Dimage

Build

Downloads all media assets from JSON files generated by DiscordChatExporter.

⚙️ Features

  • Parses .json export files from DiscordChatExporter.
  • Downloads guild icons, user avatars, mention avatars, reaction avatars, custom emojis (inline and in reactions), and message attachments.
  • Organizes downloaded media into subdirectories named after the source channel or DM.
  • Optionally categorizes media into folders (icons, avatars, emojis, channels) using a command-line flag.
  • Sets local file modification timestamps to match the original Discord message timestamps.
  • Skips duplicate URLs to avoid redundant downloads and improve performance.
  • Offers fine-grained control over which asset types to download via command-line flags.
  • Supports skipping downloads based on file extensions.
  • Includes a mode to set timestamps on existing files without downloading.

⚠️ Disclaimers

  • Default File Extension: If a file extension cannot be determined from the URL, the tool defaults to .png for icons, avatars, and standard emojis. Animated emojis default to .gif.
  • Timestamp-Only Mode: The --timestamp-only mode assumes the file structure and naming have not been altered since the initial download. It relies on a processing order that may be unstable if files have been moved, renamed, or deleted. Use this feature only to refresh timestamps on an unmodified collection of downloaded files.
  • Testing: This software is tested manually. Automated testing of download functionality is not feasible because Discord media links expire after 24 hours.

🚀 Installation

From PyPI

pip install dimage

With pipx

pipx install dimage

With Conda

conda create -n dimage python=3.9 -y
conda activate dimage
pip install dimage

From Source

git clone https://github.com/Inc44/Dimage.git
cd Dimage

To install the package:

pip install .

To install only the dependencies:

pip install -r requirements.txt

If you install only the dependencies, run the program using python -m dimage.cli (or python -OO dimage/cli.py) instead of the dimage command.

🛠️ Build

pip install build
python -m build

📖 Usage Examples

Standard Download

Download all media, skipping duplicates and SVG files. Media will be organized into folders named after each channel. Assumes your JSON files are in a directory named json.

dimage --no-dupes --skip svg

Organized Download

Download all media, skipping duplicates and SVG files. Media will be organized by type (icons, avatars, emojis, channels).

dimage --no-dupes --skip svg --organize

Update Timestamps Only

Apply original timestamps to already downloaded files. Assumes files are in an organized structure. No new files will be downloaded. Displays info and warnings.

dimage --no-dupes --skip svg --timestamp-only --organize --loglevel info

Attachments Only

Download only message attachments, skipping all other media types, duplicates, and SVG files.

dimage --no-guild-icon --no-avatars --no-mentions --no-reactions --no-reactions-emojis --no-inline-emojis --no-dupes --skip svg

I prefer to skip SVG files, as in 99.99% of cases, they are just standard Discord emojis.

🎨 Command-Line Arguments

Argument Description
-i, --input <path> Path to the input directory containing .json files. Default: json.
-o, --output <path> Path to the root output directory for downloads. Default: downloads.
--no-guild-icon Skip downloading the guild/server icon.
--no-avatars Skip downloading message author avatars.
--no-mentions Skip downloading avatars of mentioned users.
--no-reactions Skip downloading avatars of users who reacted.
--no-reactions-emojis Skip downloading custom emojis used in reactions.
--no-inline-emojis Skip downloading custom emojis used inline in messages.
--no-attachments Skip downloading message attachments.
--no-dupes Avoid downloading duplicate files based on URL.
--skip <exts> Skip files with specified comma-separated extensions.
--timestamp-only Set timestamps on existing files without downloading.
--organize Organize files into categories: icons, avatars, emojis, and channels (for attachments).
--loglevel <level> Set the logging level (NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL). Default: ERROR.

🚧 TODO

  • Refactor for Concurrency: Re-architect the download logic using asyncio and aiohttp to replace the current sequential, blocking requests implementation. This will significantly improve performance.
  • Implement Persistent Cache: Replace the in-memory visited_urls set with a persistent on-disk cache (e.g., a simple database or a state file). This will allow the application to be stopped and resumed, prevent redundant downloads, and enable recovery from interruptions.
  • Add Robust Retry Logic: Integrate a library such as tenacity or retrying into the download function to automatically handle transient network errors, timeouts, and HTTP 429 (Too Many Requests) status codes with exponential backoff.
  • Establish Formal Testing: Develop a formal test suite using pytest. Implement mocking for network requests to test application logic without relying on expiring Discord URLs. Add coverage to measure test effectiveness and identify untested code paths.

📜 License

MIT

This project is licensed under the MIT License. See the LICENSE file for details.

🤝 Support

BuyMeACoffee Ko-Fi Patreon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dimage-2025.7.7.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dimage-2025.7.7-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file dimage-2025.7.7.tar.gz.

File metadata

  • Download URL: dimage-2025.7.7.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for dimage-2025.7.7.tar.gz
Algorithm Hash digest
SHA256 d13e5096484601a8a67fb6959b664c4cd95e4db845285007016f2b5d5d0409f5
MD5 f323033e10ce415449af25dafe78e9fe
BLAKE2b-256 1b33bda91c27d15cc03362b561138ed058eda70e9a1aaafce3b8348a1d683f79

See more details on using hashes here.

File details

Details for the file dimage-2025.7.7-py3-none-any.whl.

File metadata

  • Download URL: dimage-2025.7.7-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for dimage-2025.7.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b50a4060ebe4a6b4c469265ee88309f32c0a4f7499f8b7e329305233233eb776
MD5 34b6c034a2af2f4e125d13967337a08b
BLAKE2b-256 bbfafc176c3f65628e2bc99bfcd1aa0ab3e1254ebe9dd0255dd1f08418d442cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page