safiyu/telefetchr

By safiyu

Updated 4 months ago

A lightweight self hosted telegram files download application with interactive web ui.

Image
Message queues
Content management system
1

5.4K

safiyu/telefetchr repository overview

Telefetchr (Telegram file downloader)

Prerequisites

  • Docker installed on your system
  • Docker Compose installed (usually comes with Docker Desktop)
  • Telegram API credentials (api_id and api_hash from https://my.telegram.org)

Docker compose

services:
  telefetchr:
    image: safiyu/telefetchr:latest
    container_name: telefetchr
    ports:
      - "8000:8000"
    volumes:
      - /path/to/sessions:/app/sessions
      - /path/to/downloads:/app/downloads
    environment:
      - PYTHONUNBUFFERED=1
      - CHANNELS=@copyrighten_bot,@CinemaPranthan_Bot
      - API_ID=29093411
      - API_HASH=eeafc638a054078a8e6247c3bc307721
      - PHONE_NUMBER=33661120838
      - MAX_CONCURRENT_DOWNLOADS=3
    restart: always

Environment Variables (MANDATORY):

environment:
      - PYTHONUNBUFFERED=1
      - CHANNELS=@cop_bot,@Cin_Bot # comma separated list of channels
      - API_ID=12345 # your api_id from my.telegram.org
      - API_HASH=saasdasdf12324 # your api_hash from my.telegram.org
      - PHONE_NUMBER=12345 # without + sign
      - MAX_CONCURRENT_DOWNLOADS=3 # optional, default is 3

Accessing the Application

Once the container is running, open your browser and navigate to:

http://localhost:8000

First Time Login

  1. The application will prompt you to login
  2. Click "Send Verification Code"
  3. Enter the code you receive via Telegram
  4. If you have 2FA enabled, enter your password
  5. The session will be saved in the sessions/ directory

Persistent Data

  • Downloads: All downloaded files are stored in this path
  • Sessions: Telegram session files are stored in this path
  • Both directories are mounted as volumes, so data persists even if you restart or rebuild the container

Network Paths for Downloads

If you want to download files to a network location:

Linux/Mac:
# Mount network share first
sudo mount -t cifs //server/share /mnt/network -o username=user,password=pass

# Update docker-compose.yml to add volume:
volumes:
  - /mnt/network:/app/downloads
Windows:
# Map network drive first (e.g., Z:)
net use Z: \\server\share /user:username password

# Update docker-compose.yml:
volumes:
  - Z:/:/app/downloads

Build and Run Instructions

Examples for different systems:

Linux/macOS (NFS/SMB mount):

- /mnt/nas/downloads:/app/downloads

Windows (mapped network drive):

- Z:/downloads:/app/downloads

Windows (UNC path):

- //server/share/downloads:/app/downloads

Installation & Usage

Starting the Application
  1. Build and start the container:

    docker-compose up -d
    

    The -d flag runs the container in detached mode (background).

  2. Check if the container is running:

    docker-compose ps
    
  3. Access the application: Open your browser and navigate to:

    http://localhost:8000
    
Option 2: Using Docker directly
# Build the image
docker build -t telefetchr .

# Run the container
docker run -d \
  --name telefetchr \
  -p 8000:8000 \
  -v $(pwd)/downloads:/app/downloads \
  -v $(pwd)/sessions:/app/sessions \
  -e API_ID=123456 \
  -e API_HASH=abcdef123456 \
  -e CHANNELS=@news,@music,@movies \
  -e PHONE_NUMBER=1234567890 \
  -e MAX_CONCURRENT_DOWNLOADS=3 \
  telefetchr

# Run the container (windows)
docker run -d `
  --name telefetchr `
  -p 8000:8000 `
  -v ${PWD}/downloads:/app/downloads `
  -v ${PWD}/sessions:/app/sessions `
  -v ${PWD}/config.yaml:/app/config.yaml:ro `
  -e API_ID=123456 `
  -e API_HASH=abcdef123456 `
  -e CHANNELS=@news,@music,@movies `
  -e PHONE_NUMBER=1234567890 `
  -e MAX_CONCURRENT_DOWNLOADS=3 `
  telefetchr


# View logs
docker logs -f telefetchr

# Stop the container
docker stop telefetchr
docker rm telefetchr

Common Commands

View Logs

Follow logs in real-time:

docker-compose logs -f

View logs for specific service:

docker-compose logs -f telefetchr

View last 100 lines:

docker-compose logs --tail=100
Stop the Application

Stop containers (keeps data):

docker-compose stop

Stop and remove containers:

docker-compose down
Restart the Application
docker-compose restart
Rebuild After Code Changes

If you modify launch.py or other application files:

docker-compose up -d --build
Access Container Shell

To access the container's shell for debugging:

docker-compose exec telefetchr /bin/bash

Data Persistence

The following directories are mounted as volumes and will persist data:

  • Network Drive (configured in docker-compose.yml) - All downloaded files go directly to your network storage
  • sessions/ - Telegram session data (keeps you logged in)

Files are downloaded directly to your network drive location, so they're immediately available to other systems on your network.

Troubleshooting

Container Won't Start

Check logs:

docker-compose logs

Common issues:

  • Invalid API credentials
  • Port 8000 already in use
  • Permission issues with network drive
  • Path not set correctly
Port Already in Use

If port 8000 is already occupied, edit docker-compose.yml:

ports:
  - "8080:8000"  # Change 8080 to any available port

Then access the app at http://localhost:8080

Permission Issues

If you encounter permission issues with network drive access:

For Linux/macOS NFS mounts:

# Ensure the mount has correct permissions
sudo chmod 755 /mnt/your-network-drive

For Docker on Linux with network storage:

# Run container with specific user ID
docker-compose down

Then edit docker-compose.yml to add:

user: "1000:1000"  # Replace with your user:group ID

Check your user ID:

id -u  # Gets your user ID
id -g  # Gets your group ID
Reset Everything

To completely reset (warning: deletes all data):

docker-compose down -v
rm -rf downloads/* sessions/*
docker-compose up -d --build

Advanced Configuration

Mounting Network Drives
Linux - NFS Mount

First, mount your NFS share on the host:

# Install NFS client
sudo apt-get install nfs-common

# Create mount point
sudo mkdir -p /mnt/nas

# Mount NFS share
sudo mount -t nfs server.local:/share /mnt/nas

# Or add to /etc/fstab for automatic mounting:
echo "server.local:/share /mnt/nas nfs defaults 0 0" | sudo tee -a /etc/fstab

Then update docker-compose.yml:

volumes:
  - /mnt/nas:/app/downloads
Linux - SMB/CIFS Mount
# Install CIFS utilities
sudo apt-get install cifs-utils

# Create credentials file
sudo nano /etc/.smbcredentials
# Add:
# username=your_username
# password=your_password

# Set permissions
sudo chmod 600 /etc/.smbcredentials

# Mount SMB share
sudo mount -t cifs //server/share /mnt/nas -o credentials=/etc/.smbcredentials

# Or add to /etc/fstab:
echo "//server/share /mnt/nas cifs credentials=/etc/.smbcredentials 0 0" | sudo tee -a /etc/fstab
Windows - Network Drive

On Windows with Docker Desktop, use the full path:

volumes:
  - Z:/TelegramDownloads:/app/downloads  # If Z: is your mapped drive

Or use UNC path directly:

volumes:
  - //192.168.1.100/share/downloads:/app/downloads
macOS - Network Drive

Mount your network drive first, then:

volumes:
  - /Volumes/NetworkDrive/downloads:/app/downloads
Resource Limits

To limit container resources, add to docker-compose.yml:

services:
  telefetchr:
    # ... existing config ...
    deploy:
      resources:
        limits:
          cpus: '2'
          memory: 2G
        reservations:
          cpus: '1'
          memory: 512M

Updating the Application

  1. Pull the latest code changes
  2. Rebuild and restart:
    docker-compose down
    docker-compose up -d --build
    

Security Notes

  • The sessions/ directory contains sensitive authentication data
  • Use environment variables for sensitive data in production
  • Consider using Docker secrets for production deployments

License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:208b59298

Size

65.3 MB

Last updated

4 months ago

docker pull safiyu/telefetchr