Universal IPTV playlist extractor with multi-method support and intelligent caching
Features • Installation • Usage • Configuration • Documentation
Author: runawaydevil | Contact: runawaydevil@pm.me | Version: 0.01
MasterIPTV is a universal IPTV playlist extractor that supports multiple extraction methods including Xtream Codes API and direct URL downloads. Built with efficiency in mind, it features persistent caching, parallel processing, and robust error handling for reliable playlist management.
- Multi-Method Support: Xtream Codes API and direct URL extraction
- Persistent Caching: JSON-based cache system for rapid updates
- Parallel Processing: Multi-threaded extraction for optimal performance
- Interrupt Protection: Safe Ctrl+C handling with automatic cache preservation
- Auto-Retry Logic: Automatic retry on temporary failures
- Connection Testing: Pre-extraction connectivity validation
- Multiple Providers: Support for unlimited provider configurations
- Zero-dependency core (requests only)
- Optional Cloudflare bypass support
- Thread-safe operations
- Comprehensive logging
- Cross-platform compatibility (Windows, Linux, macOS)
The Xtream Codes method extracts playlists by category, enabling:
- Granular cache management per category
- Parallel category processing
- Incremental updates (only changed categories are re-downloaded)
- Significantly faster subsequent executions
Performance:
- Initial extraction: 30-60 minutes (large playlists)
- Cached updates: 30 seconds
Traditional M3U download via direct URL:
- Simple HTTP(S) download
- Cloudflare bypass support (with cloudscraper)
- Suitable for providers without API access
- Python 3.7 or higher
- pip package manager
Required:
pip install requestsOptional (for Cloudflare bypass):
pip install cloudscrapergit clone https://github.com/runawaydevil/masteriptv.git
cd masteriptvEdit masteriptv.py and configure the PROVIDERS dictionary:
PROVIDERS = {
'provider_name': {
'name': 'Provider Display Name',
'method': 'xtream', # or 'url'
# Xtream Codes configuration
'base_url': 'http://server.example.com',
'username': 'your_username',
'password': 'your_password',
# Direct URL configuration
'url': 'http://server.example.com/playlist.m3u',
'enabled': True
}
}Standard execution (uses cache):
python masteriptv.pyForce full refresh:
python masteriptv.py --forceGenerated M3U files are saved to the output/ directory:
output/
└── provider_name_20260125_120000.m3u
OUTPUT_DIR = 'output' # Output directory for M3U files
CACHE_DIR = 'cache' # Cache storage directory
MAX_WORKERS = 8 # Parallel threads (Xtream method)
TIMEOUT = 45 # Request timeout in secondsPROVIDERS = {
'primary': {
'name': 'Primary Provider',
'method': 'xtream',
'base_url': 'http://primary.example.com',
'username': 'user1',
'password': 'pass1',
'enabled': True
},
'backup': {
'name': 'Backup Provider',
'method': 'url',
'url': 'http://backup.example.com/playlist.m3u',
'enabled': True
},
'disabled': {
'name': 'Disabled Provider',
'method': 'xtream',
'base_url': 'http://old.example.com',
'username': 'user3',
'password': 'pass3',
'enabled': False
}
}The Xtream method implements a persistent JSON cache:
Structure:
cache/
└── cache_<hash>.json
Behavior:
- Automatic save every 10 requests
- Automatic save on Ctrl+C interrupt
- Automatic save on error conditions
- Per-provider cache isolation via hash
View cache:
ls cache/Clear cache:
# Windows
rmdir /s /q cache
# Linux/macOS
rm -rf cacheForce refresh:
python masteriptv.py --forceThe application implements safe interrupt handling:
Ctrl+C behavior:
- Immediate processing halt
- Automatic cache persistence
- Progress statistics display
- Clean exit
Example output:
WARNING: INTERRUPT DETECTED (Ctrl+C)
======================================================================
Saving cache before exit...
Cache saved successfully: cache/cache_a1b2c3d4.json
Categories cached: 150
Next execution will resume from checkpoint.
======================================================================
Exiting...
======================================================================
======================================================================
MasterIPTV - Universal IPTV List Extractor
Version 0.01 by runawaydevil
GitHub: https://github.com/runawaydevil
======================================================================
Press Ctrl+C at any time to safely stop execution
======================================================================
======================================================================
PROVIDER: Primary Provider
======================================================================
Method: Xtream Codes API (with cache)
Testing connection to Xtream server...
Connection successful!
Status: Active
Expires: 2026-12-31
PHASE 1: Fetching categories...
150 live TV categories
400 VOD categories
50 series categories
PHASE 2: Fetching streams in parallel...
Fetching live streams from 150 categories...
120/150 categories already cached
BR - MOVIES: 450 items
Progress: 150/150 categories processed
Total: 15000 live streams found
PHASE 3: Building M3U file...
Processing 15000 live channels...
Processing 50000 VOD items...
Processing 5000 series...
M3U created: output/primary_20260125_120000.m3u
Total entries: 70000
Execution time: 1850.5s (30.8 min)
======================================================================
FINAL SUMMARY
======================================================================
Primary Provider: SUCCESS
Method: xtream
File: output/primary_20260125_120000.m3u
Entries: 70,000
======================================================================
COMPLETED
======================================================================
Xtream Codes detection:
Access: http://your-server.com/player_api.php?username=xxx&password=xxx
If the response is JSON containing user information, the provider supports Xtream Codes API.
Method selection:
- Use
xtreamfor API-enabled providers (faster, cached) - Use
urlfor direct M3U URLs (simpler, no cache)
Xtream Method:
- First execution: 30-60 minutes (large playlists)
- Subsequent executions: 30 seconds (with cache)
- Network requests: 400-500 (first run), 5-10 (cached)
- Bandwidth: 50-100 MB (first run), 1-5 MB (cached)
URL Method:
- Execution time: 2-5 minutes
- Network requests: 1
- Bandwidth: Varies by playlist size
Connection errors:
- Verify credentials
- Test server accessibility
- Check provider status
- Retry after delay
Timeout errors: Increase timeout in configuration:
TIMEOUT = 90 # Increase to 90 secondsConnection pool warnings: Reduce worker threads:
MAX_WORKERS = 5 # Reduce from 8 to 5Cache corruption:
# Clear cache
rm -rf cache/
# Or force refresh
python masteriptv.py --forceImport errors:
# Install required dependencies
pip install requests
# Optional: Cloudflare bypass
pip install cloudscraper- Python 3.7+
- 100MB free disk space (cache)
- Network connectivity
- requests (required)
- cloudscraper (optional)
- Windows 7/8/10/11
- Linux (all distributions)
- macOS 10.12+
MIT License - see LICENSE for details.
Copyright (c) 2026 runawaydevil
runawaydevil
- GitHub: @runawaydevil
- Email: runawaydevil@pm.me
Contributions are welcome. Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/enhancement) - Commit changes (
git commit -am 'Add enhancement') - Push to branch (
git push origin feature/enhancement) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
- Python Software Foundation
- requests library maintainers
- cloudscraper contributors
- Open source community
This software is provided for educational purposes only. Use of IPTV playlists must comply with local laws and provider terms of service. The author assumes no responsibility for misuse of this software.
Version 0.01 | Report Bug | Request Feature
Copyright (c) 2026 runawaydevil | Licensed under MIT