Advertisement
Najeebsk

IPTV-CHECK-ONLINE.py

Feb 29th, 2024
1,175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.56 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 re
  6. import subprocess
  7.  
  8. # Set VLC path with quotes
  9. vlc_path = r'C:\Program Files\VideoLAN\VLC\vlc.exe'
  10.  
  11. def download_m3u_file(url):
  12.     try:
  13.         response = requests.get(url, timeout=5)
  14.         if response.status_code == 200:
  15.             return response.text
  16.     except Exception as e:
  17.         pass
  18.     return None
  19.  
  20. def extract_urls_from_m3u(content):
  21.     return re.findall(r'(https?://[^\s]+)', content)
  22.  
  23. def check_url(url):
  24.     try:
  25.         response = requests.get(url, timeout=2)
  26.         if response.status_code == 200:
  27.             return url, "Working"
  28.     except Exception as e:
  29.         pass
  30.     return url, "Not Working"
  31.  
  32. def check_m3u_urls():
  33.     m3u_url = m3u_url_entry.get()
  34.     if m3u_url:
  35.         if m3u_url.startswith("https://") or m3u_url.startswith("http://"):
  36.             m3u_content = download_m3u_file(m3u_url)
  37.             if m3u_content:
  38.                 urls = extract_urls_from_m3u(m3u_content)
  39.                 for url in urls:
  40.                     status = check_url(url)
  41.                     if status[1] == "Working":
  42.                         working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
  43.                     else:
  44.                         not_working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
  45.             else:
  46.                 messagebox.showerror("Error", "Failed to download M3U file.")
  47.         else:
  48.             try:
  49.                 with open(m3u_url, 'r') as file:
  50.                     content = file.read()
  51.                     urls = extract_urls_from_m3u(content)
  52.                     for url in urls:
  53.                         status = check_url(url)
  54.                         if status[1] == "Working":
  55.                             working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
  56.                         else:
  57.                             not_working_urls_text.insert(tk.END, f"{status[0]} - {status[1]}\n")
  58.             except Exception as e:
  59.                 messagebox.showerror("Error", f"Failed to open local M3U file: {e}")
  60.     else:
  61.         messagebox.showerror("Error", "Please provide a valid M3U URL.")
  62.  
  63. def run_in_vlc(event):
  64.     # Get the index of the clicked line
  65.     index = event.widget.index(tk.CURRENT)
  66.     # Get the text from the clicked line
  67.     line_text = event.widget.get(index + " linestart", index + " lineend")
  68.     # Extract the URL from the line
  69.     url = line_text.strip().split(" - ")[0]
  70.     # Open the URL in VLC
  71.     if url:
  72.         subprocess.Popen([vlc_path, url])
  73.     else:
  74.         messagebox.showwarning("Warning", "No URL found in the line.")
  75.  
  76. root = tk.Tk()
  77. root.config(bg='white')
  78. root.title("NAJEEB M3U M3U8 URL CHECKER AND PLAY VLC PLAYER")
  79.  
  80. # Entry field to input M3U URL
  81. m3u_url_label = tk.Label(root, text="Enter M3U URL OR Path:")
  82. m3u_url_label.grid(row=0, column=0, padx=5, pady=5, sticky="w")
  83.  
  84. m3u_url_entry = tk.Entry(root, width=100)
  85. m3u_url_entry.grid(row=0, column=1, padx=5, pady=5)
  86.  
  87. # Button to check M3U URLs
  88. check_m3u_urls_button = tk.Button(root, text="Check M3U URLs", command=check_m3u_urls)
  89. check_m3u_urls_button.grid(row=0, column=2, padx=5, pady=5)
  90.  
  91. # Text field to display working URLs
  92. working_urls_label = tk.Label(root, text="Working URLs:")
  93. working_urls_label.grid(row=1, column=0, padx=5, pady=5, sticky="w")
  94.  
  95. working_urls_text = tk.Text(root, width=100, height=10)
  96. working_urls_text.grid(row=2, column=0, columnspan=3, padx=5, pady=5, sticky="nsew")
  97.  
  98. working_urls_scrollbar = Scrollbar(root, orient=tk.VERTICAL, command=working_urls_text.yview)
  99. working_urls_scrollbar.grid(row=2, column=3, sticky="ns")
  100. working_urls_text.config(yscrollcommand=working_urls_scrollbar.set)
  101.  
  102. working_urls_text.bind("<Double-Button-1>", run_in_vlc)
  103.  
  104. # Text field to display not working URLs
  105. not_working_urls_label = tk.Label(root, text="Not Working URLs:")
  106. not_working_urls_label.grid(row=3, column=0, padx=5, pady=5, sticky="w")
  107.  
  108. not_working_urls_text = tk.Text(root, width=100, height=10)
  109. not_working_urls_text.grid(row=4, column=0, columnspan=3, padx=5, pady=5, sticky="nsew")
  110.  
  111. not_working_urls_scrollbar = Scrollbar(root, orient=tk.VERTICAL, command=not_working_urls_text.yview)
  112. not_working_urls_scrollbar.grid(row=4, column=3, sticky="ns")
  113. not_working_urls_text.config(yscrollcommand=not_working_urls_scrollbar.set)
  114.  
  115. not_working_urls_text.bind("<Double-Button-1>", run_in_vlc)
  116.  
  117. # Configure grid weights for resizing
  118. root.grid_rowconfigure(2, weight=1)
  119. root.grid_columnconfigure(2, weight=1)
  120.  
  121. root.mainloop()
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement