- nuovo metodo di override DNS
- aggiunta opzione nascondi server, se usi l'autoplay
- migliorie al codice e fix vari
This commit is contained in:
marco
2020-01-08 19:19:59 +01:00
parent d1cc659707
commit b4376525de
139 changed files with 6078 additions and 8909 deletions

View File

@@ -90,16 +90,24 @@ def is_xbmc():
def get_videolibrary_support():
return True
def get_channel_url(name):
try:
import json
except:
import simplejson as json
ROOT_DIR = xbmc.translatePath(__settings__.getAddonInfo('Path'))
LOCAL_FILE = os.path.join(ROOT_DIR, "channels.json")
with open(LOCAL_FILE) as f:
data = json.load(f)
return data[name]
def get_channel_url(findhostMethod=None):
from core import jsontools
import inspect
frame = inspect.stack()[1]
name = os.path.basename(frame[0].f_code.co_filename).replace('.py', '')
if findhostMethod:
url = jsontools.get_node_from_file(name, 'url')
if not url:
url = findhostMethod()
jsontools.update_node(url, name, 'url')
return url
else:
ROOT_DIR = xbmc.translatePath(__settings__.getAddonInfo('Path'))
LOCAL_FILE = os.path.join(ROOT_DIR, "channels.json")
with open(LOCAL_FILE) as f:
data = jsontools.load(f.read())
return data[name]
def get_system_platform():
""" fonction: pour recuperer la platform que xbmc tourne """

View File

@@ -14,6 +14,7 @@ from core import scrapertools
from core import servertools
from core import trakt_tools
from core import videolibrarytools
from core import filetools
from core.item import Item
from platformcode import config, logger
from platformcode import platformtools
@@ -38,7 +39,7 @@ def start():
from specials import resolverdns
from specials.checkhost import test_conn
import threading
threading.Thread(target=test_conn, args=(True, True, True, [], [], True)).start()
threading.Thread(target=test_conn, args=(True, False, True, [], [], True)).start()
# check_adsl = test_conn(is_exit = True, check_dns = True, view_msg = True,
# lst_urls = [], lst_site_check_dns = [], in_addon = True)
@@ -429,6 +430,7 @@ def limit_itemlist(itemlist):
def play_from_library(item):
itemlist=[]
"""
Los .strm al reproducirlos desde kodi, este espera que sea un archivo "reproducible" asi que no puede contener
más items, como mucho se puede colocar un dialogo de seleccion.
@@ -440,12 +442,18 @@ def play_from_library(item):
@param item: elemento con información
"""
logger.info()
#logger.debug("item: \n" + item.tostring('\n'))
logger.debug("item: \n" + item.tostring('\n'))
import xbmcgui
import xbmcplugin
import xbmc
from time import sleep
from time import sleep, time
from core import jsontools
path = filetools.join(config.get_videolibrary_path(), config.get_setting("folder_tvshows"))
AP = config.get_setting('autoplay')
APS = config.get_setting('autoplay_server_list')
NE = config.get_setting('autoplay_next')
# Intentamos reproducir una imagen (esto no hace nada y ademas no da error)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True,
@@ -460,11 +468,50 @@ def play_from_library(item):
item.action = "findvideos"
window_type = config.get_setting("window_type", "videolibrary")
episodes = scrapertools.find_single_match(item.strm_path, '(\d+)x(\d+)')
season = int(episodes[0])
episode = int(episodes[1])
# y volvemos a lanzar kodi
if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
# Ventana convencional
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
if AP and NE:
while not platformtools.is_playing():
pass
while platformtools.is_playing():
pass
sleep(0.5)
xbmc.executebuiltin('Action(Back)')
ep = '%dx%02d' % (season, episode)
next_ep = '%dx%02d' % (season, episode+1)
next_season = '%dx%02d' % (season+1, 1)
next_ep_path = item.strm_path.replace(ep,next_ep)
next_season_path = item.strm_path.replace(ep,next_ep)
play_next = False
if os.path.isfile(path+next_ep_path):
item.contentEpisodeNumber = item.infoLabels['episode'] = episode+1
item.contentTitle = item.infoLabels['title'] = next_ep
item.strm_path = next_ep_path
play_next = True
elif os.path.isfile(path+next_season_path):
item.contentSeason = item.infoLabels['season'] = season+1
item.contentEpisodeNumber = item.infoLabels['episode'] = 1
item.contentTitle = item.infoLabels['title'] = next_season
item.strm_path = next_season_path
play = True
if play_next == True and platformtools.dialog_yesno('Prossimo Episodio?', item.contentTitle, nolabel="", yeslabel="No", autoclose=5000) == 0:
play_from_library(item)
elif AP and APS:
while not platformtools.is_playing():
pass
while platformtools.is_playing():
pass
sleep(0.5)
xbmc.executebuiltin('Action(Back)')
else:
# Ventana emergente
@@ -493,9 +540,8 @@ def play_from_library(item):
itemlist = reorder_itemlist(itemlist)
import time
p_dialog.update(100, '')
time.sleep(0.5)
sleep(0.5)
p_dialog.close()

View File

@@ -20,7 +20,7 @@ import xbmcplugin
from channelselector import get_thumb
from core import channeltools
from core import trakt_tools, scrapertoolsV2
from core import trakt_tools, scrapertools
from core.item import Item
from platformcode import logger, keymaptools
from platformcode import unify
@@ -123,7 +123,8 @@ def render_items(itemlist, parent_item):
@type parent_item: item
@param parent_item: elemento padre
"""
logger.info('INICIO render_items')
logger.info('START render_items')
from core import httptools
# Si el itemlist no es un list salimos
if not type(itemlist) == list:
@@ -152,7 +153,7 @@ def render_items(itemlist, parent_item):
# Recorremos el itemlist
for item in itemlist:
#logger.debug(item)
# logger.debug(item)
# Si el item no contiene categoria, le ponemos la del item padre
if item.category == "":
item.category = parent_item.category
@@ -195,7 +196,6 @@ def render_items(itemlist, parent_item):
item.title = '[I]%s[/I]' % item.title
# Añade headers a las imagenes si estan en un servidor con cloudflare
from core import httptools
if item.action == 'play':
#### Compatibilidad con Kodi 18: evita que se quede la ruedecedita dando vueltas en enlaces Directos
@@ -304,7 +304,7 @@ def render_items(itemlist, parent_item):
if parent_item.mode in ['silent', 'get_cached', 'set_cache', 'finish']:
xbmc.executebuiltin("Container.SetViewMode(500)")
logger.info('FINAL render_items')
logger.info('END render_items')
def get_viewmode_id(parent_item):
@@ -481,7 +481,6 @@ def set_context_commands(item, parent_item):
else:
context_commands.append(
(command["title"], "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], item.clone(**command).tourl())))
# No añadir más opciones predefinidas si se está dentro de Alfavoritos
if parent_item.channel == 'kodfavorites':
return context_commands
@@ -652,7 +651,6 @@ def set_context_commands(item, parent_item):
if item.action == "findvideos" or "buscar_trailer" in context:
context_commands.append((config.get_localized_string(60359), "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], item.clone(
channel="trailertools", action="buscartrailer", contextual=True).tourl())))
# Añadir SuperFavourites al menu contextual (1.0.53 o superior necesario)
sf_file_path = xbmc.translatePath("special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py")
check_sf = os.path.exists(sf_file_path)
@@ -662,16 +660,16 @@ def set_context_commands(item, parent_item):
context_commands = sorted(context_commands, key=lambda comand: comand[0])
# Menu Rapido
context_commands.insert(0, (config.get_localized_string(60360),
"XBMC.RunPlugin(%s?%s)" % (sys.argv[0], Item(channel='side_menu',
action="open_shortcut_menu",
parent=parent_item.tourl()).tourl(
))))
context_commands.insert(1, (config.get_localized_string(70737),
"XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
action="open_menu",
parent=parent_item.tourl()).tourl(
))))
# context_commands.insert(0, (config.get_localized_string(60360),
# "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], Item(channel='side_menu',
# action="open_shortcut_menu",
# parent=parent_item.tourl()).tourl(
# ))))
# context_commands.insert(1, (config.get_localized_string(70737),
# "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
# action="open_menu",
# parent=parent_item.tourl()).tourl(
# ))))
if config.dev_mode():
context_commands.insert(2, ("item info",
"XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(action="itemInfo",
@@ -799,7 +797,7 @@ def get_seleccion(default_action, opciones, seleccion, video_urls):
def calcResolution(option):
match = scrapertoolsV2.find_single_match(option, '([0-9]{2,4})x([0-9]{2,4})')
match = scrapertools.find_single_match(option, '([0-9]{2,4})x([0-9]{2,4})')
resolution = False
if match:
resolution = int(match[0])*int(match[1])

View File

@@ -41,15 +41,18 @@ def loadCommits(page=1):
xbmc.sleep(1000)
else:
platformtools.dialog_notification('Kodi on Demand', 'impossibile controllare gli aggiornamenti')
ret = None
return ret
def check_addon_init():
def check():
if not addon.getSetting('addon_update_enabled'):
return False
logger.info('Cerco aggiornamenti..')
commits = loadCommits()
if not commits:
return False
try:
localCommitFile = open(addonDir+trackingFile, 'r+')
@@ -157,12 +160,41 @@ def check_addon_init():
xbmc.executebuiltin("UpdateLocalAddons")
if poFilesChanged:
refreshLang()
updated = True
else:
logger.info('Nessun nuovo aggiornamento')
return updated
def timer(force=False):
import time
curTime = time.time()
file = "special://profile/addon_data/plugin.video.kod/updater_last_check.txt"
period = float(addon.getSetting('addon_update_timer')) * 3600
updated = False
if force:
updated = check()
checked = True
else:
checked = False
try:
with open(xbmc.translatePath(file), 'r') as fileC:
lastCheck = float(fileC.read())
if curTime - lastCheck > period:
updated = check()
checked = True
except:
updated = check()
checked = True
if checked:
with open(xbmc.translatePath(file), 'w') as fileC:
fileC.write(str(curTime))
return updated
def calcCurrHash():
treeHash = githash.tree_hash(addonDir).hexdigest()
logger.info('tree hash: ' + treeHash)