Spaces:
Paused
Paused
Create app.py
Browse files1234567891011121314151617181920212223242526272829303132333435import streamlit as stfrom streamlit_player import st_player
# Function to parse the .m3u filedef parse_m3u(file_path): streams = [] with open(file_path, 'r') as file: lines = file.readlines() for i in range(len(lines)): line = lines[i].strip() if line.startswith("#EXTINF"): name = line.split(",")[-1].strip() url = lines[i + 1].strip() streams.append((name, url)) return streams
# Load and parse the M3U filem3u_file = "index.m3u" # Path to your M3U filestreams = parse_m3u(m3u_file)
# Streamlit UIst.title("IPTV Player")
# Dropdown menu to select streamstream_names = [name for name, _ in streams]selected_stream = st.selectbox("Select a channel", stream_names)
# Find the URL of the selected streamstream_url = dict(streams).get(selected_stream)
# Display the selected streamif stream_url: st_player(stream_url, playing=True, controls=True, loop=False, width=700, height=400)else: st.write("Please select a valid stream.")app.pyAdded+35