mirror of
https://github.com/LaQuay/TDTChannels.git
synced 2025-06-02 18:45:37 +02:00
New propostal for json file
This commit is contained in:
parent
9957babe97
commit
ce8cc6562a
4 changed files with 49 additions and 34 deletions
script
28
script/utils.py
Normal file → Executable file
28
script/utils.py
Normal file → Executable file
|
@ -1,4 +1,6 @@
|
|||
import re
|
||||
import calendar
|
||||
import time
|
||||
|
||||
from channel import Channel
|
||||
|
||||
|
@ -6,10 +8,14 @@ from channel import Channel
|
|||
def get_license_info():
|
||||
return {
|
||||
"source": "https://github.com/LaQuay/TDTChannels",
|
||||
"license": "https://github.com/LaQuay/TDTChannels/blob/master/LICENSE"
|
||||
"url": "https://github.com/LaQuay/TDTChannels/blob/master/LICENSE"
|
||||
}
|
||||
|
||||
|
||||
def get_current_timestamp():
|
||||
return calendar.timegm(time.gmtime())
|
||||
|
||||
|
||||
def stringbetween(text, start, end):
|
||||
result = re.search('(?<=' + start + ')(.*)(?=' + end + ')', text, re.DOTALL)
|
||||
return result.group(1)
|
||||
|
@ -54,15 +60,21 @@ def get_tv_channels_from_part(text):
|
|||
|
||||
item_extra_info = list_to_iterate[i + 5].strip()
|
||||
if len(item_extra_info) == 1:
|
||||
item_extra_info = ""
|
||||
item_extra_info = []
|
||||
else:
|
||||
item_extra_info = item_extra_info.split(",")
|
||||
|
||||
channel = Channel(item_name, item_web, item_resolution, item_logo, item_epg, item_extra_info)
|
||||
channel = Channel(item_name, item_web, item_resolution, item_logo, item_epg, item_extra_info, "Video")
|
||||
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)
|
||||
if "# GEO" in option:
|
||||
more_info = ["GEO"]
|
||||
else:
|
||||
more_info =[]
|
||||
channel.add_option(format, url, more_info)
|
||||
channel_list.append(channel)
|
||||
return channel_list
|
||||
|
||||
|
@ -93,14 +105,16 @@ def get_radio_channels_from_part(text):
|
|||
|
||||
item_extra_info = list_to_iterate[i + 4].strip()
|
||||
if len(item_extra_info) == 1:
|
||||
item_extra_info = ""
|
||||
item_extra_info = []
|
||||
else:
|
||||
item_extra_info = item_extra_info.split(",")
|
||||
|
||||
channel = Channel(item_name, item_web, "", item_logo, "", item_extra_info)
|
||||
channel = Channel(item_name, item_web, "", item_logo, "", item_extra_info, "Audio")
|
||||
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.add_option(format, url, [])
|
||||
channel_list.append(channel)
|
||||
return channel_list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue