proxy images and generate discord embed from pages
Find a file
2023-11-18 19:54:54 -03:00
mediaproxy add proxying support 2023-11-18 19:54:54 -03:00
tests test_insertr: account for list responses 2020-01-24 21:28:19 -03:00
.gitignore remove cache dir from gitignore 2019-03-16 04:10:27 -03:00
.gitlab-ci.yml ci: bump to 3.11 2023-05-27 17:26:53 -03:00
config.ci.ini add config.ci.ini 2019-02-22 17:53:24 -03:00
config.example.ini add configurable ratelimit 2019-03-29 03:46:44 -03:00
ecosystem.config.js add ecosystem file for pm2 usage 2019-03-14 03:12:17 +00:00
LICENSE replace GPLv3 with AGPLv3 2019-02-21 21:06:41 -03:00
nginx.conf add config file 2019-02-22 16:33:10 -03:00
Pipfile add proxying support 2023-11-18 19:54:54 -03:00
Pipfile.lock add proxying support 2023-11-18 19:54:54 -03:00
README.md update readme 2020-01-22 22:14:24 -03:00
requirements.txt Use tox 2019-03-13 22:43:26 -05:00
run.py add proxying support 2023-11-18 19:54:54 -03:00
setup.py update deps 2022-08-13 17:25:43 -03:00
test.sh test.sh: run $@ to pytest 2020-01-24 21:27:16 -03:00
tox.ini tox: use any python 3 2023-05-27 17:27:48 -03:00

mediaproxy

Proxy Images and other files through itself. Also can generate Discord Embeds out of given websites, via OpenGraph or <meta> tags or other embedders.

This is an optional component of Litecord.

This is designed to run on a separate machine, so the server running the litecord instance does not have to deal with other websites.

Discord does not use this software.

Installation

Requirements:

mediaproxy does not require a database. The filesystem is used as cache.

Download the code

$ git clone https://gitlab.com/litecord/mediaproxy.git && cd mediaproxy

Install packages

$ pipenv install

Configuration

$ cp config.example.ini config.ini
# edit config.ini as wanted

Running

It is preferred to run mediaproxy on the port 5002, while Litecord and its websocket run on ports 5000 and 5001 respectively.

$ pipenv run hypercorn run:app --bind 0.0.0.0:5002

It is recommended to run mediaproxy behind NGINX. You can use the nginx.conf file at the root of the repository as a template.

Usage

external websites use the following syntax in paths:

/<scheme>/<path>

path is composed of <host>/<url_path>. scheme can only be http or https.

  • the /img/ scope proxies an external HTTP website's multimedia resource.
  • the /meta scope gives metadata about an external image, such as width and height, used for embed generation in litecord
  • the /embed/ scope gives a discord embed representing the url. depending of the url's format it can be routed to a different embedder, such as the OGP (OpenGraph Protocol) embedder, <meta> embedder, or XKCD embedder, etc.

Errors

  • Requesting images or metadata from URLs that aren't images will return a 405 Method Not Allowed response.
  • Embeds that fail to be generated will return null.

Example

if you want to get a certain image's raw data as a response body, http://blah.com/img/http/website.com/photo.png

replace img with meta for image metadata, and img with embed to generate an embed.