1
0
Fork 0
mirror of https://github.com/LaQuay/TDTChannels.git synced 2025-06-05 19:54:36 +02:00

first version radio m3u8

This commit is contained in:
LaQuay 2019-03-26 00:38:03 +01:00
parent 4d7e2f83ce
commit 3909f5aba9
4 changed files with 274 additions and 49 deletions
script

View file

@ -19,7 +19,7 @@ def stringbetweenparantheses(text):
return text.split("(")[1].split(")")[0]
def get_channels_from_part(text):
def get_tv_channels_from_part(text):
line_where_first_channel_starts = 15
attributes_per_item = 6
list_to_iterate = text.split("|")[line_where_first_channel_starts:-1]
@ -65,3 +65,42 @@ def get_channels_from_part(text):
channel.add_option(format, url)
channel_list.append(channel)
return channel_list
def get_radio_channels_from_part(text):
line_where_first_channel_starts = 13
attributes_per_item = 5
list_to_iterate = text.split("|")[line_where_first_channel_starts:-1]
while "\n" in list_to_iterate:
list_to_iterate.remove("\n")
channel_list = []
for i in range(0, len(list_to_iterate), attributes_per_item):
item_name = list_to_iterate[i].strip()
item_options = list_to_iterate[i + 1].strip()
item_web = list_to_iterate[i + 2].strip()
if len(item_web) > 0 and item_web[0] != "-":
item_web = stringbetweenparantheses(item_web)
if len(item_web) == 1:
item_web = ""
item_logo = list_to_iterate[i + 3].strip()
if len(item_logo) > 0 and item_logo[0] != "-":
item_logo = stringbetweenparantheses(item_logo)
if len(item_logo) == 1:
item_logo = ""
item_extra_info = list_to_iterate[i + 4].strip()
if len(item_extra_info) == 1:
item_extra_info = ""
channel = Channel(item_name, item_web, "", item_logo, "", item_extra_info)
item_options = item_options.split(" - ")
if len(item_options) > 0 and item_options[0] != "-":
for option in item_options:
format = (option[1:5]).replace("]", "")
url = stringbetweenparantheses(option)
channel.add_option(format, url)
channel_list.append(channel)
return channel_list