Web UI for downloading media with gallery-dl and yt-dlp.
Project description
gallery-dl-server
Web UI for gallery-dl with support for downloading videos via yt-dlp.
Running
Docker
Docker Run
This example uses the docker run command to create the container to run the app.
docker run -d \
--name gallery-dl \
-p 9080:9080 \
-e UID=1000 \
-e GID=1000 \
-v "/path/to/config:/config" \
-v "/path/to/downloads:/gallery-dl" \
--restart on-failure \
qx6ghqkz/gallery-dl-server:latest
Docker Compose
This is an example of a docker-compose.yaml service definition which can be used to start a running container with the docker compose up -d command.
services:
gallery-dl:
image: qx6ghqkz/gallery-dl-server:latest
container_name: gallery-dl
ports:
- 9080:9080
environment:
- UID=1000
- GID=1000
volumes:
- "/path/to/config:/config"
- "/path/to/downloads:/gallery-dl"
restart: on-failure
This is another example which uses a VPN client container for its networking.
services:
gallery-dl:
image: qx6ghqkz/gallery-dl-server:latest
container_name: gallery-dl
network_mode: container:vpn
environment:
- UID=1000
- GID=1000
volumes:
- "/path/to/config:/config"
- "/path/to/downloads:/gallery-dl"
restart: on-failure
Gluetun is recommended for VPN usage. See docs/docker-compose.yaml for an example.
Port Mapping
By default, this service listens on port 9080. Any value can be used for the host port, but the CONTAINER_PORT environment variable needs to be set to change the internal container port. This can be done using the -e flag with docker run or in a Docker Compose file.
For example, to run multiple instances of gallery-dl-server using a single Gluetun instance for the networking (each instance must use a different internal port), a different container port can be set for one of the containers.
services:
instance-1:
image: qx6ghqkz/gallery-dl-server:latest
container_name: day
depends_on:
- gluetun
network_mode: service:gluetun
[...]
instance-2:
image: qx6ghqkz/gallery-dl-server:latest
container_name: night
environment:
- CONTAINER_PORT=9090
depends_on:
- gluetun
network_mode: service:gluetun
[...]
gluetun:
image: qmcgaw/gluetun:latest
container_name: vpn
ports:
# instance-1
- 9080:9080
# instance-2
- 9090:9090
[...]
Important Notes
-
Make sure to mount the directory containing the configuration file rather than the file itself. This ensures changes to the configuration file are propagated to the running Docker container and it will not need to be restarted for changes to take effect. More information on this issue here.
-
The output download directory depends on the
base-directoryin your gallery-dl configuration file. Make sure it is the absolute path/gallery-dl/instead of the relative path./gallery-dl/or else the download directory will need to be mounted to/usr/src/app/gallery-dlinstead (not recommended). -
The environment variables
UIDandGIDcan be used to change the user ID and group ID of the user running the server process. This is important because downloaded files will be owned by that user. Make sure the IDs match those of the user on the host system. The defaultUID:GIDis1000:1000when left unspecified.
Python
If Python 3.10 or later (3.12 is recommended) is installed and on the PATH, the server can simply be run from the command line.
Running from Source
Clone this repository and install the dependencies located in requirements.txt in a virtual environment, then run the command below in the root folder while inside the virtual environment. On Windows, replace python3 with python.
python3 -m gallery_dl_server --host "0.0.0.0" --port "9080"
The command-line arguments are optional. By default, the server will run on host 0.0.0.0 and an available port will be selected if one is not provided.
To view the full list of command-line arguments, perform python3 -m gallery_dl_server -h for help. These arguments can also be specified as environment variables.
Installation
The package and its dependencies can be installed with Python by performing pip install gallery-dl-server. To also install optional dependencies, perform pip install gallery-dl-server[full]. It is recommended to use a virtual environment to avoid dependency conflicts.
The package can be installed directly from the source code by performing pip install . in the root directory of the cloned repository. Perform pip install .[full] to install optional dependencies.
Installation allows running directly from the command line via the command gallery-dl-server. To view the list of command-line options, perform gallery-dl-server -h for help.
When installed, the log file will be created directly in the home directory of the user as long as the package is not found in the current working directory, in which case a logs folder will be created there to store the log file.
Standalone Executable
On Windows, the program can be run using the prebuilt executable (.exe) file, which includes a Python interpreter and the required Python packages. Prebuilt executables for each release can be found in Releases.
By default, any available port will be selected. To select a specific port, run the executable from the command line and specify the port, and optionally host, as command-line arguments.
gallery-dl-server.exe --host "0.0.0.0" --port "9080"
When run as an executable, the log file will be created in a logs folder in the same directory as the executable.
Configuration files can also be loaded from the same directory as the executable. The bundled releases contain a default configuration file in JSON, YAML and TOML formats, which are all supported.
Dependencies
All required and optional Python and non-Python dependencies are included in the Docker image and will be available in the running container, however if you are running gallery-dl-server using any of the other methods, i.e. not with a Docker container, some dependencies may need to be installed separately.
In order to run with Python, the dependencies in requirements.txt need to be installed in the running Python environment. These Python dependencies are included in the standalone executable and do not need to be installed.
Installation with pip only installs the required dependencies by default. Install the gallery-dl-server[full] package to install the optional dependencies.
Optional
- brotli or brotlicffi: Brotli content encoding support
- mutagen: embed metadata and thumbnails in certain formats
- pycryptodomex: decrypt AES-128 HLS streams and other forms of data
- pyyaml: YAML configuration file support
- toml: TOML configuration file support (<= Python 3.10 only)
Non-Python dependencies are not included. FFmpeg is strongly recommended for video and audio conversion and should be accessible from the command line, i.e. on the PATH.
There is also MKVToolNix, which includes mkvmerge for accurate Ugoira frame timecodes.
Dependencies for gallery-dl and yt-dlp are documented in their respective repositories. The majority of these are optional Python dependencies and have been accounted for, however dependencies that are strongly recommended should be installed.
Configuration
Configuration of gallery-dl is as documented in the official documentation. A configuration file is required.
If run outside of Docker, the default locations will be used to search for a configuration file. If run as an executable, the current directory will also be searched for a valid configuration file.
Additionally, YAML and TOML configuration files are supported at any of the pre-defined locations.
When run with Docker, the configuration file must be mounted inside the /config directory inside the container.
Docker Locations
/config/gallery-dl.conf/config/gallery-dl.{yaml, yml}/config/gallery-dl.toml/config/config.json/config/config.{yaml, yml}/config/config.toml
A default configuration file for use with gallery-dl-server has been provided and will automatically be placed in the directory mounted to /config if no valid configuration file exists in that location.
For more information on configuration file options, see gallery-dl/docs/configuration.rst.
Any additional locations specified in the configuration file must also exist inside the Docker container. For example, if a cookies file is required, ensure it is placed in a location accessible from within the Docker container.
It is recommended to place any additional files such as archive, cache and cookies files inside the same directory mounted to /config along with the configuration file.
Usage
Downloads can be triggered by supplying the {{url}} of the requested video through the web UI or through the REST interface via curl, etc.
Web UI
Just navigate to http://{{host}}:9080/gallery-dl and enter the requested {{url}}.
Curl
curl -X POST --data-urlencode "url={{url}}" http://{{host}}:9080/gallery-dl/q
Fetch
fetch(`http://${host}:9080/gallery-dl/q`, {
method: "POST",
body: new URLSearchParams({
url: url
})
});
Bookmarklet
The following bookmarklet can be used from the bookmarks bar to send the current page URL to the gallery-dl-server instance running on a particular host.
javascript:(function(){var url="http://${host}:9080/gallery-dl/q",newTab=window.open(url,"_blank"),f=newTab.document.createElement("form");f.action=url;f.method="POST";var i=newTab.document.createElement("input");i.name="url";i.type="hidden";i.value=window.location.href;f.appendChild(i);newTab.document.body.appendChild(f);f.submit();})();
Implementation
This service operates using the ASGI web server uvicorn and is built on the starlette ASGI framework.
Downloads are handled by gallery-dl in conjunction with yt-dlp. The integration with gallery-dl uses Python as discussed in this issue. For video downloads, gallery-dl imports and uses yt-dlp.
The Docker image is based on python:3.12-alpine, which in turn is based on alpine.
Useful Links
gallery-dl
- Documentation: gallery-dl/README.rst
- Config file outline: gallery-dl/wiki/config-file-outline
- Configuration options: gallery-dl/docs/configuration.rst
- List of supported sites: gallery-dl/docs/supportedsites.md
yt-dlp
- Documentation: yt-dlp/README.md
- List of supported sites: yt-dlp/supportedsites.md
- List of extractors: yt-dlp/yt_dlp/extractor/_extractors.py
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gallery_dl_server-0.7.2.tar.gz.
File metadata
- Download URL: gallery_dl_server-0.7.2.tar.gz
- Upload date:
- Size: 160.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14a12df1aaa95bed3c13b53ba1f84b2d6adec8b3bf707ce6f06ca3635390b6ae
|
|
| MD5 |
2e4a9990351f62a93eb150ab740596b5
|
|
| BLAKE2b-256 |
0ae2cd97f710ee573f29bd820a53015c7abc804eaca216a31bab1c71c01863f9
|
File details
Details for the file gallery_dl_server-0.7.2-py3-none-any.whl.
File metadata
- Download URL: gallery_dl_server-0.7.2-py3-none-any.whl
- Upload date:
- Size: 147.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8876e706bef1471772a34b9d6b2affb717ad712378e8e7c2cd3402ef9a654445
|
|
| MD5 |
44e72709bc9e9fc5f345a1ee5278f015
|
|
| BLAKE2b-256 |
b36373a1021d5a50eb48bff9e3193a755cea9a4b73869e2b5d530a880c1a8cab
|