Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- VERSION = "4.7.1"
- import requests
- import tkinter as tk
- from tkinter import messagebox, filedialog
- import subprocess
- import os
- import re
- #================ADD-IMAGE-ICON=================
- import sys
- def resource_path(relative_path):
- """ Get the absolute path to the resource, works for PyInstaller. """
- if getattr(sys, '_MEIPASS', False):
- return os.path.join(sys._MEIPASS, relative_path)
- return os.path.join(os.path.abspath("."), relative_path)
- # Use this function to load files:
- splash_image = resource_path("splash-1.png")
- icon_path = resource_path("IPTV.ico")
- # ==================ADD-SPLASH==================
- import tkinter as tk
- from PIL import Image, ImageTk
- import time
- def show_splash(image_path):
- # Create splash screen window
- splash = tk.Tk()
- splash.overrideredirect(True) # Remove window border
- # Load the image
- image = Image.open(image_path)
- img = ImageTk.PhotoImage(image)
- # Get image dimensions
- img_width, img_height = image.size
- # Calculate position to center the splash screen
- screen_width = splash.winfo_screenwidth()
- screen_height = splash.winfo_screenheight()
- x = (screen_width - img_width) // 2
- y = (screen_height - img_height) // 2
- splash.geometry(f"{img_width}x{img_height}+{x}+{y}")
- # Set transparent background
- splash.config(bg="white")
- splash.attributes("-transparentcolor", "white") # Make white color transparent
- # Display the image
- label = tk.Label(splash, image=img, bg="white")
- label.pack()
- # Display the splash screen for 5 seconds
- splash.after(5000, splash.destroy)
- splash.mainloop()
- # Call splash screen function
- show_splash(splash_image) # Replace with your image file path 1 To 6
- # ==================ADD-SPLASH==================
- def fetch_m3u():
- url = entry_url.get()
- if not url:
- messagebox.showerror("Error", "Please enter a valid URL")
- return
- try:
- response = requests.get(url)
- response.raise_for_status()
- content = response.text
- parse_m3u(content)
- except requests.exceptions.RequestException as e:
- messagebox.showerror("Error", f"Failed to fetch M3U file: {e}")
- def save_m3u():
- file_path = filedialog.asksaveasfilename(defaultextension=".m3u", filetypes=[("M3U files", "*.m3u")])
- if file_path:
- with open(file_path, "w", encoding="utf-8") as file:
- for title, url in stream_list:
- file.write(f"#EXTINF:-1,{title}\n{url}\n")
- messagebox.showinfo("Success", f"M3U file saved: {file_path}")
- def parse_m3u(content):
- global stream_list, displayed_list
- stream_list.clear()
- displayed_list.clear()
- listbox.delete(0, tk.END)
- lines = content.splitlines()
- title = "Unknown"
- for line in lines:
- if line.startswith("#EXTINF"):
- match = re.search(r'#EXTINF:-1,([^\n]+)', line)
- if match:
- title = match.group(1)
- elif line.startswith("http"):
- stream_list.append((title, line))
- displayed_list.append((title, line))
- listbox.insert(tk.END, f"{title} - {line}")
- title = "Unknown" # Reset title for next entry
- def play_selected():
- selected = listbox.curselection()
- if not selected:
- messagebox.showwarning("Warning", "Please select a stream to play")
- return
- _, url = displayed_list[selected[0]]
- vlc_path = r"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
- try:
- subprocess.run([vlc_path, url], check=True)
- except FileNotFoundError:
- messagebox.showerror("Error", "VLC Player not found. Ensure VLC is installed and added to PATH.")
- def clear_all():
- entry_url.delete(0, tk.END)
- listbox.delete(0, tk.END)
- stream_list.clear()
- displayed_list.clear()
- def search_streams():
- query = search_entry.get().lower()
- listbox.delete(0, tk.END)
- displayed_list.clear()
- for title, url in stream_list:
- if query in title.lower() or query in url.lower():
- displayed_list.append((title, url))
- listbox.insert(tk.END, f"{title} - {url}")
- # UI Setup
- root = tk.Tk()
- root.title("Najeeb M3U Scraper & VLC Player")
- root.geometry("900x600")
- root.configure(bg="#2c3e50")
- root.iconbitmap(icon_path)
- stream_list = []
- displayed_list = []
- input_frame = tk.Frame(root, bg="#2c3e50")
- input_frame.pack(pady=5)
- tk.Label(input_frame, text="Enter M3U URL:", bg="#2c3e50", fg="white", font=("Arial", 12, "bold")).pack(side=tk.LEFT, padx=5)
- entry_url = tk.Entry(input_frame, width=60, font=("Arial", 12))
- entry_url.pack(side=tk.LEFT, padx=5)
- button_frame = tk.Frame(root, bg="#2c3e50")
- button_frame.pack(pady=5)
- tk.Button(button_frame, text="Fetch M3U", command=fetch_m3u, bg="#3498db", fg="white", font=("Arial", 12, "bold"), width=12).pack(side=tk.LEFT, padx=5)
- tk.Button(button_frame, text="Save M3U", command=save_m3u, bg="#27ae60", fg="white", font=("Arial", 12, "bold"), width=12).pack(side=tk.LEFT, padx=5)
- tk.Button(button_frame, text="Play in VLC", command=play_selected, bg="#e74c3c", fg="white", font=("Arial", 12, "bold"), width=12).pack(side=tk.LEFT, padx=5)
- tk.Button(button_frame, text="Clear All", command=clear_all, bg="#f1c40f", fg="black", font=("Arial", 12, "bold"), width=12).pack(side=tk.LEFT, padx=5)
- search_frame = tk.Frame(root, bg="#2c3e50")
- search_frame.pack(pady=5)
- tk.Label(search_frame, text="Search:", bg="#2c3e50", fg="white", font=("Arial", 12, "bold")).pack(side=tk.LEFT, padx=5)
- search_entry = tk.Entry(search_frame, width=40, font=("Arial", 12))
- search_entry.pack(side=tk.LEFT, padx=5)
- tk.Button(search_frame, text="Search", command=search_streams, bg="#8e44ad", fg="white", font=("Arial", 12, "bold"), width=12).pack(side=tk.LEFT, padx=5)
- frame = tk.Frame(root)
- frame.pack(pady=5, fill=tk.BOTH, expand=True)
- scrollbar = tk.Scrollbar(frame, orient=tk.VERTICAL)
- listbox = tk.Listbox(frame, width=100, height=25, yscrollcommand=scrollbar.set, font=("Arial", 10))
- scrollbar.config(command=listbox.yview)
- scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
- listbox.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
- root.mainloop()
- # pyinstaller --onefile --windowed --icon=IPTV.ico --add-data "splash-1.png;." --add-data "IPTV.ico;." IPTV-M3U.pyw
- # pyinstaller --onefile --windowed --icon=IPTV.ico --add-data "splash-1.png:." --add-data "IPTV.ico:." IPTV-M3U.pyw
- # pyinstaller --onefile --windowed --noconsole --icon=IPTV.ico --add-data "splash-1.png;." --add-data "IPTV.ico;." IPTV-M3U.pyw
Add Comment
Please, Sign In to add comment