Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Ignore VCS and editor cruft
.git
.gitignore

# Python build/test caches
__pycache__
*.pyc
.pytest_cache
build

# Local configs and sessions (mounted at runtime instead)
config.ini
*.session

10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,13 @@ cython_debug/

config.ini
*.session

*.mp4
*.mp3
*.jpeg
*.jpg
*.png
*.pdf
*.mov
*.webm
*.mkv
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM python:3.11-slim

# Prevent Python from writing .pyc files and enable unbuffered logs
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1

# System deps: none required for runtime; keep slim
WORKDIR /app

# Ensure readline is available for interactive prompts
RUN apt-get update \
&& apt-get install curl -y \
&& curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash \
&& apt-get install speedtest -y \
&& apt-get install -y --no-install-recommends libreadline8 \
&& rm -rf /var/lib/apt/lists/*

# Copy metadata first to leverage Docker layer caching
# Project metadata and helper scripts
COPY pyproject.toml README.md scripts /app/
# Optional samples and inputs
COPY .stuff /app/.stuff
COPY src /app/src

# Install the package so the `rcdtool` CLI entrypoint is available
RUN pip install --no-cache-dir .

# Use a dedicated working directory for user data (config, session, downloads)
WORKDIR /work

# Default command runs the CLI; pass args after image name
ENTRYPOINT ["rcdtool"]
CMD ["--help"]
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
SHELL := bash

# docker compose driven workflow
COMPOSE ?= docker compose
SERVICE ?= rcdtoold
IMG ?= rcdtool
NAME ?= rcdtoold
DATA_DIR ?= $(CURDIR)/data
# Avoid readonly UID in zsh; use HOST_* and pass as DOCKER_* to compose
HOST_UID := $(shell id -u 2>/dev/null || echo 1000)
HOST_GID := $(shell id -g 2>/dev/null || echo 1000)

.PHONY: build up up-nc down ps bash logs restart

build:
DOCKER_UID=$(HOST_UID) DOCKER_GID=$(HOST_GID) $(COMPOSE) build

up: ## Start long‑lived dev container with volumes
@mkdir -p "$(DATA_DIR)"
@if [ ! -f "$(DATA_DIR)/config.ini" ]; then cp -n config.ini.sample "$(DATA_DIR)/config.ini"; fi
DOCKER_UID=$(HOST_UID) DOCKER_GID=$(HOST_GID) $(COMPOSE) up -d
@$(COMPOSE) ps

down:
$(COMPOSE) down

bash:
$(COMPOSE) exec -w /work $(SERVICE) bash

restart:
$(COMPOSE) restart $(SERVICE)
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ api_id: 32767
api_hash: ed855a59bbe4a3360dbf7a0538842142
```

You might have problems with registering new app, consider following these advices: https://habr.com/ru/articles/923168/

Then rename `config.ini.sample` to `config.ini`, edit it and save wherever you want. If the file is in the same directory as `rcdtool` and its name is exactly "config.ini", then `rcdtool` will load it automatically.

The first time, **rcdtool** will ask you for your phone number, and will start a login process. When this is done, a `.session` file will be created. With this `.session` file, the tool could access to your Telegram account to read messages and download medias. The name of the .session file is set in `config.ini`.
Expand Down Expand Up @@ -91,3 +93,30 @@ rcdtool -c config.ini -C qwert -M 34 -O download/base --infer-extension
---

If you want to find a media in a comment on a channel post, use `--discussion-message-id` to set the message id of the comment.

## Docker

You can run this app inside a docker container, see Makefile


### Makefile shortcuts

Prefer one-liners via `make` (defaults include `--infer-extension` so files get a proper extension):

- Build and prepare:

```
make build
make setup
```

- Start a long‑lived container once, then exec commands inside it:

```
make up # builds image, prepares data/, runs container as a daemon
make shell # optional: drop into /work inside the container
```

```bash
docker exec -it -w /work rcdtoold python3 /app/rcdtool_from_messages.py --infer-extension -f /app/.stuff/messages.md -c /work/config.ini
```
18 changes: 18 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
services:
rcdtoold:
container_name: rcdtoold
build:
context: .
image: rcdtool
restart: unless-stopped
working_dir: /work
user: "${DOCKER_UID}:${DOCKER_GID}"
environment:
- PYTHONDONTWRITEBYTECODE=1
- PYTHONUNBUFFERED=1
# Helpful for running `python -m rcdtool.main` against mounted source
- PYTHONPATH=/app/src
volumes:
- ./data:/work
- .:/app
entrypoint: ["sh", "-c", "sleep infinity"]
11 changes: 10 additions & 1 deletion config.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ hash = [your API hash here]
[Client]
timeout = 7000
device_model = scriptgram
lang_code = es-ES
lang_code = en-US

; Optional performance tuning
; concurrent download workers (1..8 is sensible)
workers = 4
; chunk size per request in KiB (128, 256, 512, 1024)
part_size_kb = 512
; retry behavior for unstable networks
request_retries = 5
retry_delay = 2
connection_retries = 5
Loading