1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2024-11-22 17:03:24 +01:00

support to enigma2

This commit is contained in:
Marc 2019-01-26 15:40:27 +01:00
parent 4cd9036814
commit 1a150636d2
4 changed files with 51 additions and 10 deletions

View file

@ -30,5 +30,18 @@ class Ambito:
def to_m3u8(self):
return self.__channels_to_m3u8__()
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__()
def __str__(self):
return self.name

View file

@ -28,7 +28,7 @@
def __str__(self):
options_string = ""
for option in self.options:
options_string += "[Format: " + option.get_format() + ", URL: " + option.get_url() + "]"
options_string += f"[Format: {option.get_format()}, URL: {option.get_url()}]"
return self.name + " " + options_string
def __options_to_json__(self):
@ -47,20 +47,28 @@
"options": self.__options_to_json__()
}
def to_m3u8(self, ambit, option):
def to_m3u8(self, ambit_name, option):
info = '#EXTINF:-1'
if self.epg_id != "":
info += ' tvg-id="' + self.epg_id + '"'
info += f' tvg-id="{self.epg_id}"'
if self.logo != "":
info += ' tvg-logo="' + self.logo + '"'
if ambit != "":
info += ' group-title="' + ambit + '"'
info += f' tvg-logo="{self.logo}"'
if ambit_name != "":
info += f' group-title="{ambit_name}"'
info += ', ' + self.name
info += '\n' + option.get_url() + '\n'
return info
def to_enigma2(self, option, counter):
info = f'#SERVICE 4097:0:1:{counter}:0:0:0:0:0:0'
info += f':{option.get_url(double_dot=False)}'
info += f':{self.name}\n'
info += f'#DESCRIPTION {self.name}\n'
return info
class Web:
def __init__(self, format, url):
self.format = format
@ -72,8 +80,11 @@
def get_format(self):
return self.format
def get_url(self):
return self.url
def get_url(self, double_dot=True):
if double_dot:
return self.url
else:
return self.url.replace(":", "%3a")
def __str__(self):
return self.format + ", " + self.url
@ -82,4 +93,4 @@
return {
"format": self.format,
"url": self.url
}
}

View file

@ -32,3 +32,12 @@ class Country:
def to_m3u8(self):
return self.__ambits_to_m3u8__()
def __ambits_to_enigma2__(self):
ambits_list = ""
for ambit in self.ambits:
ambits_list += ambit.to_enigma2()
return ambits_list
def to_enigma2(self):
return self.__ambits_to_enigma2__()

View file

@ -165,6 +165,7 @@ json_file.write(", ")
json_file.write(json.dumps(andorra.to_json()))
json_file.write("]")
json_file.close()
print("JSON Updated")
# Save data to M3U8 file
text_file = open('./public/output/channels.m3u8', "w+")
@ -173,5 +174,12 @@ text_file.write("# @LaQuay https://github.com/LaQuay/TDTChannels" + "\n")
text_file.write(spain.to_m3u8())
text_file.write(international.to_m3u8())
text_file.close()
print("M3U8 Updated")
print("JSON + M3U8 Updated")
# Save data to .tv file (Enigma2)
text_file = open('./public/output/userbouquet.tdtchannels.tv', "w+")
text_file.write("#NAME @LaQuay https://github.com/LaQuay/TDTChannels" + "\n")
text_file.write(spain.to_enigma2())
text_file.write(international.to_enigma2())
text_file.close()
print("ENIGMA2 Updated")