diff --git a/channels/raiplay.py b/channels/raiplay.py index efe0569f..c397e563 100644 --- a/channels/raiplay.py +++ b/channels/raiplay.py @@ -58,7 +58,6 @@ def learning(item): itemlist =[] json = current_session.get(item.url).json()['contents'] 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'], url = key['contents'], thumbnail = item.thumbnail, action = 'peliculas', args = item.args)) return itemlist @@ -117,7 +116,6 @@ def replay(item): support.log() itemlist = [] json = current_session.get(item.url).json()[item.fulltitle][0]['palinsesto'][0]['programmi'] - # support.log(json) for key in json: 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']), @@ -165,13 +163,13 @@ def dirette(item): onAir = current_session.get(onair).json()['on_air'] 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'], - 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')) return itemlist def peliculas(item): - support.log(item.url) + support.log() itemlist = [] keys = [] key_list = [] @@ -235,7 +233,7 @@ def select(item): def episodios(item): - support.log(len(item.url)) + support.log() 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()): for key in item.url: diff --git a/channels/vvvvid.py b/channels/vvvvid.py index 1eded5de..9bd08b16 100644 --- a/channels/vvvvid.py +++ b/channels/vvvvid.py @@ -165,8 +165,8 @@ def episodios(item): episodes.append(episode['episodes']) for episode in episodes: for key in episode: - if 'stagione' in key['title'].encode('utf8').lower(): - match = support.match(key['title'].encode('utf8'), patron=r'[Ss]tagione\s*(\d+) - [Ee]pisodio\s*(\d+)').match + if 'stagione' in encode(key['title']).lower(): + 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 make_item = True 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 '' infoLabels = {} 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['title'] = infoLabels['tvshowtitle'] = key['title'] - title = key['title'].encode('utf8') + title = encode(key['title']) itemlist.append( Item( channel = item.channel, @@ -245,4 +245,10 @@ def make_itemlist(itemlist, item, data): contentTitle= title if item.contentType == 'movie' else '', infoLabels=infoLabels )) - return itemlist \ No newline at end of file + return itemlist + +def encode(text): + if sys.version_info[0] >= 3: + return text + else: + return text.encode('utf8') \ No newline at end of file diff --git a/core/scrapertools.py b/core/scrapertools.py index e984484c..0503b92e 100644 --- a/core/scrapertools.py +++ b/core/scrapertools.py @@ -120,7 +120,7 @@ def unescape(text): pass 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 diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index f2671ee2..40292408 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -28,9 +28,9 @@ VIDEOLIBRARY_PATH = config.get_videolibrary_path() MOVIES_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_MOVIES) 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): - config.verify_directories_created()""" + config.verify_directories_created() addon_name = "plugin://plugin.video.%s/" % config.PLUGIN_NAME diff --git a/platformcode/launcher.py b/platformcode/launcher.py index a377e863..60a657a1 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -45,7 +45,7 @@ def start(): if not config.dev_mode(): from platformcode import updater updater.showSavedChangelog() - + def run(item=None): logger.info() if not item: diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index c082d4ee..0b757bac 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -181,7 +181,7 @@ def render_items(itemlist, parent_item): item.folder = False if 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' # if cloudflare, cookies are needed to display images taken from site diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index 8e5219d8..b4a7ef59 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -1035,113 +1035,123 @@ def execute_sql_kodi(sql): 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() - try: - SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") - if filetools.isfile(SOURCES_PATH): - xmldoc = minidom.parse(SOURCES_PATH) + new_movies_path = format_path(new_movies_path) + new_tvshows_path = format_path(new_tvshows_path) - # collect nodes - # nodes = xmldoc.getElementsByTagName("video") - video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0] - paths_node = video_node.getElementsByTagName("path") + SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") + if filetools.isfile(SOURCES_PATH): + xmldoc = minidom.parse(SOURCES_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=''): logger.info() - if new == old: return True + if new == old: return - try: - SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") - if filetools.isfile(SOURCES_PATH): - xmldoc = minidom.parse(SOURCES_PATH) + SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml") + if filetools.isfile(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: - xmldoc = minidom.Document() - source_nodes = xmldoc.createElement("sources") + 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 removed from sources.xml" % old) - 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) + if new: + # create new path + list_path = [p.firstChild.data for p in paths_node] + if new in list_path: + logger.info("The path %s already exists in sources.xml" % new) + return + logger.info("The path %s does not exist in sources.xml" % new) - # collect nodes - # nodes = xmldoc.getElementsByTagName("video") - video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0] - paths_node = video_node.getElementsByTagName("path") + # if the path does not exist we create one + source_node = xmldoc.createElement("source") - if old: - # delete old path - for node in paths_node: - if node.firstChild.data == old: - parent = node.parentNode - remove = parent.parentNode - remove.removeChild(parent) + # Node + name_node = xmldoc.createElement("name") + sep = os.sep + if new.startswith("special://") or scrapertools.find_single_match(new, r'(^\w+:\/\/)'): + sep = "/" + name = new + if new.endswith(sep): + name = new[:-1] + name_node.appendChild(xmldoc.createTextNode(name.rsplit(sep)[-1])) + source_node.appendChild(name_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 removed from sources.xml" % old) + # Node + path_node = xmldoc.createElement("path") + path_node.setAttribute("pathversion", "1") + path_node.appendChild(xmldoc.createTextNode(new)) + source_node.appendChild(path_node) - if new: - # create new path - list_path = [p.firstChild.data for p in paths_node] - if new in list_path: - 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) + # Node + allowsharing_node = xmldoc.createElement("allowsharing") + allowsharing_node.appendChild(xmldoc.createTextNode('true')) + source_node.appendChild(allowsharing_node) - # if the path does not exist we create one - source_node = xmldoc.createElement("source") + # Añadimos a