Skip to main content

Discord Archiver Media Archiver

Meant to be used in conjunction with Discord Archiver

A simple script and command line tool to archive the Discord media from Discord CDN links in archived chats, along with options for archiving Tenor gifs in the chat, or replacing the embed Tenor view links with direct media links to make the chat look nicer.

All media sent through Discord uses Discord's CDN (Content Distribution Network) links, which have a built in expiry of around 24 hours when not used in the Discord app or website. Thus, any links archived will be inaccessible after that time period, meaning that your archived chats will lose all their media after 24 hours.

This script downloads and replaces all the CDN media links in the archive HTML file with a path to a locally saved version of the media, meaning even after the links expire you can still scroll through the chats and see all the photos, voice messages, and videos in all their glory.

Please run this tool either immediately after downloading the archive via Discord Archiver, or within approximately 24 hours so that media can be saved without the links expiring.

Installation

As Python Package

Install from pip with the following command

python3 -m pip install discord-archiver-media-archiver

Can also be run as a python script via

python3 media_archiver.py "archive name"

As executable (Windows Only)

  • Go to Releases on Github and download the media_archiver.exe file

  • Place the exe in the same folder as the html or file that you're trying to archive the links from.

  • Double click and run the exe and follow the instructions.

Usage

usage: media_archiver.py [-h] [-g] [-ndc] [-gl] [-r [REFRESH]] archive

positional arguments:
  archive               the Discord archive in the current working directory to archive media from

options:
  -h, --help            show this help message and exit
  -g, --gifs            enable the download and archival of gifs from Tenor while archiving
  -ndc, --no-discord-cdn
                        disable downloads from the Discord CDN servers (useful for if the CDN links are already expired or downloaded and you just
                        want to archive gifs)
  -gl, --gif-links      replace the gif embed links in the archive with the direct media links from Tenor (does not archive any media, overrides -g)
  -r, --refresh [REFRESH]
                        refresh the cdn links in the file with new ones. Uses the entered Discord auth token, or defaults to the environmental
                        variable DISCORD_TOKEN if none entered

Examples

da-ma "archive_(350) Discord_2026-07-16.html"

Downloads all Discord CDN media in the archive file "archive_(350) Discord_2026-07-16.html", but not gifs.


da-ma "archive_(350) Discord_2026-07-16.html" -g

Downloads all Discord CDN media in the archive file "archive_(350) Discord_2026-07-16.html" including gifs.


da-ma "archive_(350) Discord_2026-07-16.html" -gl

Downloads all Discord CDN media in the archive file "archive_(350) Discord_2026-07-16.html" and replaces all Tenor gifs with their direct media link, but does not download them.


da-ma "archive_(350) Discord_2026-07-16.html" -g -ndc

Downloads only the Tenor gifs from the archive file "archive_(350) Discord_2026-07-16.html".

Python Library

Since this was written in Python, you can also import the package media_archiver in order to use the underlying methods behind the CLI tool in your Python scripts and programs.

The core methods are:

def archive_media(archive_name: str, do_cdn : bool = True, do_gifs : bool = False, do_gif_links : bool = False, refresh_token : str = ""):
    """
    Archive all the media from a given html and replace all cdn web links in the html with local file paths.
        
    :param archive_name: name of archive file to replace and archive the media from
    :type archive_name: str
    :param do_cdn: whether to archive from Discord CDN Links (default True)
    :type do_cdn: bool
    :param do_gifs: whether to archive gifs from TENOR (default False)
    :type do_gifs: bool
    :param do_gif_links: whether to not archive gifs but just replace the gif embed links with true TENOR media links (default False, overrides do_gifs)
    :type do_gif_links: bool
    :param refresh_token: if provided, refresh Discord CDN links in the file using the provided Discord authentication token
    :type refresh_token: str
    """

def fetch_tenor_media_link(tenor_view_link : str)
# Convert from a Tenor view link to a Tenor direct media link

class CDN_Media(media_link: str, save_location: Path, fetch = True)
# Downloads media from media_link upon creation unless fetch is set to false, so be careful.
# Despite the name, does still work on gifs

Note

If this package was of use to you, maybe leave a comment in Github Discussions, or a star or a watch, just so I know that someone got use out of something I made, since it's hard to tell otherwise. It's a nice feeling, to know that your efforts weren't wasted on just yourself.

Changelog

V 1.0.4

  • Changed the Regex string for the Discord CDN URLs to be more robust and to capture other types such as the one used in the non-web app, although how useful that is, that is to be seen.

V 2.0.0

  • Added functionality to refresh links via discord_cdn_link_refresher
  • Added an interactive command line interface for a compiled exe version on Windows

Metadata

Release files for discord-archiver-media-archiver 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discord-archiver-media-archiver 2.0.1
File Size Uploaded Provenance
discord_archiver_media_archiver-2.0.1.tar.gz 37.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for discord-archiver-media-archiver 2.0.1
File Interpreter ABI Platform
discord_archiver_media_archiver-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 48.1 kB

Release files / discord_archiver_media_archiver-2.0.1.tar.gz

Download URL discord_archiver_media_archiver-2.0.1.tar.gz
Size 37.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b3a1482e52b2de39874d6d70c5b6d1fbf2ed4c47521c71773a83ccd69985be93
BLAKE2b-256 checksum
How to use checksums
19c4b95eaf62c860933c9fa81e46e7b0eea206e13a45c22accf6b2fefc242861
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / discord_archiver_media_archiver-2.0.1-py3-none-any.whl

Download URL discord_archiver_media_archiver-2.0.1-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
812e41ba0855395a01e3bad4acc93bc63577caac29dde71c61dd3255f707bca9
BLAKE2b-256 checksum
How to use checksums
07f57fc5233399f27ba22c7dd93728a9e90969342fa7e05740bc60af646294c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for discord-archiver-media-archiver 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page