
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Web UI for gallery-dl
with support for downloading videos via yt-dlp
.
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
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.
By default, this service listens on port 9080. Any value can be used for the host port, but the CONTAINER_PORT
environment variable must 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
# More settings here...
instance-2:
image: qx6ghqkz/gallery-dl-server:latest
container_name: night
environment:
- "CONTAINER_PORT=9090"
depends_on:
- gluetun
network_mode: service:gluetun
# More settings here...
gluetun:
image: qmcgaw/gluetun:latest
container_name: vpn
ports:
# instance-1
- "9080:9080"
# instance-2
- "9090:9090"
# More settings here...
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-directory
in 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-dl
instead (not recommended).
The environment variables UID
and GID
can 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 default UID:GID
is 1000:1000
when left unspecified.
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.
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 --help
. These arguments can also be provided as environment variables.
Installation allows running directly from the command line via the command gallery-dl-server
. Using a virtual environment is recommended to avoid dependency conflicts.
From PyPI:
pip install gallery-dl-server
With optional dependencies:
pip install gallery-dl-server[full]
From source code (perform command in the root of the repository):
pip install .
With optional dependencies:
pip install .[full]
Once installed, perform gallery-dl-server --help
to view the list of command-line options.
When installed, the log file is created directly in the home directory of the user, unless the package is found in the current working directory, in which case it is created in a logs
folder in the same directory.
import gallery_dl_server as server
server.run(host="0.0.0.0", port=9080, log_level="info")
The run()
method needs to be guarded with an if __name__ == "__main__"
block on Windows due to how multiprocessing works.
python3 -m uvicorn gallery_dl_server.server:app --host "0.0.0.0" --port "9080" --log-level "info" --no-access-log
On Windows, the program can be run using the prebuilt .exe
file, which includes a Python interpreter and the required Python packages. Prebuilt executables for each release can be found in Releases.
The executable can be run from the command line with the same arguments as the Python package.
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.
The server can be configured with numerous command-line arguments and environment variables. Command-line arguments take precedence over their equivalent environment variables.
Use the arguments when running the server directly from the command line, and the environment variables for configuring the server inside running containers.
Command-Line Argument | Environment Variable | Docker Only | Type | Expected Values | Default Value | Description |
---|---|---|---|---|---|---|
‑‑host | HOST | ✗ | str | IP address or hostname | 0.0.0.0 | Specify the host address |
‑‑port | PORT | ✗ | int | 0–65535 | 0 | Specify the port to run the app |
CONTAINER_PORT | ✓ | int | 0–65535 | 9080 | Set the internal container port | |
— | UID | ✓ | int | Any valid user ID | 1000 | User ID to run the server process |
— | GID | ✓ | int | Any valid group ID | 1000 | Group ID to run the server process |
— | UMASK | ✓ | int | Any valid umask value | 022 | Set umask for file permissions |
‑‑log‑dir | LOG_DIR | ✗ | str | Any existing directory | ~ | Set the log file directory |
‑‑log‑level | LOG_LEVEL | ✗ | str | critical error warning info debug | info | Set the download log level |
‑‑server‑log‑level | SERVER_LOG_LEVEL | ✗ | str | critical error warning info debug trace | info | Set the server log level |
‑‑access‑log | ACCESS_LOG | ✗ | bool | true false | false | Enable the server access log |
Note: CONTAINER_PORT
takes precedence over the PORT
environment variable in Docker containers to set the port the server will run on internally. This value and HOST
should not normally need to be changed from their default values for Docker running.
All required and optional Python and non-Python dependencies are included in the Docker image, however if you are running gallery-dl-server using any of the other methods, 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 are included in the standalone executable and do not need to be installed.
Installation with pip
only installs the required dependencies by default. Install gallery-dl-server[full]
for the optional dependencies.
brotli
or brotlicffi
: Brotli content encoding supportmutagen
: embed metadata and thumbnails in certain formatspycryptodomex
: decrypt AES-128 HLS streams and other forms of datapyyaml
: YAML configuration file supporttoml
: TOML configuration file support (<= Python 3.10 only)Non-Python dependencies must be installed separately. 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.
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 inside the directory mounted to /config
inside the container.
/config/gallery-dl.{conf, toml, yaml, yml}
/config/config.{json, toml, yaml, yml}
A default configuration file for use with gallery-dl-server will automatically be placed in the directory mounted to /config
if none are found.
For more information on configuration file options, see gallery-dl/docs/configuration.rst.
Any additional locations specified in the configuration file must also exist in the Docker container. For example, if a cookies file is required, ensure it is also mounted inside the Docker container.
It is easiest to place any additional files inside the same directory as the configuration file.
Downloads can be triggered by supplying the {{url}}
of the requested video through the web UI or through the REST interface via curl, etc.
Navigate to http://{{host}}:{{port}}/gallery-dl
and enter the requested {{url}}
.
curl -X POST --data-urlencode "url={{url}}" http://{{host}}:{{port}}/gallery-dl/q
fetch(`http://${host}:${port}/gallery-dl/q`, {
method: "POST",
body: new URLSearchParams({
url: url
})
});
The following bookmarklet can be used from the bookmarks bar to send the current page URL to a gallery-dl-server instance.
javascript:(function(){var url="http://${host}:${port}/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();})();
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
.
FAQs
Web UI for downloading media with gallery-dl and yt-dlp.
We found that gallery-dl-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.