📺 IPTV Need help for Xtream Code which has over 40K+ channels

Python:
#!/usr/bin/env python3
import requests
import re
import sys

USERNAME = "1ARbE2L7ak"
PASSWORD = "ezfQtdrB3J"
PANEL_URL = "http://cchelp.xyz:826"
OUTPUT_FILE = "iptv_safe_playlist.m3u"

def sanitize(text):
    """Safely clean up channel names and categories."""
    text = re.sub(r'[#\s]+$', '', str(text).strip())
    return re.sub(r'[\\/*?:"<>|]', "", text)

def main():
    print("Fetching live categories...")
    cat_resp = requests.get(f"{PANEL_URL}/player_api.php", params={
        "username": USERNAME, "password": PASSWORD, "action": "get_live_categories"
    }, timeout=15)
    cat_resp.raise_for_status()
    categories = {str(cat["category_id"]): sanitize(cat["category_name"]) for cat in cat_resp.json()}

    print("Fetching live streams...")
    stream_resp = requests.get(f"{PANEL_URL}/player_api.php", params={
        "username": USERNAME, "password": PASSWORD, "action": "get_live_streams"
    }, timeout=15)
    stream_resp.raise_for_status()
    streams = stream_resp.json()

    print(f"Found {len(streams)} channels. Generating safe M3U...")
    m3u_lines = ["#EXTM3U"]
    for stream in streams:
        name = sanitize(stream["name"])
        group = categories.get(str(stream.get("category_id")), "General")
        stream_url = f"{PANEL_URL}/live/{USERNAME}/{PASSWORD}/{stream['stream_id']}.ts"
        m3u_lines.append(f'#EXTINF:-1 group-title="{group}",{name}')
        m3u_lines.append(stream_url)

    with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
        f.write("\n".join(m3u_lines))

    print(f"Success! Clean playlist saved as {OUTPUT_FILE}")

if __name__ == "__main__":
    try:
        main()
    except Exception as e:
        print(f"Error: {e}")
        sys.exit(1)

here is the code to get the m3u playlist from xtream code
 

About this Thread

  • 5
    Replies
  • 128
    Views
  • 2
    Participants
Last reply from:
thbuihp

Trending Topics

Online now

Members online
1,189
Guests online
2,053
Total visitors
3,242

Forum statistics

Threads
2,286,140
Posts
29,035,896
Members
1,217,806
Latest member
abihikari1
Back
Top