Skip to content

Instantly share code, notes, and snippets.

@link89
Created January 17, 2024 15:32
Show Gist options
  • Save link89/83cc2e013e84e558dab7042d0425f11a to your computer and use it in GitHub Desktop.
Save link89/83cc2e013e84e558dab7042d0425f11a to your computer and use it in GitHub Desktop.
Convert DIYP IPTV list to M3U8 format
"""
Convert DIYP TV List to m3u format
Usage:
python dipy_to_m3u.py diyp.txt out.m3u
DIPY format example:
cctv|channel,#genre#
CCTV1,http://example.org
"""
import sys
sys.argv
in_file = sys.argv[1]
out_file = sys.argv[2]
lines = ['#EXTM3U']
with open(in_file, 'r', encoding='utf-8') as fp:
for line in fp:
tag, url = line.split(',', maxsplit=1)
if url.startswith('#'):
continue
lines += ['#EXTINF:-1 tvg-id="",{}'.format(tag), url.strip()]
with open(out_file, 'w', encoding='utf-8') as fp:
fp.write('\n'.join(lines))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment