Pulizia di codice vecchio, piccole migliorie
This commit is contained in:
@@ -21,9 +21,9 @@ from platformcode import config
|
|||||||
from core.item import Item
|
from core.item import Item
|
||||||
|
|
||||||
|
|
||||||
def findhost(url):
|
# def findhost(url):
|
||||||
host = support.match(url, patron=r'href="([^"]+)">\s*cliccando qui').matches[-1]
|
# host = support.match(url, patron=r'href="([^"]+)">\s*cliccando qui').matches[-1]
|
||||||
return host
|
# return host
|
||||||
|
|
||||||
host = config.get_channel_url()
|
host = config.get_channel_url()
|
||||||
headers = [['Referer', host]]
|
headers = [['Referer', host]]
|
||||||
|
|||||||
+1
-1
@@ -138,7 +138,7 @@ def scrapeLang(scraped, lang, longtitle):
|
|||||||
# e credo sia utile per filtertools
|
# e credo sia utile per filtertools
|
||||||
language = ''
|
language = ''
|
||||||
|
|
||||||
if scraped['lang']:
|
if scraped.get('lang'):
|
||||||
if 'ita' in scraped['lang'].lower(): language = 'ITA'
|
if 'ita' in scraped['lang'].lower(): language = 'ITA'
|
||||||
if 'sub' in scraped['lang'].lower(): language = 'Sub-' + language
|
if 'sub' in scraped['lang'].lower(): language = 'Sub-' + language
|
||||||
|
|
||||||
|
|||||||
+1
-33
@@ -119,7 +119,7 @@ def get_channel_url(findhostMethod=None, name=None, forceFindhost=False):
|
|||||||
name = os.path.basename(frame[0].f_code.co_filename).replace('.py', '')
|
name = os.path.basename(frame[0].f_code.co_filename).replace('.py', '')
|
||||||
if findhostMethod:
|
if findhostMethod:
|
||||||
url = jsontools.get_node_from_file(name, 'url')
|
url = jsontools.get_node_from_file(name, 'url')
|
||||||
if not url or 'web.archive.org' in url or forceFindhost: # per eliminare tutti i webarchive salvati causa bug httptools CF, eliminare in futuro
|
if not url or forceFindhost:
|
||||||
url = findhostMethod(channels_data['findhost'][name])
|
url = findhostMethod(channels_data['findhost'][name])
|
||||||
jsontools.update_node(url, name, 'url')
|
jsontools.update_node(url, name, 'url')
|
||||||
return url
|
return url
|
||||||
@@ -139,38 +139,6 @@ def get_system_platform():
|
|||||||
return platform
|
return platform
|
||||||
|
|
||||||
|
|
||||||
def is_autorun_enabled():
|
|
||||||
try:
|
|
||||||
if "xbmc.executebuiltin('RunAddon(plugin.video.kod)')" in open(os.path.join(xbmc.translatePath('special://userdata'),'autoexec.py')).read():
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
except:
|
|
||||||
# if error in reading from file autoexec doesnt exists
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def enable_disable_autorun(is_enabled):
|
|
||||||
# old method, now using service.py
|
|
||||||
|
|
||||||
path = os.path.join(xbmc.translatePath('special://userdata'),'autoexec.py')
|
|
||||||
append_write = 'a' if os.path.exists(path) else 'w'
|
|
||||||
|
|
||||||
if is_enabled is False:
|
|
||||||
with open(path, append_write) as file:
|
|
||||||
file.write("import xbmc\nxbmc.executebuiltin('RunAddon(plugin.video.kod)')")
|
|
||||||
set_setting('autostart', 'On')
|
|
||||||
else:
|
|
||||||
file = open(path, "r")
|
|
||||||
old_content = file.read()
|
|
||||||
new_content = old_content.replace("xbmc.executebuiltin('RunAddon(plugin.video.kod)')", "")
|
|
||||||
file.close()
|
|
||||||
with open(path, "w") as file:
|
|
||||||
file.write(new_content)
|
|
||||||
set_setting('autostart', True)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_settings_addon():
|
def get_all_settings_addon():
|
||||||
# Read the settings.xml file and return a dictionary with {id: value}
|
# Read the settings.xml file and return a dictionary with {id: value}
|
||||||
from core import scrapertools
|
from core import scrapertools
|
||||||
|
|||||||
@@ -455,9 +455,6 @@ if __name__ == "__main__":
|
|||||||
if config.get_setting('autostart'):
|
if config.get_setting('autostart'):
|
||||||
xbmc.executebuiltin('RunAddon(plugin.video.' + config.PLUGIN_NAME + ')')
|
xbmc.executebuiltin('RunAddon(plugin.video.' + config.PLUGIN_NAME + ')')
|
||||||
|
|
||||||
# handling old autoexec method
|
|
||||||
if config.is_autorun_enabled():
|
|
||||||
config.enable_disable_autorun(True)
|
|
||||||
# port old db to new
|
# port old db to new
|
||||||
old_db_name = filetools.join(config.get_data_path(), "kod_db.sqlite")
|
old_db_name = filetools.join(config.get_data_path(), "kod_db.sqlite")
|
||||||
if filetools.isfile(old_db_name):
|
if filetools.isfile(old_db_name):
|
||||||
|
|||||||
@@ -417,6 +417,8 @@ def findvideos(item):
|
|||||||
|
|
||||||
all_videolibrary = []
|
all_videolibrary = []
|
||||||
ch_results = []
|
ch_results = []
|
||||||
|
list_servers = []
|
||||||
|
|
||||||
with futures.ThreadPoolExecutor() as executor:
|
with futures.ThreadPoolExecutor() as executor:
|
||||||
for nom_canal, json_path in list(list_canales.items()):
|
for nom_canal, json_path in list(list_canales.items()):
|
||||||
if filtro_canal and filtro_canal != nom_canal.capitalize():
|
if filtro_canal and filtro_canal != nom_canal.capitalize():
|
||||||
@@ -476,7 +478,6 @@ def findvideos(item):
|
|||||||
del item.library_urls[nom_canal]
|
del item.library_urls[nom_canal]
|
||||||
|
|
||||||
item_json = Item().fromjson(filetools.read(json_path))
|
item_json = Item().fromjson(filetools.read(json_path))
|
||||||
list_servers = []
|
|
||||||
# support.dbg()
|
# support.dbg()
|
||||||
try: from urllib.parse import urlsplit
|
try: from urllib.parse import urlsplit
|
||||||
except ImportError: from urlparse import urlsplit
|
except ImportError: from urlparse import urlsplit
|
||||||
|
|||||||
Reference in New Issue
Block a user