mirror of
https://github.com/LaQuay/TDTChannels.git
synced 2024-11-26 18:54:57 +01:00
support to enigma2
This commit is contained in:
parent
4cd9036814
commit
1a150636d2
4 changed files with 51 additions and 10 deletions
|
@ -30,5 +30,18 @@ class Ambito:
|
||||||
def to_m3u8(self):
|
def to_m3u8(self):
|
||||||
return self.__channels_to_m3u8__()
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
options_string = ""
|
options_string = ""
|
||||||
for option in self.options:
|
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
|
return self.name + " " + options_string
|
||||||
|
|
||||||
def __options_to_json__(self):
|
def __options_to_json__(self):
|
||||||
|
@ -47,20 +47,28 @@
|
||||||
"options": self.__options_to_json__()
|
"options": self.__options_to_json__()
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_m3u8(self, ambit, option):
|
def to_m3u8(self, ambit_name, option):
|
||||||
info = '#EXTINF:-1'
|
info = '#EXTINF:-1'
|
||||||
if self.epg_id != "":
|
if self.epg_id != "":
|
||||||
info += ' tvg-id="' + self.epg_id + '"'
|
info += f' tvg-id="{self.epg_id}"'
|
||||||
if self.logo != "":
|
if self.logo != "":
|
||||||
info += ' tvg-logo="' + self.logo + '"'
|
info += f' tvg-logo="{self.logo}"'
|
||||||
if ambit != "":
|
if ambit_name != "":
|
||||||
info += ' group-title="' + ambit + '"'
|
info += f' group-title="{ambit_name}"'
|
||||||
|
|
||||||
info += ', ' + self.name
|
info += ', ' + self.name
|
||||||
info += '\n' + option.get_url() + '\n'
|
info += '\n' + option.get_url() + '\n'
|
||||||
|
|
||||||
return info
|
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:
|
class Web:
|
||||||
def __init__(self, format, url):
|
def __init__(self, format, url):
|
||||||
self.format = format
|
self.format = format
|
||||||
|
@ -72,8 +80,11 @@
|
||||||
def get_format(self):
|
def get_format(self):
|
||||||
return self.format
|
return self.format
|
||||||
|
|
||||||
def get_url(self):
|
def get_url(self, double_dot=True):
|
||||||
return self.url
|
if double_dot:
|
||||||
|
return self.url
|
||||||
|
else:
|
||||||
|
return self.url.replace(":", "%3a")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.format + ", " + self.url
|
return self.format + ", " + self.url
|
||||||
|
|
|
@ -32,3 +32,12 @@ class Country:
|
||||||
|
|
||||||
def to_m3u8(self):
|
def to_m3u8(self):
|
||||||
return self.__ambits_to_m3u8__()
|
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__()
|
||||||
|
|
|
@ -165,6 +165,7 @@ json_file.write(", ")
|
||||||
json_file.write(json.dumps(andorra.to_json()))
|
json_file.write(json.dumps(andorra.to_json()))
|
||||||
json_file.write("]")
|
json_file.write("]")
|
||||||
json_file.close()
|
json_file.close()
|
||||||
|
print("JSON Updated")
|
||||||
|
|
||||||
# Save data to M3U8 file
|
# Save data to M3U8 file
|
||||||
text_file = open('./public/output/channels.m3u8', "w+")
|
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(spain.to_m3u8())
|
||||||
text_file.write(international.to_m3u8())
|
text_file.write(international.to_m3u8())
|
||||||
text_file.close()
|
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")
|
||||||
|
|
Loading…
Reference in a new issue