import sys
import subprocess
import importlib
import os
import asyncio
REQUIRED_MODULES = [
"requests",
"json",
"aiohttp",
"tqdm",
]
def ensure_modules_installed():
for module in REQUIRED_MODULES:
try:
importlib.import_module(module)
except ModuleNotFoundError:
print(f"\033[93mInstalling missing module: {module}\033[0m")
subprocess.check_call([sys.executable, "-m", "pip", "install", module])
ensure_modules_installed()
import requests
import json
from datetime import datetime
from urllib.parse import urlparse, quote
import base64
from typing import Dict, Optional, Any, List, Tuple
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor, as_completed
import group
import list as list_script
import series
import vod
def print_colored(text: str, color: str = "cyan") -> None:
colors = {
"green": "\033[92m",
"red": "\033[91m",
"blue": "\033[94m",
"yellow": "\033[93m",
"cyan": "\033[96m",
"magenta": "\033[95m",
"reset": "\033[0m",
}
color_code = colors.get(color.lower(), colors["reset"])
print(f"{color_code}{text}{colors['reset']}")
def get_mac_address() -> str:
default_prefix = "00:1A:79:"
print_colored(f"Default MAC prefix: {default_prefix}", "yellow")
suffix = input("Enter remaining 3 bytes (e.g. 30:6F:DD): ").strip().upper()
suffix = suffix.replace("-", ":")
if len(suffix) == 6 and ":" not in suffix:
suffix = ":".join([suffix[i:i+2] for i in range(0, 6, 2)])
mac = (default_prefix + suffix).upper()
if not mac or len(mac) != 17:
print_colored("⚠ Invalid MAC format, using fallback 00:1A:79:00:00:00", "red")
mac = "00:1A:79:00:00:00"
print_colored(f"✅ Using MAC: {mac}", "green")
return mac
def main():
os.system("clear" if os.name != "nt" else "cls")
print_colored("───────────────────────────────────────────", "magenta")
print_colored(" PORTAL/MAC TO M3U ", "magenta")
print_colored("───────────────────────────────────────────\n", "magenta")
base_url = input("Enter IPTV base URL (e.g. http://123.45.67.89:8080): ").strip()
mac = get_mac_address()
while True:
print_colored("\nSelect an operation:", "yellow")
print(" [1] MAC Live Channels")
print(" [2] Extract M3U groups")
print(" [3] MAC Series / Shows")
print(" [4] MAC VOD Movies")
print(" [5] Exit")
choice = input("\nYour choice: ").strip()
if choice == "1":
try:
list_script.main(base_url, mac)
except Exception as e:
print_colored(f"Error in MAC Live list: {e}", "red")
elif choice == "2":
try:
group.main(base_url, mac)
except Exception as e:
print_colored(f"Error in M3U group extractor: {e}", "red")
elif choice == "3":
try:
asyncio.run(series.main(base_url, mac))
except Exception as e:
print_colored(f"Error in MAC Series: {e}", "red")
elif choice == "4":
try:
vod.main(base_url, mac)
except Exception as e:
print_colored(f"Error in MAC VOD: {e}", "red")
elif choice == "5":
print_colored("\nExiting... Goodbye!", "green")
sys.exit(0)
else:
print_colored("Invalid choice, please enter 1–5!", "red")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print_colored("\nInterrupted by user. Exiting...", "yellow")
sys.exit(0)