diff --git a/channels/guardaserieclick.json b/channels/guardaserieclick.json index 1729826d..2593ae40 100644 --- a/channels/guardaserieclick.json +++ b/channels/guardaserieclick.json @@ -25,5 +25,6 @@ "enabled": false, "visible": false } - ] + ], + "cloudflare": true } diff --git a/channels/piratestreaming.json b/channels/piratestreaming.json index 0ad00303..b52b1c73 100644 --- a/channels/piratestreaming.json +++ b/channels/piratestreaming.json @@ -7,5 +7,6 @@ "thumbnail": "piratestreaming.png", "bannermenu": "piratestreaming.png", "categories": ["anime","movie","tvshow"], - "settings": [] + "settings": [], + "cloudflare": true } diff --git a/channels/seriehd.json b/channels/seriehd.json index b6be2f7b..54a7a5a5 100644 --- a/channels/seriehd.json +++ b/channels/seriehd.json @@ -7,5 +7,6 @@ "thumbnail": "seriehd.png", "banner": "seriehd.png", "categories": ["tvshow"], - "settings": [] + "settings": [], + "cloudflare": true } diff --git a/servers/akstream.json b/servers/akstream.json index 3dd3023c..6e1f942e 100644 --- a/servers/akstream.json +++ b/servers/akstream.json @@ -42,5 +42,6 @@ "visible": false } ], - "thumbnail": "server_akvideo.png" + "thumbnail": "server_akvideo.png", + "cloudflare": true } diff --git a/servers/wstream.json b/servers/wstream.json index 9bca3af8..d2e0df0d 100644 --- a/servers/wstream.json +++ b/servers/wstream.json @@ -42,5 +42,6 @@ "type": "list", "visible": false } - ] + ], + "cloudflare": true } diff --git a/videolibrary_service.py b/videolibrary_service.py index 113715f4..19f7e672 100644 --- a/videolibrary_service.py +++ b/videolibrary_service.py @@ -5,8 +5,7 @@ import datetime, imp, math, threading, traceback, sys, glob - - +import channelselector from platformcode import config try: import xbmc, os @@ -333,7 +332,35 @@ def monitor_update(): # config.set_setting(name=data[channel_file], value="value", channel=channel_file) # except: pass #channel not in json +# always bypass al websites that use cloudflare at startup, so there's no need to wait 5 seconds when opened +def callCloudflare(): + from core import httptools, support + import json + channels_path = os.path.join(config.get_runtime_path(), "channels", '*.json') + channel_files = [os.path.splitext(os.path.basename(c))[0] for c in glob.glob(channels_path)] + for channel_name in channel_files: + channel_parameters = channeltools.get_channel_parameters(channel_name) + if 'cloudflare' in channel_parameters and channel_parameters["cloudflare"]: + channel = __import__('channels.%s' % channel_name, fromlist=["channels.%s" % channel_name]) + try: + channel.findhost() + except: + pass + httptools.downloadpage(channel.host) + + servers_path = os.path.join(config.get_runtime_path(), "servers", '*.json') + servers_files = glob.glob(servers_path) + for server in servers_files: + with open(server) as server: + server_parameters = json.load(server) + if 'cloudflare' in server_parameters and server_parameters["cloudflare"]: + patternUrl = server_parameters["find_videos"]["patterns"][0]["url"] + url = '/'.join(patternUrl.split('/')[:3]) + httptools.downloadpage(url) + + if __name__ == "__main__": + threading.Thread(target=callCloudflare()) # Se ejecuta en cada inicio import xbmc import time