Advertisement
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 re
- import subprocess
- # Set VLC path with quotes
- vlc_path = r'C:\Program Files\VideoLAN\VLC\vlc.exe'
- def download_m3u_file(url):
- try:
- response = requests.get(url, timeout=5)
- if response.status_code == 200:
- return response.text
- except Exception as e:
- pass
- return None
- def extract_urls_from_m3u(content):
- return re.findall(r'(https?://[^\s]+)', content)
- def check_url(url):
- try:
- response = requests.get(url, timeout=2)
- if response.status_code == 200:
- return url, "Working"
- except Exception as e:
- pass
- return url, "Not Working"
- def check_m3u_urls():
- m3u_url = m3u_url_entry.get()
- if m3u_url:
- if m3u_url.startswith("https://") or m3u_url.startswith("http://"):
- m3u_content = download_m3u_file(m3u_url)
- if m3u_content:
- urls = extract_urls_from_m3u(m3u_content)
- for url in urls:
- status = check_url(url)
- if status[1] == "Working":
- working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
- else:
- not_working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
- else:
- messagebox.showerror("Error", "Failed to download M3U file.")
- else:
- try:
- with open(m3u_url, 'r') as file:
- content = file.read()
- urls = extract_urls_from_m3u(content)
- for url in urls:
- status = check_url(url)
- if status[1] == "Working":
- working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
- else:
- not_working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
- except Exception as e:
- messagebox.showerror("Error", f"Failed to open local M3U file: {e}")
- else:
- messagebox.showerror("Error", "Please provide a valid M3U URL.")
- def run_in_vlc(event):
- # Get the index of the clicked line
- index = event.widget.index(tk.CURRENT)
- # Get the text from the clicked line
- line_text = event.widget.get(index + " linestart", index + " lineend")
- # Extract the URL from the line
- url = line_text.strip().split(" - ")[0]
- # Open the URL in VLC
- if url:
- subprocess.Popen([vlc_path, url])
- else:
- messagebox.showwarning("Warning", "No URL found in the line.")
- root = tk.Tk()
- root.config(bg='white')
- root.title("NAJEEB M3U M3U8 URL CHECKER AND PLAY VLC PLAYER")
- # Entry field to input M3U URL
- m3u_url_label = tk.Label(root, text="Enter M3U URL OR Path:")
- m3u_url_label.grid(row=0, column=0, padx=5, pady=5, sticky="w")
- m3u_url_entry = tk.Entry(root, width=100)
- m3u_url_entry.grid(row=0, column=1, padx=5, pady=5)
- # Button to check M3U URLs
- check_m3u_urls_button = tk.Button(root, text="Check M3U URLs", command=check_m3u_urls)
- check_m3u_urls_button.grid(row=0, column=2, padx=5, pady=5)
- # Text field to display working URLs
- working_urls_label = tk.Label(root, text="Working URLs:")
- working_urls_label.grid(row=1, column=0, padx=5, pady=5, sticky="w")
- working_urls_text = tk.Text(root, width=100, height=10)
- working_urls_text.grid(row=2, column=0, columnspan=3, padx=5, pady=5, sticky="nsew")
- working_urls_scrollbar = Scrollbar(root, orient=tk.VERTICAL, command=working_urls_text.yview)
- working_urls_scrollbar.grid(row=2, column=3, sticky="ns")
- working_urls_text.config(yscrollcommand=working_urls_scrollbar.set)
- working_urls_text.bind("<Double-Button-1>", run_in_vlc)
- # Text field to display not working URLs
- not_working_urls_label = tk.Label(root, text="Not Working URLs:")
- not_working_urls_label.grid(row=3, column=0, padx=5, pady=5, sticky="w")
- not_working_urls_text = tk.Text(root, width=100, height=10)
- not_working_urls_text.grid(row=4, column=0, columnspan=3, padx=5, pady=5, sticky="nsew")
- not_working_urls_scrollbar = Scrollbar(root, orient=tk.VERTICAL, command=not_working_urls_text.yview)
- not_working_urls_scrollbar.grid(row=4, column=3, sticky="ns")
- not_working_urls_text.config(yscrollcommand=not_working_urls_scrollbar.set)
- not_working_urls_text.bind("<Double-Button-1>", run_in_vlc)
- # Configure grid weights for resizing
- root.grid_rowconfigure(2, weight=1)
- root.grid_columnconfigure(2, weight=1)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement