1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2024-12-25 16:52:30 +01:00
TDTChannels/script/ambit.py

48 lines
1.3 KiB
Python
Raw Normal View History

2018-09-22 19:28:28 +02:00
class Ambito:
def __init__(self, name, channels):
self.name = name
self.channels = channels
2019-01-07 23:45:27 +01:00
def add_channels(self, channels_to_add):
if self.channels:
2019-01-08 15:47:06 +01:00
self.channels += channels_to_add
2019-01-07 23:45:27 +01:00
2018-09-22 19:28:28 +02:00
def __channels_to_json__(self):
channel_list = []
for channel in self.channels:
channel_list.append(channel.to_json())
return channel_list
def to_json(self):
return {
"name": self.name,
"channels": self.__channels_to_json__()
}
def __channels_to_m3u8__(self):
channels_list = ""
for channel in self.channels:
for option in channel.get_options():
if option.is_m3u8_valid():
2018-09-23 12:00:20 +02:00
channels_list += channel.to_m3u8(self.name, option)
2018-09-22 19:28:28 +02:00
return channels_list
def to_m3u8(self):
return self.__channels_to_m3u8__()
2019-01-26 15:40:27 +01:00
def __channels_to_enigma2__(self):
channels_list = ""
counter = 3
for channel in self.channels:
for option in channel.get_options():
if option.is_m3u8_valid():
channels_list += channel.to_enigma2(option, counter)
counter += 2
return channels_list
def to_enigma2(self):
return self.__channels_to_enigma2__()
2018-09-22 19:28:28 +02:00
def __str__(self):
2019-01-07 23:45:27 +01:00
return self.name