Najeebsk

IPTV-CHECK-LIVE.py

Feb 27th, 2024 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.32 KB | None | 0 0
  1. import tkinter as tk
  2. from tkinter import filedialog, messagebox, Scrollbar
  3. import concurrent.futures
  4. import requests
  5. import subprocess
  6.  
  7. def check_url(url):
  8.     try:
  9.         response = requests.get(url, timeout=2)
  10.         if response.status_code == 200:
  11.             return url, True
  12.     except Exception as e:
  13.         pass
  14.     return url, False
  15.  
  16. def check_playlist():
  17.     filepath = filedialog.askopenfilename(filetypes=[("M3U files", "*.m3u"), ("M3U8 files", "*.m3u8")])
  18.     if filepath:
  19.         working_urls = {}
  20.         working_links = []
  21.         group_counter = 1  # Initialize group title counter
  22.         with open(filepath, 'r', encoding='utf-8') as file:
  23.             urls = [line.strip() for line in file if line.startswith('http')]
  24.  
  25.         with concurrent.futures.ThreadPoolExecutor() as executor:
  26.             results = executor.map(check_url, urls)
  27.             for url, status in results:
  28.                 working_urls[url] = status
  29.                 if status:
  30.                     working_links.append(url)
  31.  
  32.         for url in urls:
  33.             status = "Working" if working_urls.get(url) else "Not Working"
  34.             listbox.insert(tk.END, f"{url} - {status}")
  35.  
  36.         # Write working links with proper M3U8 format
  37.         with open("PLAYLIST.m3u8", "w") as new_file:
  38.             new_file.write("#EXTM3U\n")
  39.             for link in working_links:
  40.                 group_title = f"Your Group Title-{group_counter}"
  41.                 new_file.write(f"#EXTINF:-1 group-title=\"{group_title}\"\n{link}\n")
  42.                 group_counter += 1  # Increment group title counter
  43.  
  44.         # Display working links in the second text area
  45.         for link in working_links:
  46.             working_links_text.insert(tk.END, link + '\n')
  47.  
  48. def copy_selected_url(event):
  49.     selected_index = listbox.curselection()
  50.     if selected_index:
  51.         selected_url = listbox.get(selected_index)
  52.         root.clipboard_clear()
  53.         root.clipboard_append(selected_url.split(" - ")[0])
  54.         root.update()
  55.  
  56. def run_in_vlc(event):
  57.     selected_index = listbox.curselection()
  58.     if selected_index:
  59.         selected_url = listbox.get(selected_index)
  60.         url = selected_url.split(" - ")[0]
  61.         vlc_path = r"C:\Program Files\VideoLAN\VLC\vlc.exe"
  62.         try:
  63.             subprocess.Popen([vlc_path, url])
  64.         except FileNotFoundError:
  65.             messagebox.showerror("Error", "VLC player not found. Please check the installation path.")
  66.  
  67. root = tk.Tk()
  68. root.config(bg='green')
  69. root.title("NAJEEB IPTV M3U URL CHECKER")
  70.  
  71. check_button = tk.Button(root, text="Check Playlist", command=check_playlist)
  72. check_button.pack(pady=10)
  73.  
  74. scrollbar = Scrollbar(root, orient=tk.VERTICAL)
  75. scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
  76.  
  77. listbox = tk.Listbox(root, width=150, height=15, yscrollcommand=scrollbar.set)
  78. listbox.pack(padx=10, pady=10)
  79.  
  80. scrollbar.config(command=listbox.yview)
  81.  
  82. listbox.bind("<Double-Button-1>", run_in_vlc)
  83. listbox.bind("<Button-3>", copy_selected_url)
  84.  
  85. # New text field to display working links
  86. working_scrollbar = Scrollbar(root, orient=tk.VERTICAL)
  87. working_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
  88.  
  89. working_links_text = tk.Text(root, width=110, height=15, yscrollcommand=working_scrollbar.set)
  90. working_links_text.pack(pady=10)
  91.  
  92. working_scrollbar.config(command=working_links_text.yview)
  93.  
  94. root.mainloop()
  95.  
Add Comment
Please, Sign In to add comment