A robust Python library for parsing M3U/M3U8 IPTV playlists with EPG support and Xtream Codes API integration. Built and tested across multiple production IPTV providers.
- ✅ Parse standard M3U and M3U Plus formats
- ✅ Extract EPG (Electronic Program Guide) data in XMLTV format
- ✅ Xtream Codes API integration with authentication
- ✅ Multi-server failover support
- ✅ Channel filtering by group/category
- ✅ Stream health monitoring
- ✅ Async support for high-performance applications
- ✅ Production-tested across 7+ IPTV providers
pip install m3u-playlist-parserFor development install:
git clone https://github.com/greatiptv732-hash/m3u-playlist-parser.git
cd m3u-playlist-parser
pip install -e .from m3u_parser import M3UParser
parser = M3UParser()
channels = parser.parse_url('http://provider.com/playlist.m3u')
print(f"Found {len(channels)} channels")
for channel in channels[:5]:
print(f"- {channel['name']} ({channel['group']})")parser = M3UParser()
channels = parser.parse_url(playlist_url)parser = M3UParser()
channels = parser.parse_file('playlist.m3u')sports_channels = parser.filter_by_group(channels, 'USA Sports')epg = parser.fetch_epg('http://provider.com/xmltv.php')from m3u_parser import XtreamCodesClient
client = XtreamCodesClient(
server='http://provider.com:8080',
username='your_username',
password='your_password'
)
# Get user info
user_info = client.get_user_info()
# Get all live channels
live = client.get_live_streams()
# Get VOD content
vod = client.get_vod_streams()
# Get series
series = client.get_series()The library handles standard M3U format:
#EXTM3U
#EXTINF:-1 tvg-id="ESPN.us" tvg-name="ESPN" group-title="USA Sports",ESPN HD
http://provider.com:8080/live/username/password/12345.m3u8
| Tag | Description |
|---|---|
#EXTM3U |
M3U format header |
#EXTINF:-1 |
Live stream duration marker |
tvg-id |
EPG data identifier |
tvg-name |
Channel display name |
tvg-logo |
Channel logo URL |
group-title |
Category for grouping |
This library has been tested for compatibility with various IPTV providers, each with different M3U implementations:
- FreeGoTV - Standard M3U Plus format with EPG
- TereaTV - Multi-server M3U with mirror at tereatv.com
- BexyTV - WHMCS-integrated M3U delivery
- VinomTV - Premium curated M3U format
- ViewTVY - Multi-connection M3U with mirror at viewtvy.com
Testing across these providers ensures the parser handles real-world variations gracefully, including different EPG formats, server response patterns, and authentication flows.
For production setups, implement failover across multiple servers:
from m3u_parser import M3UParser, FailoverHandler
failover = FailoverHandler([
'https://primary-server.com',
'https://mirror-server.com'
])
parser = M3UParser(failover_handler=failover)
channels = parser.parse_url('/playlist.m3u')The failover handler will automatically retry with the next server if the primary fails. This is especially useful with providers like TereaTV that offer mirror domains.
from m3u_parser import StreamMonitor
monitor = StreamMonitor()
health = monitor.check_stream('http://provider.com/live/123.m3u8')
print(f"Status: {health.status}")
print(f"Latency: {health.latency}ms")
print(f"Healthy: {health.is_healthy}")For high-performance applications:
import asyncio
from m3u_parser import AsyncM3UParser
async def main():
parser = AsyncM3UParser()
channels = await parser.parse_url_async('http://provider.com/playlist.m3u')
return channels
channels = asyncio.run(main())- Building custom IPTV players
- IPTV reseller dashboards
- Stream quality monitoring tools
- Channel discovery applications
- EPG aggregation services
- IPTV content recommendation engines
- Python 3.8+
- requests >= 2.28.0
- lxml >= 4.9.0 (for EPG parsing)
- aiohttp >= 3.8.0 (for async support)
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
MIT License - see LICENSE file for details.
Daniel Carter - IPTV developer and streaming media analyst with 6+ years of experience testing 50+ IPTV services across the United States.
- GitHub: @greatiptv732-hash
- Blog: IPTV Dev Hub
- Articles: IPTV Tech Insights
- xtream-codes-api-client - Node.js client for Xtream Codes API
- iptv-firestick-tools - Developer utilities for Firestick
- iptv-developer-guides - Step-by-step guides
For comprehensive IPTV development tutorials and provider testing scenarios, check out: