Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import ttk
- import requests
- import subprocess
- def search_channels():
- search_term = url_entry.get().lower()
- if search_term.startswith("http"):
- search_by_url(search_term)
- else:
- search_by_category()
- def search_by_url(url):
- try:
- # Send a GET request to the provided URL
- response = requests.get(url)
- # Check if the request was successful (status code 200)
- if response.status_code == 200:
- # Parse M3U data
- m3u_data = response.text.split('\n')
- # Clear any previous results
- result_text.delete(0, tk.END)
- # Store channels' names and URLs
- global channels_info
- channels_info = {}
- # Extract channel names and URLs
- channel_name = None
- for line in m3u_data:
- if line.startswith('#EXTINF:'):
- channel_name = line.split(',')[-1]
- elif line.startswith('http') and channel_name:
- channels_info[channel_name] = line.strip()
- # Insert channel name into the listbox
- result_text.insert(tk.END, channel_name)
- channel_name = None
- else:
- result_text.insert(tk.END, f"Error: Failed to fetch channel data. Status Code: {response.status_code}")
- except requests.RequestException as e:
- result_text.insert(tk.END, f"Error: {str(e)}")
- def search_by_category():
- category = category_var.get()
- url = category_urls.get(category)
- mac_address = mac_entry.get()
- # Construct the request URL with the provided MAC address
- request_url = f"{url}?mac={mac_address}"
- try:
- # Send a GET request to the constructed URL
- response = requests.get(request_url)
- # Check if the request was successful (status code 200)
- if response.status_code == 200:
- # Parse M3U data
- m3u_data = response.text.split('\n')
- # Clear any previous results
- result_text.delete(0, tk.END)
- # Store channels' names and URLs
- global channels_info
- channels_info = {}
- # Extract channel names and URLs
- channel_name = None
- for line in m3u_data:
- if line.startswith('#EXTINF:'):
- channel_name = line.split(',')[-1]
- elif line.startswith('http') and channel_name:
- channels_info[channel_name] = line.strip()
- # Insert channel name into the listbox
- result_text.insert(tk.END, channel_name)
- channel_name = None
- else:
- result_text.insert(tk.END, f"Error: Failed to fetch channel data. Status Code: {response.status_code}")
- except requests.RequestException as e:
- result_text.insert(tk.END, f"Error: {str(e)}")
- def play_selected_channel(event):
- try:
- # Get the selected channel name
- selected_channel = result_text.get(tk.ACTIVE)
- # Open the corresponding URL in VLC
- subprocess.Popen([r"C:\Program Files\VideoLAN\VLC\vlc.exe", channels_info[selected_channel]])
- except (tk.TclError, KeyError):
- pass # Ignore if no channel is selected or channel info is missing
- def check_links():
- global working_links
- working_links = {}
- for channel_name, url in channels_info.items():
- try:
- response = requests.get(url)
- if response.status_code == 200:
- working_links[channel_name] = url
- except requests.RequestException:
- pass
- # Display working links in the result_text widget
- result_text.delete(0, tk.END)
- for channel_name, url in working_links.items():
- result_text.insert(tk.END, f"{channel_name}: {url}\n")
- def save_working_links():
- with open("working_channels.m3u", "w", encoding="utf-8") as f:
- for channel_name, url in working_links.items():
- f.write(f"#EXTINF:-1,{channel_name}\n{url}\n")
- # Create the main application window
- app = tk.Tk()
- app.title("Najeeb IPTV Channel Search M3u and Mac All Conutry")
- app.geometry("800x600")
- app.configure(bg="#336699")
- # Add labels, entry fields, buttons, etc.
- url_frame = tk.Frame(app, bg="#336699")
- url_frame.pack(pady=10)
- url_label = tk.Label(url_frame, text="Enter URL or select category:", bg="#336699", fg="white")
- url_label.pack(side=tk.LEFT, padx=5)
- url_entry = tk.Entry(url_frame, width=50) # Adjust width here
- url_entry.pack(side=tk.LEFT, padx=5)
- mac_label = tk.Label(url_frame, text="Enter MAC Address:", bg="#336699", fg="white")
- mac_label.pack(side=tk.LEFT, padx=5)
- mac_entry = tk.Entry(url_frame)
- mac_entry.pack(side=tk.LEFT, padx=5)
- search_button = tk.Button(url_frame, text="Search", command=search_channels, bg="#FFA500", fg="white")
- search_button.pack(side=tk.LEFT, padx=5)
- result_label = tk.Label(app, text="Channels:", bg="#336699", fg="white")
- result_label.pack()
- # Add scrollbar to the listbox
- scrollbar = tk.Scrollbar(app, orient=tk.VERTICAL)
- scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
- result_text = tk.Listbox(app, height=30, width=130, yscrollcommand=scrollbar.set)
- result_text.pack()
- # Configure scrollbar
- scrollbar.config(command=result_text.yview)
- # Bind double click event to play_selected_channel function
- result_text.bind("<Double-1>", play_selected_channel)
- # Add button to check links
- check_button = tk.Button(app, text="Check Links", command=check_links, bg="#008000", fg="white")
- check_button.pack(side=tk.RIGHT, padx=5)
- # Add button to save working links
- save_button = tk.Button(app, text="Save Working Links", command=save_working_links, bg="#FF0000", fg="white")
- save_button.pack(side=tk.LEFT, padx=5)
- # Dropdown menu for channel categories
- category_urls = {
- "ALL-CONUTRY": "",
- "Afghanistan": "https://iptv-org.github.io/iptv/countries/af.m3u",
- "Albania": "https://iptv-org.github.io/iptv/countries/al.m3u",
- "Algeria": "https://iptv-org.github.io/iptv/countries/dz.m3u",
- "Andorra": "https://iptv-org.github.io/iptv/countries/ad.m3u",
- "Angola": "https://iptv-org.github.io/iptv/countries/ao.m3u",
- "Anguilla": "https://iptv-org.github.io/iptv/countries/ai.m3u",
- "Antigua and Barbuda": "https://iptv-org.github.io/iptv/countries/ag.m3u",
- "Argentina": "https://iptv-org.github.io/iptv/countries/ar.m3u",
- "Armenia": "https://iptv-org.github.io/iptv/countries/am.m3u",
- "Aruba": "https://iptv-org.github.io/iptv/countries/aw.m3u",
- "Australia": "https://iptv-org.github.io/iptv/countries/au.m3u",
- "Austria": "https://iptv-org.github.io/iptv/countries/at.m3u",
- "Azerbaijan": "https://iptv-org.github.io/iptv/countries/az.m3u",
- "Bahamas": "https://iptv-org.github.io/iptv/countries/bs.m3u",
- "Bahrain": "https://iptv-org.github.io/iptv/countries/bh.m3u",
- "Bangladesh": "https://iptv-org.github.io/iptv/countries/bd.m3u",
- "Barbados": "https://iptv-org.github.io/iptv/countries/bb.m3u",
- "Belarus": "https://iptv-org.github.io/iptv/countries/by.m3u",
- "Belgium": "https://iptv-org.github.io/iptv/countries/be.m3u",
- "Belize": "https://iptv-org.github.io/iptv/countries/bz.m3u",
- "Benin": "https://iptv-org.github.io/iptv/countries/bj.m3u",
- "Bermuda": "https://iptv-org.github.io/iptv/countries/bm.m3u",
- "Bhutan": "https://iptv-org.github.io/iptv/countries/bt.m3u",
- "Bolivia": "https://iptv-org.github.io/iptv/countries/bo.m3u",
- "Bosnia and Herzegovina": "https://iptv-org.github.io/iptv/countries/ba.m3u",
- "Botswana": "https://iptv-org.github.io/iptv/countries/bw.m3u",
- "Bouvet Island": "https://iptv-org.github.io/iptv/countries/bv.m3u",
- "Brazil": "https://iptv-org.github.io/iptv/countries/br.m3u",
- "British Virgin Islands": "https://iptv-org.github.io/iptv/countries/vg.m3u",
- "Brunei": "https://iptv-org.github.io/iptv/countries/bn.m3u",
- "Bulgaria": "https://iptv-org.github.io/iptv/countries/bg.m3u",
- "Burkina Faso": "https://iptv-org.github.io/iptv/countries/bf.m3u",
- "Burundi": "https://iptv-org.github.io/iptv/countries/bi.m3u",
- "Cambodia": "https://iptv-org.github.io/iptv/countries/kh.m3u",
- "Cameroon": "https://iptv-org.github.io/iptv/countries/cm.m3u",
- "Canada": "https://iptv-org.github.io/iptv/countries/ca.m3u",
- "Central African Republic": "https://iptv-org.github.io/iptv/countries/cf.m3u",
- "Chad": "https://iptv-org.github.io/iptv/countries/td.m3u",
- "Chile": "https://iptv-org.github.io/iptv/countries/cl.m3u",
- "China": "https://iptv-org.github.io/iptv/countries/cn.m3u",
- "Colombia": "https://iptv-org.github.io/iptv/countries/co.m3u",
- "Comoros": "https://iptv-org.github.io/iptv/countries/km.m3u",
- "Cook Islands": "https://iptv-org.github.io/iptv/countries/ck.m3u",
- "Costa Rica": "https://iptv-org.github.io/iptv/countries/cr.m3u",
- "Croatia": "https://iptv-org.github.io/iptv/countries/hr.m3u",
- "Cuba": "https://iptv-org.github.io/iptv/countries/cu.m3u",
- "Curacao": "https://iptv-org.github.io/iptv/countries/cw.m3u",
- "Cyprus": "https://iptv-org.github.io/iptv/countries/cy.m3u",
- "Czech Republic": "https://iptv-org.github.io/iptv/countries/cz.m3u",
- "Democratic Republic of the Congo": "https://iptv-org.github.io/iptv/countries/cd.m3u",
- "Denmark": "https://iptv-org.github.io/iptv/countries/dk.m3u",
- "Djibouti": "https://iptv-org.github.io/iptv/countries/dj.m3u",
- "Dominica": "https://iptv-org.github.io/iptv/countries/dm.m3u",
- "Dominican Republic": "https://iptv-org.github.io/iptv/countries/do.m3u",
- "El Salvador": "https://iptv-org.github.io/iptv/countries/sv.m3u",
- "Equatorial Guinea": "https://iptv-org.github.io/iptv/countries/gq.m3u",
- "Eritrea": "https://iptv-org.github.io/iptv/countries/er.m3u",
- "Estonia": "https://iptv-org.github.io/iptv/countries/ee.m3u",
- "Ethiopia": "https://iptv-org.github.io/iptv/countries/et.m3u",
- "Finland": "https://iptv-org.github.io/iptv/countries/fi.m3u",
- "France": "https://iptv-org.github.io/iptv/countries/fr.m3u",
- "French Guiana": "https://iptv-org.github.io/iptv/countries/gf.m3u",
- "French Polynesia": "https://iptv-org.github.io/iptv/countries/pf.m3u",
- "French Southern Territories": "https://iptv-org.github.io/iptv/countries/tf.m3u",
- "Gabon": "https://iptv-org.github.io/iptv/countries/ga.m3u",
- "Gambia": "https://iptv-org.github.io/iptv/countries/gm.m3u",
- "Georgia": "https://iptv-org.github.io/iptv/countries/ge.m3u",
- "Germany": "https://iptv-org.github.io/iptv/countries/de.m3u",
- "Ghana": "https://iptv-org.github.io/iptv/countries/gh.m3u",
- "Greece": "https://iptv-org.github.io/iptv/countries/gr.m3u",
- "Greenland": "https://iptv-org.github.io/iptv/countries/gl.m3u",
- "Grenada": "https://iptv-org.github.io/iptv/countries/gd.m3u",
- "Guadeloupe": "https://iptv-org.github.io/iptv/countries/gp.m3u",
- "Guam": "https://iptv-org.github.io/iptv/countries/gu.m3u",
- "Guatemala": "https://iptv-org.github.io/iptv/countries/gt.m3u",
- "Guinea": "https://iptv-org.github.io/iptv/countries/gn.m3u",
- "Guinea-Bissau": "https://iptv-org.github.io/iptv/countries/gw.m3u",
- "Haiti": "https://iptv-org.github.io/iptv/countries/ht.m3u",
- "Honduras": "https://iptv-org.github.io/iptv/countries/hn.m3u",
- "Hong Kong": "https://iptv-org.github.io/iptv/countries/hk.m3u",
- "Hungary": "https://iptv-org.github.io/iptv/countries/hu.m3u",
- "Iceland": "https://iptv-org.github.io/iptv/countries/is.m3u",
- "India": "https://iptv-org.github.io/iptv/countries/in.m3u",
- "Indonesia": "https://iptv-org.github.io/iptv/countries/id.m3u",
- "Iran": "https://iptv-org.github.io/iptv/countries/ir.m3u",
- "Iraq": "https://iptv-org.github.io/iptv/countries/iq.m3u",
- "Ireland": "https://iptv-org.github.io/iptv/countries/ie.m3u",
- "Israel": "https://iptv-org.github.io/iptv/countries/il.m3u",
- "Italy": "https://iptv-org.github.io/iptv/countries/it.m3u",
- "Ivory Coast": "https://iptv-org.github.io/iptv/countries/ci.m3u",
- "Jamaica": "https://iptv-org.github.io/iptv/countries/jm.m3u",
- "Japan": "https://iptv-org.github.io/iptv/countries/jp.m3u",
- "Jordan": "https://iptv-org.github.io/iptv/countries/jo.m3u",
- "Kazakhstan": "https://iptv-org.github.io/iptv/countries/kz.m3u",
- "Kenya": "https://iptv-org.github.io/iptv/countries/ke.m3u",
- "Kosovo": "https://iptv-org.github.io/iptv/countries/xk.m3u",
- "Kuwait": "https://iptv-org.github.io/iptv/countries/kw.m3u",
- "Kyrgyzstan": "https://iptv-org.github.io/iptv/countries/kg.m3u",
- "Laos": "https://iptv-org.github.io/iptv/countries/la.m3u",
- "Latvia": "https://iptv-org.github.io/iptv/countries/lv.m3u",
- "Lebanon": "https://iptv-org.github.io/iptv/countries/lb.m3u",
- "Lesotho": "https://iptv-org.github.io/iptv/countries/ls.m3u",
- "Liberia": "https://iptv-org.github.io/iptv/countries/lr.m3u",
- "Libya": "https://iptv-org.github.io/iptv/countries/ly.m3u",
- "Liechtenstein": "https://iptv-org.github.io/iptv/countries/li.m3u",
- "Lithuania": "https://iptv-org.github.io/iptv/countries/lt.m3u",
- "Luxembourg": "https://iptv-org.github.io/iptv/countries/lu.m3u",
- "Macao": "https://iptv-org.github.io/iptv/countries/mo.m3u",
- "Madagascar": "https://iptv-org.github.io/iptv/countries/mg.m3u",
- "Malawi": "https://iptv-org.github.io/iptv/countries/mw.m3u",
- "Malaysia": "https://iptv-org.github.io/iptv/countries/my.m3u",
- "Maldives": "https://iptv-org.github.io/iptv/countries/mv.m3u",
- "Mali": "https://iptv-org.github.io/iptv/countries/ml.m3u",
- "Malta": "https://iptv-org.github.io/iptv/countries/mt.m3u",
- "Martinique": "https://iptv-org.github.io/iptv/countries/mq.m3u",
- "Mauritania": "https://iptv-org.github.io/iptv/countries/mr.m3u",
- "Mexico": "https://iptv-org.github.io/iptv/countries/mx.m3u",
- "Morocco": "https://iptv-org.github.io/iptv/countries/ma.m3u",
- "Myanmar (Burma)": "https://iptv-org.github.io/iptv/countries/mm.m3u",
- "Namibia": "https://iptv-org.github.io/iptv/countries/na.m3u",
- "Nepal": "https://iptv-org.github.io/iptv/countries/np.m3u",
- "Netherlands": "https://iptv-org.github.io/iptv/countries/nl.m3u",
- "New Zealand": "https://iptv-org.github.io/iptv/countries/nz.m3u",
- "Nicaragua": "https://iptv-org.github.io/iptv/countries/ni.m3u",
- "Niger": "https://iptv-org.github.io/iptv/countries/ne.m3u",
- "Nigeria": "https://iptv-org.github.io/iptv/countries/ng.m3u",
- "North Macedonia": "https://iptv-org.github.io/iptv/countries/mk.m3u",
- "Norway": "https://iptv-org.github.io/iptv/countries/no.m3u",
- "Oman": "https://iptv-org.github.io/iptv/countries/om.m3u",
- "Pakistan": "https://iptv-org.github.io/iptv/countries/pk.m3u",
- "Palestine": "https://iptv-org.github.io/iptv/countries/ps.m3u",
- "Panama": "https://iptv-org.github.io/iptv/countries/pa.m3u",
- "Paraguay": "https://iptv-org.github.io/iptv/countries/py.m3u",
- "Peru": "https://iptv-org.github.io/iptv/countries/pe.m3u",
- "Philippines": "https://iptv-org.github.io/iptv/countries/ph.m3u",
- "Pitcairn Islands": "https://iptv-org.github.io/iptv/countries/pn.m3u",
- "Poland": "https://iptv-org.github.io/iptv/countries/pl.m3u",
- "Portugal": "https://iptv-org.github.io/iptv/countries/pt.m3u",
- "Puerto Rico": "https://iptv-org.github.io/iptv/countries/pr.m3u",
- "Qatar": "https://iptv-org.github.io/iptv/countries/qa.m3u",
- "Republic of the Congo": "https://iptv-org.github.io/iptv/countries/cg.m3u",
- "Réunion": "https://iptv-org.github.io/iptv/countries/re.m3u",
- "Romania": "https://iptv-org.github.io/iptv/countries/ro.m3u",
- "Russia": "https://iptv-org.github.io/iptv/countries/ru.m3u",
- "Rwanda": "https://iptv-org.github.io/iptv/countries/rw.m3u",
- "Saint Barthélemy": "https://iptv-org.github.io/iptv/countries/bl.m3u",
- "Saint Helena": "https://iptv-org.github.io/iptv/countries/sh.m3u",
- "Saint Kitts and Nevis": "https://iptv-org.github.io/iptv/countries/kn.m3u",
- "Saint Lucia": "https://iptv-org.github.io/iptv/countries/lc.m3u",
- "Saint Martin": "https://iptv-org.github.io/iptv/countries/mf.m3u",
- "Saint Pierre and Miquelon": "https://iptv-org.github.io/iptv/countries/pm.m3u",
- "Saint Vincent and the Grenadines": "https://iptv-org.github.io/iptv/countries/vc.m3u",
- "Samoa": "https://iptv-org.github.io/iptv/countries/ws.m3u",
- "San Marino": "https://iptv-org.github.io/iptv/countries/sm.m3u",
- "São Tomé and Príncipe": "https://iptv-org.github.io/iptv/countries/st.m3u",
- "Saudi Arabia": "https://iptv-org.github.io/iptv/countries/sa.m3u",
- "Senegal": "https://iptv-org.github.io/iptv/countries/sn.m3u",
- "Serbia": "https://iptv-org.github.io/iptv/countries/rs.m3u",
- "Seychelles": "https://iptv-org.github.io/iptv/countries/sc.m3u",
- "Sierra Leone": "https://iptv-org.github.io/iptv/countries/sl.m3u",
- "Singapore": "https://iptv-org.github.io/iptv/countries/sg.m3u",
- "Sint Maarten": "https://iptv-org.github.io/iptv/countries/sx.m3u",
- "Slovakia": "https://iptv-org.github.io/iptv/countries/sk.m3u",
- "Slovenia": "https://iptv-org.github.io/iptv/countries/si.m3u",
- "Solomon Islands": "https://iptv-org.github.io/iptv/countries/sb.m3u",
- "Somalia": "https://iptv-org.github.io/iptv/countries/so.m3u",
- "South Africa": "https://iptv-org.github.io/iptv/countries/za.m3u",
- "South Korea": "https://iptv-org.github.io/iptv/countries/kr.m3u",
- "Spain": "https://iptv-org.github.io/iptv/countries/es.m3u",
- "Sri Lanka": "https://iptv-org.github.io/iptv/countries/lk.m3u",
- "Sudan": "https://iptv-org.github.io/iptv/countries/sd.m3u",
- "Suriname": "https://iptv-org.github.io/iptv/countries/sr.m3u",
- "Swaziland": "https://iptv-org.github.io/iptv/countries/sz.m3u",
- "Sweden": "https://iptv-org.github.io/iptv/countries/se.m3u",
- "Switzerland": "https://iptv-org.github.io/iptv/countries/ch.m3u",
- "Syria": "https://iptv-org.github.io/iptv/countries/sy.m3u",
- "Taiwan": "https://iptv-org.github.io/iptv/countries/tw.m3u",
- "Tajikistan": "https://iptv-org.github.io/iptv/countries/tj.m3u",
- "Tanzania": "https://iptv-org.github.io/iptv/countries/tz.m3u",
- "Thailand": "https://iptv-org.github.io/iptv/countries/th.m3u",
- "Togo": "https://iptv-org.github.io/iptv/countries/tg.m3u",
- "Trinidad and Tobago": "https://iptv-org.github.io/iptv/countries/tt.m3u",
- "Tunisia": "https://iptv-org.github.io/iptv/countries/tn.m3u",
- "Turkey": "https://iptv-org.github.io/iptv/countries/tr.m3u",
- "Turkmenistan": "https://iptv-org.github.io/iptv/countries/tm.m3u",
- "Turks and Caicos Islands": "https://iptv-org.github.io/iptv/countries/tc.m3u",
- "U.S. Virgin Islands": "https://iptv-org.github.io/iptv/countries/vi.m3u",
- "Uganda": "https://iptv-org.github.io/iptv/countries/ug.m3u",
- "Ukraine": "https://iptv-org.github.io/iptv/countries/ua.m3u",
- "United Arab Emirates": "https://iptv-org.github.io/iptv/countries/ae.m3u",
- "United Kingdom": "https://iptv-org.github.io/iptv/countries/uk.m3u",
- "United States": "https://iptv-org.github.io/iptv/countries/us.m3u",
- "Uruguay": "https://iptv-org.github.io/iptv/countries/uy.m3u",
- "Uzbekistan": "https://iptv-org.github.io/iptv/countries/uz.m3u",
- "Vanuatu": "https://iptv-org.github.io/iptv/countries/vu.m3u",
- "Vatican City": "https://iptv-org.github.io/iptv/countries/va.m3u",
- "Venezuela": "https://iptv-org.github.io/iptv/countries/ve.m3u",
- "Vietnam": "https://iptv-org.github.io/iptv/countries/vn.m3u",
- "Western Sahara": "https://iptv-org.github.io/iptv/countries/eh.m3u",
- "Yemen": "https://iptv-org.github.io/iptv/countries/ye.m3u",
- "Zambia": "https://iptv-org.github.io/iptv/countries/zm.m3u",
- "Zimbabwe": "https://iptv-org.github.io/iptv/countries/zw.m3u",
- "International": "https://iptv-org.github.io/iptv/countries/int.m3u",
- # Add more categories here
- }
- category_var = tk.StringVar(app)
- category_var.set("Afghanistan") # default value
- category_dropdown = ttk.OptionMenu(app, category_var, *category_urls.keys())
- category_dropdown.pack(pady=10)
- # Global variable to store channels' info
- channels_info = {}
- working_links = {}
- # Run the application loop
- app.mainloop()
Add Comment
Please, Sign In to add comment