Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import filedialog, messagebox, Scrollbar
- import concurrent.futures
- import requests
- import subprocess
- def check_url(url):
- try:
- response = requests.get(url, timeout=2)
- if response.status_code == 200:
- return url, True
- except Exception as e:
- pass
- return url, False
- def check_playlist():
- filepath = filedialog.askopenfilename(filetypes=[("M3U files", "*.m3u"), ("M3U8 files", "*.m3u8")])
- if filepath:
- working_urls = {}
- working_links = []
- group_counter = 1 # Initialize group title counter
- with open(filepath, 'r', encoding='utf-8') as file:
- urls = [line.strip() for line in file if line.startswith('http')]
- with concurrent.futures.ThreadPoolExecutor() as executor:
- results = executor.map(check_url, urls)
- for url, status in results:
- working_urls[url] = status
- if status:
- working_links.append(url)
- for url in urls:
- status = "Working" if working_urls.get(url) else "Not Working"
- listbox.insert(tk.END, f"{url} - {status}")
- # Write working links with proper M3U8 format
- with open("PLAYLIST.m3u8", "w") as new_file:
- new_file.write("#EXTM3U\n")
- for link in working_links:
- group_title = f"Your Group Title-{group_counter}"
- new_file.write(f"#EXTINF:-1 group-title=\"{group_title}\"\n{link}\n")
- group_counter += 1 # Increment group title counter
- # Display working links in the second text area
- for link in working_links:
- working_links_text.insert(tk.END, link + '\n')
- def copy_selected_url(event):
- selected_index = listbox.curselection()
- if selected_index:
- selected_url = listbox.get(selected_index)
- root.clipboard_clear()
- root.clipboard_append(selected_url.split(" - ")[0])
- root.update()
- def run_in_vlc(event):
- selected_index = listbox.curselection()
- if selected_index:
- selected_url = listbox.get(selected_index)
- url = selected_url.split(" - ")[0]
- vlc_path = r"C:\Program Files\VideoLAN\VLC\vlc.exe"
- try:
- subprocess.Popen([vlc_path, url])
- except FileNotFoundError:
- messagebox.showerror("Error", "VLC player not found. Please check the installation path.")
- root = tk.Tk()
- root.config(bg='green')
- root.title("NAJEEB IPTV M3U URL CHECKER")
- check_button = tk.Button(root, text="Check Playlist", command=check_playlist)
- check_button.pack(pady=10)
- scrollbar = Scrollbar(root, orient=tk.VERTICAL)
- scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
- listbox = tk.Listbox(root, width=150, height=15, yscrollcommand=scrollbar.set)
- listbox.pack(padx=10, pady=10)
- scrollbar.config(command=listbox.yview)
- listbox.bind("<Double-Button-1>", run_in_vlc)
- listbox.bind("<Button-3>", copy_selected_url)
- # New text field to display working links
- working_scrollbar = Scrollbar(root, orient=tk.VERTICAL)
- working_scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
- working_links_text = tk.Text(root, width=110, height=15, yscrollcommand=working_scrollbar.set)
- working_links_text.pack(pady=10)
- working_scrollbar.config(command=working_links_text.yview)
- root.mainloop()
Add Comment
Please, Sign In to add comment