Files
DemonEditor/app/eparser/iptv.py

26 lines
761 B
Python
Raw Normal View History

2018-01-01 23:42:40 +03:00
from .ecommons import BqServiceType, Service
2017-12-08 18:32:28 +03:00
def parse_m3u(path):
with open(path) as file:
2018-01-31 00:13:42 +03:00
aggr = [None] * 10
2017-12-08 18:32:28 +03:00
channels = []
count = 0
name = None
for line in file.readlines():
if line.startswith("#EXTINF"):
name = line[1 + line.index(","):].strip()
count += 1
elif count == 1:
count = 0
2017-12-20 11:27:18 +03:00
fav_id = " 1:0:1:0:0:0:0:0:0:0:{}:{}\n#DESCRIPTION: {}\n".format(
2017-12-16 19:28:57 +03:00
line.strip().replace(":", "%3a"), name, name, None)
2018-01-31 00:13:42 +03:00
srv = Service(*aggr[0:3], name, *aggr[0:3], BqServiceType.IPTV.name, *aggr, fav_id, None)
channels.append(srv)
2017-12-08 18:32:28 +03:00
return channels
if __name__ == "__main__":
pass