Media Filters
Complete guide to filtering media files during download.
Overview
tgdl supports filtering by: - Media type (photos, videos, audio, documents) - File size (min/max) - Message ID range (min/max) - Download limit (first N files)
Media Type Filters
Available Types
| Flag | Type | Includes |
|---|---|---|
-p or --photos |
Photos | JPG, PNG, WebP images |
-v or --videos |
Videos | MP4, MKV, AVI, MOV files |
-a or --audio |
Audio | MP3, M4A, OGG, FLAC files |
-d or --documents |
Documents | PDF, ZIP, TXT, any file type |
Document Type
Documents include ALL file types that aren't photos, videos, or audio. This includes PDFs, ZIPs, APKs, executables, archives, etc.
Single Type
# Photos only
tgdl download -c 1234567890 -p
# Videos only
tgdl download -c 1234567890 -v
# Audio only
tgdl download -c 1234567890 -a
# Documents only
tgdl download -c 1234567890 -d
Multiple Types
# Photos and videos
tgdl download -c 1234567890 -p -v
# Audio and documents
tgdl download -c 1234567890 -a -d
# Everything except videos
tgdl download -c 1234567890 -p -a -d
# Everything (no filter)
tgdl download -c 1234567890
Type Examples
Download Profile Pictures
Video Archive
Music Collection
Software/APKs
File Size Filters
Size Units
Supported units:
- B - Bytes
- KB - Kilobytes (1024 B)
- MB - Megabytes (1024 KB)
- GB - Gigabytes (1024 MB)
- TB - Terabytes (1024 GB)
Case Sensitive
Use uppercase: MB not mb
Maximum Size
# Max 10MB
tgdl download -c 1234567890 --max-size 10MB
# Max 100MB
tgdl download -c 1234567890 --max-size 100MB
# Max 1GB
tgdl download -c 1234567890 --max-size 1GB
Use cases: - Limited storage space - Bandwidth concerns - Quick downloads only - Filter out large videos
Minimum Size
# Min 1MB (skip small files)
tgdl download -c 1234567890 --min-size 1MB
# Min 10MB (only large files)
tgdl download -c 1234567890 --min-size 10MB
# Min 100MB (very large files only)
tgdl download -c 1234567890 --min-size 100MB
Use cases: - Skip thumbnails/previews - High quality content only - Avoid compressed versions
Size Range
# Between 1MB and 100MB
tgdl download -c 1234567890 --min-size 1MB --max-size 100MB
# Between 10MB and 1GB
tgdl download -c 1234567890 --min-size 10MB --max-size 1GB
# Medium-sized files only (5-50MB)
tgdl download -c 1234567890 --min-size 5MB --max-size 50MB
Use cases: - Specific quality range - Storage budget - Network limitations
Size Examples
Quick Download (Small Files)
Skip Previews
Storage Budget
High Quality Videos
Avoid Huge Files
Message ID Filters
Basics
Message IDs are sequential numbers assigned by Telegram.
Minimum ID
# From message 100 onwards
tgdl download -c 1234567890 --min-id 100
# Recent messages only (if latest is 1000)
tgdl download -c 1234567890 --min-id 900
Use cases: - Skip old content - Get recent additions - Resume from specific point
Maximum ID
# Up to message 100
tgdl download -c 1234567890 --max-id 100
# First 50 messages
tgdl download -c 1234567890 --max-id 50
Use cases: - Get old content only - Archive historical messages - Stop at specific point
ID Range
# Messages 100-200
tgdl download -c 1234567890 --min-id 100 --max-id 200
# Specific section (500-600)
tgdl download -c 1234567890 --min-id 500 --max-id 600
# Single message
tgdl download -c 1234567890 --min-id 12345 --max-id 12345
Use cases: - Download specific period - Re-download failed range - Targeted backup
Finding Message IDs
Method 1: Telegram Desktop
1. Right-click message
2. "Copy Message Link"
3. Link format: https://t.me/channel/12345
4. Last number is message ID
Method 2: From Downloads
# Filename is message_id.extension
ls downloads/entity_1234567890/
# Output: 12345.jpg, 12346.mp4, etc.
Method 3: Use download-link
# Download single message to see its ID
tgdl download-link https://t.me/channel/12345
# Downloads 12345.ext
ID Filter Examples
Archive Old Content
Get Recent Updates
Re-download Failed Range
Monthly Archives
# January messages (1-1000)
tgdl download -c 1234567890 --min-id 1 --max-id 1000 -o ~/Archives/Jan
# February messages (1001-2000)
tgdl download -c 1234567890 --min-id 1001 --max-id 2000 -o ~/Archives/Feb
Download Limit
Limit Count
# First 10 files
tgdl download -c 1234567890 --limit 10
# First 50 files
tgdl download -c 1234567890 --limit 50
# First 100 files
tgdl download -c 1234567890 --limit 100
How Limit Works
Limit applies AFTER all other filters:
- Filter by message ID range
- Filter by media type
- Filter by file size
- Apply limit to remaining files
Limit Examples
Quick Preview
Test Filters
Storage Budget
Sample Collection
Combining Filters
Filter Execution Order
- Message ID range - Which messages to consider
- Media type - Filter by photo/video/audio/document
- File size - Filter by size constraints
- Limit - Take first N after all filters
Common Combinations
Small Photos Only
Recent Large Videos
Limited Music Collection
Specific Range, Specific Type
# Messages 100-200, videos only, under 50MB
tgdl download -c 1234567890 --min-id 100 --max-id 200 -v --max-size 50MB
Everything Except Large Videos
# Photos, audio, documents, and small videos
tgdl download -c 1234567890 -p -a -d
tgdl download -c 1234567890 -v --max-size 10MB
Complex Filter Examples
High-Quality Recent Videos
# Last 100 messages, videos, 50-500MB (HD quality)
tgdl download -c 1234567890 \
--min-id 1900 \
-v \
--min-size 50MB \
--max-size 500MB \
--limit 20
Quick Photo Gallery
# First 50 photos under 2MB
tgdl download -c 1234567890 \
-p \
--max-size 2MB \
--limit 50 \
-o ~/Pictures/Gallery
Document Archive (No Large Files)
# All documents under 100MB
tgdl download -c 1234567890 \
-d \
--max-size 100MB \
-o ~/Documents/Archive
Music Playlist
# 100 audio files, 2-10MB each
tgdl download -c 1234567890 \
-a \
--min-size 2MB \
--max-size 10MB \
--limit 100 \
-o ~/Music/Telegram
Filter Performance
Fast Filters
These are checked before download: - Message ID range - Media type - File size
Result: Very fast, no bandwidth wasted
Example
Process: 1. Fetch message list (fast) 2. Filter: Keep only video messages 3. Filter: Check size (from message metadata) 4. Download only matching files
Advantage: Doesn't download files to check size!
Filter Tips
1. Start Broad, Then Narrow
Iterative Filtering
2. Use Limit for Testing
Test First
3. Combine Size and Type
Precision Filtering
4. Use Range for Updates
Incremental Downloads
5. Budget Your Storage
Calculate Before Downloading
Filter Troubleshooting
No Files Downloaded
Symptom:
Possible causes:
-
Filters too restrictive
-
No media in range
-
Wrong media type
-
Size constraint too strict
Unexpected File Types
Symptom: Got documents instead of videos
Cause: Telegram categorization
Solution:
# Be explicit with type
tgdl download -c 1234567890 -v # Videos only
# Or check media info
tgdl download -c 1234567890 --limit 1
ls -lh downloads/entity_1234567890/
Size Limit Not Working
Symptom: Downloaded files larger than max-size
Cause: Size in message metadata may differ slightly
Note: tgdl uses size from Telegram's metadata, which is usually accurate but may have small variations.
Filter Reference
Quick Reference Table
| Filter | Flag | Example | Effect |
|---|---|---|---|
| Photos | -p |
tgdl download -c ID -p |
Only photos |
| Videos | -v |
tgdl download -c ID -v |
Only videos |
| Audio | -a |
tgdl download -c ID -a |
Only audio |
| Documents | -d |
tgdl download -c ID -d |
Only documents |
| Max Size | --max-size |
--max-size 100MB |
Files ≤ 100MB |
| Min Size | --min-size |
--min-size 10MB |
Files ≥ 10MB |
| Min ID | --min-id |
--min-id 100 |
Messages ≥ 100 |
| Max ID | --max-id |
--max-id 200 |
Messages ≤ 200 |
| Limit | --limit |
--limit 50 |
First 50 files |
Filter Combinations
# Template
tgdl download \
-c|g|b ID \
[-p] [-v] [-a] [-d] \
[--min-size SIZE] [--max-size SIZE] \
[--min-id ID] [--max-id ID] \
[--limit N]
Examples:
# Photos under 5MB, first 20
tgdl download -c 1234567890 -p --max-size 5MB --limit 20
# Videos in range, 10-100MB
tgdl download -c 1234567890 -v --min-id 100 --max-id 200 --min-size 10MB --max-size 100MB
# Everything except videos, under 50MB
tgdl download -c 1234567890 -p -a -d --max-size 50MB