Update app.py
This commit is contained in:
parent
2612cae57e
commit
a4b55e6754
18
app.py
18
app.py
@ -95,6 +95,24 @@ def generate_m3u_output(channels):
|
||||
output.append(item["url"])
|
||||
return "\n".join(output)
|
||||
|
||||
def generate_txt_output(channels):
|
||||
"""
|
||||
Generates a plain text output for the given channels.
|
||||
Each channel will be written in the format: "Channel Name: URL".
|
||||
"""
|
||||
output_lines = []
|
||||
for channel in channels:
|
||||
# Extract channel name from metadata
|
||||
if match := re.search(r'tvg-name="([^"]+)"', channel["meta"]):
|
||||
channel_name = match.group(1)
|
||||
else:
|
||||
channel_name = "Unknown Channel"
|
||||
|
||||
# Append formatted line to output
|
||||
output_lines.append(f"{channel_name}: {channel['url']}")
|
||||
|
||||
return "\n".join(output_lines)
|
||||
|
||||
def save_file(content, filename):
|
||||
live_folder = 'live'
|
||||
if not os.path.exists(live_folder):
|
||||
|
Loading…
Reference in New Issue
Block a user