nothin to see here
Some checks failed
Deploy Jekyll with GitHub Pages dependencies preinstalled / build (push) Failing after 6s
Deploy Jekyll with GitHub Pages dependencies preinstalled / deploy (push) Has been skipped
Deploy static content to Pages / deploy (push) Failing after 3s

This commit is contained in:
LoveEL 2026-06-29 17:46:14 -04:00 • committed by GitHub
parent 57583c4b68
commit 2cacef20bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

41
split_m3u.py Normal file
View file

@ -0,0 +1,41 @@
import os
def split_m3u(input_file, channels_per_file=500):
with open(input_file, "r", encoding="utf-8", errors="ignore") as f:
lines = f.readlines()
header = []
entries = []
i = 0
# Save #EXTM3U header
if lines and lines[0].startswith("#EXTM3U"):
header.append(lines[0])
i = 1
# Each channel consists of an #EXTINF line and its URL
while i < len(lines):
if lines[i].startswith("#EXTINF"):
if i + 1 < len(lines):
entries.append([lines[i], lines[i + 1]])
i += 2
else:
break
else:
i += 1
total_files = (len(entries) + channels_per_file - 1) // channels_per_file
for n in range(total_files):
output = f"playlist_part_{n + 1}.m3u"
with open(output, "w", encoding="utf-8") as out:
out.writelines(header)
start = n * channels_per_file
end = start + channels_per_file
for entry in entries[start:end]:
out.writelines(entry)
print(f"Created {output}")
if __name__ == "__main__":
split_m3u("playlist.m3u", channels_per_file=500)