Merge remote-tracking branch 'origin/master'

This commit is contained in:
marco
2020-04-11 10:41:17 +02:00
10 changed files with 151 additions and 116 deletions
+3 -5
View File
@@ -58,7 +58,6 @@ def learning(item):
itemlist =[] itemlist =[]
json = current_session.get(item.url).json()['contents'] json = current_session.get(item.url).json()['contents']
for key in json: for key in json:
support.log(key['name'])
itemlist.append(support.Item(channel = item.channel, title = support.typo(key['name'],'bold'), fulltitle = key['name'], show = key['name'], itemlist.append(support.Item(channel = item.channel, title = support.typo(key['name'],'bold'), fulltitle = key['name'], show = key['name'],
url = key['contents'], thumbnail = item.thumbnail, action = 'peliculas', args = item.args)) url = key['contents'], thumbnail = item.thumbnail, action = 'peliculas', args = item.args))
return itemlist return itemlist
@@ -117,7 +116,6 @@ def replay(item):
support.log() support.log()
itemlist = [] itemlist = []
json = current_session.get(item.url).json()[item.fulltitle][0]['palinsesto'][0]['programmi'] json = current_session.get(item.url).json()[item.fulltitle][0]['palinsesto'][0]['programmi']
# support.log(json)
for key in json: for key in json:
support.log('KEY=',key) support.log('KEY=',key)
if key and key['pathID']: itemlist.append(support.Item(channel = item.channel, thumbnail = getUrl(key['images']['landscape']), fanart = getUrl(key['images']['landscape']), url = getUrl(key['pathID']), if key and key['pathID']: itemlist.append(support.Item(channel = item.channel, thumbnail = getUrl(key['images']['landscape']), fanart = getUrl(key['images']['landscape']), url = getUrl(key['pathID']),
@@ -165,13 +163,13 @@ def dirette(item):
onAir = current_session.get(onair).json()['on_air'] onAir = current_session.get(onair).json()['on_air']
for i, key in enumerate(json): for i, key in enumerate(json):
itemlist.append(support.Item(channel = item.channel, title = support.typo(key['channel'], 'bold'), fulltitle = key['channel'], show = key['channel'], itemlist.append(support.Item(channel = item.channel, title = support.typo(key['channel'], 'bold'), fulltitle = key['channel'], show = key['channel'],
thumbnail = key['transparent-icon'].replace("[RESOLUTION]", "256x-"), fanart = getUrl(onAir[i]['currentItem']['image']), url = key['video']['contentUrl'], thumbnail = key['transparent-icon'].replace("[RESOLUTION]", "256x-"),forcethumb=True , fanart = getUrl(onAir[i]['currentItem']['image']), url = key['video']['contentUrl'],
plot = support.typo(onAir[i]['currentItem']['name'],'bold')+ '\n\n' + onAir[i]['currentItem']['description'], action = 'play')) plot = support.typo(onAir[i]['currentItem']['name'],'bold')+ '\n\n' + onAir[i]['currentItem']['description'], action = 'play'))
return itemlist return itemlist
def peliculas(item): def peliculas(item):
support.log(item.url) support.log()
itemlist = [] itemlist = []
keys = [] keys = []
key_list = [] key_list = []
@@ -235,7 +233,7 @@ def select(item):
def episodios(item): def episodios(item):
support.log(len(item.url)) support.log()
itemlist = [] itemlist = []
if type(item.url) in [list, dict] and len(item.url) > 1 and ('name' in item.url[0] and 'stagione' not in item.url[0]['name'].lower()): if type(item.url) in [list, dict] and len(item.url) > 1 and ('name' in item.url[0] and 'stagione' not in item.url[0]['name'].lower()):
for key in item.url: for key in item.url:
+11 -5
View File
@@ -165,8 +165,8 @@ def episodios(item):
episodes.append(episode['episodes']) episodes.append(episode['episodes'])
for episode in episodes: for episode in episodes:
for key in episode: for key in episode:
if 'stagione' in key['title'].encode('utf8').lower(): if 'stagione' in encode(key['title']).lower():
match = support.match(key['title'].encode('utf8'), patron=r'[Ss]tagione\s*(\d+) - [Ee]pisodio\s*(\d+)').match match = support.match(encode(key['title']), patron=r'[Ss]tagione\s*(\d+) - [Ee]pisodio\s*(\d+)').match
title = match[0]+'x'+match[1] + ' - ' + item.fulltitle title = match[0]+'x'+match[1] + ' - ' + item.fulltitle
make_item = True make_item = True
elif int(key['season_id']) == int(season_id): elif int(key['season_id']) == int(season_id):
@@ -228,10 +228,10 @@ def make_itemlist(itemlist, item, data):
search = item.search if item.search else '' search = item.search if item.search else ''
infoLabels = {} infoLabels = {}
for key in data['data']: for key in data['data']:
if search.lower() in key['title'].encode('utf8').lower(): if search.lower() in encode(key['title']).lower():
infoLabels['year'] = key['date_published'] infoLabels['year'] = key['date_published']
infoLabels['title'] = infoLabels['tvshowtitle'] = key['title'] infoLabels['title'] = infoLabels['tvshowtitle'] = key['title']
title = key['title'].encode('utf8') title = encode(key['title'])
itemlist.append( itemlist.append(
Item( Item(
channel = item.channel, channel = item.channel,
@@ -245,4 +245,10 @@ def make_itemlist(itemlist, item, data):
contentTitle= title if item.contentType == 'movie' else '', contentTitle= title if item.contentType == 'movie' else '',
infoLabels=infoLabels infoLabels=infoLabels
)) ))
return itemlist return itemlist
def encode(text):
if sys.version_info[0] >= 3:
return text
else:
return text.encode('utf8')
+1 -1
View File
@@ -120,7 +120,7 @@ def unescape(text):
pass pass
return text # leave as is return text # leave as is
return re.sub("&#?\w+;", fixup, text) return re.sub("&#?\w+;", str(fixup), str(text))
# Convierte los codigos html "ñ" y lo reemplaza por "ñ" caracter unicode utf-8 # Convierte los codigos html "ñ" y lo reemplaza por "ñ" caracter unicode utf-8
+2 -2
View File
@@ -28,9 +28,9 @@ VIDEOLIBRARY_PATH = config.get_videolibrary_path()
MOVIES_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_MOVIES) MOVIES_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_MOVIES)
TVSHOWS_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_TVSHOWS) TVSHOWS_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_TVSHOWS)
"""if not FOLDER_MOVIES or not FOLDER_TVSHOWS or not VIDEOLIBRARY_PATH \ if not FOLDER_MOVIES or not FOLDER_TVSHOWS or not VIDEOLIBRARY_PATH \
or not filetools.exists(MOVIES_PATH) or not filetools.exists(TVSHOWS_PATH): or not filetools.exists(MOVIES_PATH) or not filetools.exists(TVSHOWS_PATH):
config.verify_directories_created()""" config.verify_directories_created()
addon_name = "plugin://plugin.video.%s/" % config.PLUGIN_NAME addon_name = "plugin://plugin.video.%s/" % config.PLUGIN_NAME
+1 -1
View File
@@ -45,7 +45,7 @@ def start():
if not config.dev_mode(): if not config.dev_mode():
from platformcode import updater from platformcode import updater
updater.showSavedChangelog() updater.showSavedChangelog()
def run(item=None): def run(item=None):
logger.info() logger.info()
if not item: if not item:
+1 -1
View File
@@ -181,7 +181,7 @@ def render_items(itemlist, parent_item):
item.folder = False item.folder = False
if item.fanart == "": if item.fanart == "":
item.fanart = parent_item.fanart item.fanart = parent_item.fanart
if item.action == 'play' and thumb_type == 1: if item.action == 'play' and thumb_type == 1 and not item.forcethumb:
item.thumbnail = "https://github.com/kodiondemand/media/raw/master/resources/servers/" + item.server.lower() + '.png' item.thumbnail = "https://github.com/kodiondemand/media/raw/master/resources/servers/" + item.server.lower() + '.png'
# if cloudflare, cookies are needed to display images taken from site # if cloudflare, cookies are needed to display images taken from site
+102 -93
View File
@@ -1035,113 +1035,123 @@ def execute_sql_kodi(sql):
def check_sources(new_movies_path='', new_tvshows_path=''): def check_sources(new_movies_path='', new_tvshows_path=''):
def format_path(path):
if path.startswith("special://") or '://' in path: sep = '/'
else: sep = os.sep
if not path.endswith(sep): path += sep
return path
logger.info() logger.info()
try: new_movies_path = format_path(new_movies_path)
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") new_tvshows_path = format_path(new_tvshows_path)
if filetools.isfile(SOURCES_PATH):
xmldoc = minidom.parse(SOURCES_PATH)
# collect nodes SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
# nodes = xmldoc.getElementsByTagName("video") if filetools.isfile(SOURCES_PATH):
video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0] xmldoc = minidom.parse(SOURCES_PATH)
paths_node = video_node.getElementsByTagName("path")
video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0]
paths_node = video_node.getElementsByTagName("path")
list_path = [p.firstChild.data for p in paths_node]
return new_movies_path in list_path, new_tvshows_path in list_path
else:
xmldoc = minidom.Document()
source_nodes = xmldoc.createElement("sources")
for type in ['programs', 'video', 'music', 'picture', 'files']:
nodo_type = xmldoc.createElement(type)
element_default = xmldoc.createElement("default")
element_default.setAttribute("pathversion", "1")
nodo_type.appendChild(element_default)
source_nodes.appendChild(nodo_type)
xmldoc.appendChild(source_nodes)
return False, False
# check paths
list_path = [p.firstChild.data for p in paths_node]
if new_movies_path in list_path or new_tvshows_path in list_path:
return True
return False
except:
return True
def update_sources(new='', old=''): def update_sources(new='', old=''):
logger.info() logger.info()
if new == old: return True if new == old: return
try: SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") if filetools.isfile(SOURCES_PATH):
if filetools.isfile(SOURCES_PATH): xmldoc = minidom.parse(SOURCES_PATH)
xmldoc = minidom.parse(SOURCES_PATH) else:
xmldoc = minidom.Document()
source_nodes = xmldoc.createElement("sources")
for type in ['programs', 'video', 'music', 'picture', 'files']:
nodo_type = xmldoc.createElement(type)
element_default = xmldoc.createElement("default")
element_default.setAttribute("pathversion", "1")
nodo_type.appendChild(element_default)
source_nodes.appendChild(nodo_type)
xmldoc.appendChild(source_nodes)
# collect nodes
# nodes = xmldoc.getElementsByTagName("video")
video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0]
paths_node = video_node.getElementsByTagName("path")
if old:
# delete old path
for node in paths_node:
if node.firstChild.data == old:
parent = node.parentNode
remove = parent.parentNode
remove.removeChild(parent)
# write changes
if sys.version_info[0] >= 3: #PY3
filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
else: else:
xmldoc = minidom.Document() filetools.write(SOURCES_PATH, b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), vfs=False)
source_nodes = xmldoc.createElement("sources") logger.debug("The path %s has been removed from sources.xml" % old)
for type in ['programs', 'video', 'music', 'picture', 'files']: if new:
nodo_type = xmldoc.createElement(type) # create new path
element_default = xmldoc.createElement("default") list_path = [p.firstChild.data for p in paths_node]
element_default.setAttribute("pathversion", "1") if new in list_path:
nodo_type.appendChild(element_default) logger.info("The path %s already exists in sources.xml" % new)
source_nodes.appendChild(nodo_type) return
xmldoc.appendChild(source_nodes) logger.info("The path %s does not exist in sources.xml" % new)
# collect nodes # if the path does not exist we create one
# nodes = xmldoc.getElementsByTagName("video") source_node = xmldoc.createElement("source")
video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0]
paths_node = video_node.getElementsByTagName("path")
if old: # <name> Node
# delete old path name_node = xmldoc.createElement("name")
for node in paths_node: sep = os.sep
if node.firstChild.data == old: if new.startswith("special://") or scrapertools.find_single_match(new, r'(^\w+:\/\/)'):
parent = node.parentNode sep = "/"
remove = parent.parentNode name = new
remove.removeChild(parent) if new.endswith(sep):
name = new[:-1]
name_node.appendChild(xmldoc.createTextNode(name.rsplit(sep)[-1]))
source_node.appendChild(name_node)
# write changes # <path> Node
if sys.version_info[0] >= 3: #PY3 path_node = xmldoc.createElement("path")
filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()])) path_node.setAttribute("pathversion", "1")
else: path_node.appendChild(xmldoc.createTextNode(new))
filetools.write(SOURCES_PATH, b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), vfs=False) source_node.appendChild(path_node)
logger.debug("The path %s has been removed from sources.xml" % old)
if new: # <allowsharing> Node
# create new path allowsharing_node = xmldoc.createElement("allowsharing")
list_path = [p.firstChild.data for p in paths_node] allowsharing_node.appendChild(xmldoc.createTextNode('true'))
if new in list_path: source_node.appendChild(allowsharing_node)
logger.info("The path %s already exists in sources.xml" % new)
return True
logger.info("The path %s does not exist in sources.xml" % new)
# if the path does not exist we create one # Añadimos <source> a <video>
source_node = xmldoc.createElement("source") video_node.appendChild(source_node)
# <name> Node # write changes
name_node = xmldoc.createElement("name") if sys.version_info[0] >= 3: #PY3
sep = os.sep filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().splitlines() if x.strip()]))
if new.startswith("special://") or scrapertools.find_single_match(new, r'(^\w+:\/\/)'): else:
sep = "/" filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().splitlines() if x.strip()]), vfs=False)
name = new logger.debug("The path %s has been added to sources.xml" % new)
if new.endswith(sep):
name = new[:-1]
name_node.appendChild(xmldoc.createTextNode(name.rsplit(sep)[-1]))
source_node.appendChild(name_node)
# <path> Node
path_node = xmldoc.createElement("path")
path_node.setAttribute("pathversion", "1")
path_node.appendChild(xmldoc.createTextNode(new))
source_node.appendChild(path_node)
# <allowsharing> Node
allowsharing_node = xmldoc.createElement("allowsharing")
allowsharing_node.appendChild(xmldoc.createTextNode('true'))
source_node.appendChild(allowsharing_node)
# Añadimos <source> a <video>
video_node.appendChild(source_node)
# write changes
if sys.version_info[0] >= 3: #PY3
filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
else:
filetools.write(SOURCES_PATH, b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), vfs=False)
logger.debug("The path %s has been added to sources.xml" % new)
return True
except:
logger.debug("An error occurred. The path %s has not been added/updated to sources.xml" % old)
return False
def ask_set_content(silent=False): def ask_set_content(silent=False):
@@ -1149,9 +1159,7 @@ def ask_set_content(silent=False):
logger.debug("videolibrary_kodi %s" % config.get_setting("videolibrary_kodi")) logger.debug("videolibrary_kodi %s" % config.get_setting("videolibrary_kodi"))
def do_config(custom=False): def do_config(custom=False):
if set_content("movie", True, custom) and set_content("tvshow", True, custom) and \ if set_content("movie", True, custom) and set_content("tvshow", True, custom):
update_sources(config.get_setting("videolibrarypath")) and \
update_sources(config.get_setting("downloadpath")):
platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(70104)) platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(70104))
config.set_setting("videolibrary_kodi", True) config.set_setting("videolibrary_kodi", True)
update() update()
@@ -1164,6 +1172,7 @@ def ask_set_content(silent=False):
if not platformtools.dialog_yesno(config.get_localized_string(80026), config.get_localized_string(80016), "", "", config.get_localized_string(80017), config.get_localized_string(80018)): if not platformtools.dialog_yesno(config.get_localized_string(80026), config.get_localized_string(80016), "", "", config.get_localized_string(80017), config.get_localized_string(80018)):
path = platformtools.dialog_browse(3, config.get_localized_string(80019), config.get_setting("videolibrarypath")) path = platformtools.dialog_browse(3, config.get_localized_string(80019), config.get_setting("videolibrarypath"))
if path != "": if path != "":
update_sources(path, config.get_setting("videolibrarypath"))
config.set_setting("videolibrarypath", path) config.set_setting("videolibrarypath", path)
folder = platformtools.dialog_input(config.get_setting("folder_movies"), config.get_localized_string(80020)) folder = platformtools.dialog_input(config.get_setting("folder_movies"), config.get_localized_string(80020))
if folder != "": if folder != "":
+12 -4
View File
@@ -5924,7 +5924,7 @@ msgid "Logging"
msgstr "" msgstr ""
msgctxt "#70789" msgctxt "#70789"
msgid "* Change by opening the settings from the main menu of KoD" msgid "* Change by opening the settings from the KoD main menu"
msgstr "" msgstr ""
@@ -6154,7 +6154,7 @@ msgid "Folder name for TV shows"
msgstr "" msgstr ""
msgctxt "#80022" msgctxt "#80022"
msgid "You can configure the Kodi video library later from the Settings menu inside KoD" msgid "You can configure the Kodi video library later from the settings menu inside KoD"
msgstr "" msgstr ""
msgctxt "#80023" msgctxt "#80023"
@@ -6162,7 +6162,7 @@ msgid "You will be asked to choose and configure the information providers for m
msgstr "" msgstr ""
msgctxt "#80024" msgctxt "#80024"
msgid "An error has occurred during the configuration of the Kodi video library. Please check the log and try again from the Settings menu inside KoD" msgid "An error has occurred during the configuration of the Kodi video library. Please check the log and try again from the settings menu inside KoD"
msgstr "" msgstr ""
msgctxt "#80025" msgctxt "#80025"
@@ -6178,5 +6178,13 @@ msgid "You will be asked to configure The Movie Database for movies and The TVDB
msgstr "" msgstr ""
msgctxt "#80028" msgctxt "#80028"
msgid "The path and/or the folders you selected are already used by the Kodi library. Please select other ones" msgid "The selected folders are already used by the Kodi library. Please change them"
msgstr ""
msgctxt "#80029"
msgid "The selected folders are already used by the Kodi library. Please change them from the settings menu inside KoD"
msgstr ""
msgctxt "#80030"
msgid "The default path and folders will be used. You will be asked to choose and configure the information providers for movies and TV shows"
msgstr "" msgstr ""
+11 -3
View File
@@ -5924,7 +5924,7 @@ msgid "Logging"
msgstr "Logging" msgstr "Logging"
msgctxt "#70789" msgctxt "#70789"
msgid "* Change by opening the settings from the main menu of KoD" msgid "* Change by opening the settings from the KoD main menu"
msgstr "* Cambia aprendo le impostazioni dal menu principale di KoD" msgstr "* Cambia aprendo le impostazioni dal menu principale di KoD"
@@ -6178,5 +6178,13 @@ msgid "You will be asked to configure The Movie Database for movies and The TVDB
msgstr "Ti verrà chiesto di configurare The Movie Database per i film e The TVDB per le serie TV" msgstr "Ti verrà chiesto di configurare The Movie Database per i film e The TVDB per le serie TV"
msgctxt "#80028" msgctxt "#80028"
msgid "The path and/or the folders you selected are already used by the Kodi library. Please select other ones" msgid "The selected folders are already used by the Kodi library. Please change them"
msgstr "Il percorso e/o le cartelle selezionate sono già utilizzati dalla libreria di Kodi. Si prega di selezionarne altri" msgstr "Le cartelle selezionate sono già utilizzate dalla libreria di Kodi. Si prega di cambiarle"
msgctxt "#80029"
msgid "The selected folders are already used by the Kodi library. Please change them"
msgstr "Le cartelle selezionate sono già utilizzate dalla libreria di Kodi. Si prega di cambiarle dal menu impostazioni all'interno di KoD"
msgctxt "#80030"
msgid "The default path and folders will be used. You will be asked to choose and configure the information providers for movies and TV shows"
msgstr "Verranno utilizzati il percorso e le cartelle predefiniti. Ti verrà chiesto di scegliere e configurare i provider delle informazioni per film e serie TV"
+7 -1
View File
@@ -705,10 +705,16 @@ def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_
new_tvshows_path = os.path.join(new_path, new_tvshows_folder) new_tvshows_path = os.path.join(new_path, new_tvshows_folder)
from platformcode import xbmc_videolibrary from platformcode import xbmc_videolibrary
if xbmc_videolibrary.check_sources(new_movies_path+'\\', new_tvshows_path+'\\'): movies_path, tvshows_path = xbmc_videolibrary.check_sources(new_movies_path, new_tvshows_path)
if movies_path or tvshows_path:
if not movies_path:
filetools.rmdir(new_movies_path)
if not tvshows_path:
filetools.rmdir(new_tvshows_path)
config.set_setting("videolibrarypath", current_path) config.set_setting("videolibrarypath", current_path)
config.set_setting("folder_movies", current_movies_folder) config.set_setting("folder_movies", current_movies_folder)
config.set_setting("folder_tvshows", current_tvshows_folder) config.set_setting("folder_tvshows", current_tvshows_folder)
xbmc_videolibrary.update_sources(current_path, new_path)
progress.update(100) progress.update(100)
xbmc.sleep(1000) xbmc.sleep(1000)
progress.close() progress.close()