2018-09-22 19:28:28 +02:00
|
|
|
|
class Channel:
|
|
|
|
|
name = None
|
2018-09-22 22:03:56 +02:00
|
|
|
|
web = None
|
|
|
|
|
resolution = None
|
|
|
|
|
logo = None
|
|
|
|
|
epg_id = None
|
2018-09-22 19:28:28 +02:00
|
|
|
|
options = []
|
|
|
|
|
|
2018-09-22 22:03:56 +02:00
|
|
|
|
def __init__(self, name, web, resolution, logo, epg_id):
|
2018-09-22 19:28:28 +02:00
|
|
|
|
self.name = name
|
2018-09-22 22:03:56 +02:00
|
|
|
|
self.web = web
|
|
|
|
|
self.resolution = resolution
|
|
|
|
|
self.logo = logo
|
|
|
|
|
self.epg_id = epg_id
|
2018-09-22 19:28:28 +02:00
|
|
|
|
self.options = []
|
|
|
|
|
|
|
|
|
|
def add_option(self, format, url):
|
|
|
|
|
self.options.append(self.Web(format, url))
|
|
|
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
|
return self.name
|
|
|
|
|
|
2018-09-22 22:03:56 +02:00
|
|
|
|
def get_resolution(self):
|
|
|
|
|
return self.get_resolution
|
|
|
|
|
|
|
|
|
|
def get_logo(self):
|
|
|
|
|
return self.logo
|
|
|
|
|
|
|
|
|
|
def get_epg(self):
|
|
|
|
|
return self.epg_id
|
|
|
|
|
|
2018-09-22 19:28:28 +02:00
|
|
|
|
def get_options(self):
|
|
|
|
|
return self.options
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
options_string = ""
|
|
|
|
|
for option in self.options:
|
|
|
|
|
options_string += "[Format: " + option.get_format() + ", URL: " + option.get_url() + "]"
|
2018-09-22 22:03:56 +02:00
|
|
|
|
return self.name + " " + options_string
|
2018-09-22 19:28:28 +02:00
|
|
|
|
|
|
|
|
|
def __options_to_json__(self):
|
|
|
|
|
options_list = []
|
|
|
|
|
for option in self.options:
|
|
|
|
|
options_list.append(option.to_json())
|
|
|
|
|
return options_list
|
|
|
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
|
return {
|
|
|
|
|
"name": self.name,
|
2018-09-23 11:47:54 +02:00
|
|
|
|
"web": self.web,
|
2018-09-22 22:03:56 +02:00
|
|
|
|
"logo": self.logo,
|
2018-09-23 11:47:54 +02:00
|
|
|
|
"resolution": self.resolution,
|
2018-09-22 22:03:56 +02:00
|
|
|
|
"epg_id": self.epg_id,
|
2018-09-22 19:28:28 +02:00
|
|
|
|
"options": self.__options_to_json__()
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-22 22:03:56 +02:00
|
|
|
|
def to_m3u8(self, option):
|
|
|
|
|
return ('#EXTINF:-1 tvg-id="' + self.epg_id + '" tvg-logo="' + self.logo + '", ' + self.name + "\n" +
|
|
|
|
|
option.get_url() + "\n")
|
|
|
|
|
|
2018-09-22 19:28:28 +02:00
|
|
|
|
class Web:
|
|
|
|
|
format = None
|
|
|
|
|
url = None
|
|
|
|
|
|
|
|
|
|
def __init__(self, format, url):
|
|
|
|
|
self.format = format
|
|
|
|
|
self.url = url
|
|
|
|
|
|
|
|
|
|
def is_m3u8_valid(self):
|
|
|
|
|
return self.format == "m3u8"
|
|
|
|
|
|
|
|
|
|
def get_format(self):
|
|
|
|
|
return self.format
|
|
|
|
|
|
|
|
|
|
def get_url(self):
|
|
|
|
|
return self.url
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
2018-09-22 22:03:56 +02:00
|
|
|
|
return self.format + ", " + self.url
|
2018-09-22 19:28:28 +02:00
|
|
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
|
return {
|
|
|
|
|
"format": self.format,
|
|
|
|
|
"url": self.url
|
|
|
|
|
}
|