def get_results(nfo_path, root, Type, local=False): dead_list = [] zombie_list = [] value = 0 if Type == 'movie': folder = "folder_movies" else: folder = "folder_tvshows" if filetools.exists(nfo_path): # We synchronize the episodes seen from the Kodi video library with that of KoD from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kod(nfo_path) head_nfo, item = videolibrarytools.read_nfo(nfo_path) # If you have not read the .nfo well, we will proceed to the next if not item: logger.error('.nfo erroneous in ' + str(nfo_path)) return Item(), 0 if len(item.library_urls) > 1: multichannel = True else: multichannel = False # Verify the existence of the channels. If the channel does not exist, ask yourself if you want to remove the links from that channel. for canal in item.library_urls: try: if canal in ['community', 'downloads']: channel_verify = __import__('specials.%s' % canal, fromlist=["channels.%s" % canal]) else: channel_verify = __import__('channels.%s' % canal, fromlist=["channels.%s" % canal]) logger.debug('Channel %s seems correct' % channel_verify) except: dead_item = Item(multichannel=multichannel, contentType='tvshow', dead=canal, path=filetools.split(nfo_path)[0], nfo=nfo_path, library_urls=item.library_urls, infoLabels={'title': item.contentTitle}) if canal not in dead_list and canal not in zombie_list: confirm = platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(30132) % canal.upper() + '\n' + config.get_localized_string(30133)) elif canal in zombie_list: confirm = False else: confirm = True if confirm: delete(dead_item) if canal not in dead_list: dead_list.append(canal) continue else: if canal not in zombie_list: zombie_list.append(canal) if len(dead_list) > 0: for canal in dead_list: if canal in item.library_urls: del item.library_urls[canal] # continue loading the elements of the video library if Type == 'movie': item.path = filetools.split(nfo_path)[0] item.nfo = nfo_path sep = '/' if '/' in nfo_path else '\\' item.extra = filetools.join(config.get_setting("videolibrarypath"), config.get_setting(folder), item.path.split(sep)[-1]) strm_path = item.strm_path.replace("\\", "/").rstrip("/") if not item.thumbnail: item.thumbnail = item.infoLabels['thumbnail'] if '/' in item.path: item.strm_path = strm_path # If strm has been removed from kodi library, don't show it if not filetools.exists(filetools.join(item.path, filetools.basename(strm_path))) and not local: return Item(), 0 # Contextual menu: Mark as seen / not seen visto = item.library_playcounts.get(item.path.split(sep)[0], 0) item.infoLabels["playcount"] = visto if visto > 0: seen_text = config.get_localized_string(60016) counter = 0 else: seen_text = config.get_localized_string(60017) counter = 1 # Context menu: Delete series / channel channels_num = len(item.library_urls) if "downloads" in item.library_urls: channels_num -= 1 if channels_num > 1: delete_text = config.get_localized_string(60018) else: delete_text = config.get_localized_string(60019) item.context = [{"title": seen_text, "action": "mark_content_as_watched", "channel": "videolibrary", "playcount": counter}, {"title": delete_text, "action": "delete", "channel": "videolibrary", "multichannel": multichannel}] else: # Sometimes it gives random errors, for not finding the .nfo. Probably timing issues try: item.title = item.contentTitle item.path = filetools.split(nfo_path)[0] item.nfo = nfo_path sep = '/' if '/' in nfo_path else '\\' item.extra = filetools.join(config.get_setting("videolibrarypath"), config.get_setting(folder), item.path.split(sep)[-1]) # Contextual menu: Mark as seen / not seen visto = item.library_playcounts.get(item.contentTitle, 0) item.infoLabels["playcount"] = visto logger.info('item\n' + str(item)) if visto > 0: seen_text = config.get_localized_string(60020) counter = 0 else: seen_text = config.get_localized_string(60021) counter = 1 except: logger.error('Not find: ' + str(nfo_path)) logger.error(traceback.format_exc()) return Item(), 0 # Context menu: Automatically search for new episodes or not if item.active and int(item.active) > 0: update_text = config.get_localized_string(60022) value = 0 else: update_text = config.get_localized_string(60023) value = 1 item.title += " [B]" + u"\u2022" + "[/B]" # Context menu: Delete series / channel channels_num = len(item.library_urls) if "downloads" in item.library_urls: channels_num -= 1 if channels_num > 1: delete_text = config.get_localized_string(60024) else: delete_text = config.get_localized_string(60025) item.context = [{"title": seen_text, "action": "mark_content_as_watched", "channel": "videolibrary", "playcount": counter}, {"title": update_text, "action": "mark_tvshow_as_updatable", "channel": "videolibrary", "active": value}, {"title": delete_text, "action": "delete", "channel": "videolibrary", "multichannel": multichannel}, {"title": config.get_localized_string(70269), "action": "update_tvshow", "channel": "videolibrary"}] if item.local_episodes_path == "": item.context.append({"title": config.get_localized_string(80048), "action": "add_local_episodes", "channel": "videolibrary"}) else: item.context.append({"title": config.get_localized_string(80049), "action": "remove_local_episodes", "channel": "videolibrary"}) else: item = Item() return item, value
def update(path, p_dialog, i, t, serie, overwrite): logger.debug("Updating " + path) insertados_total = 0 nfo_file = xbmc.translatePath(filetools.join(path, 'tvshow.nfo')) head_nfo, it = videolibrarytools.read_nfo(nfo_file) videolibrarytools.update_renumber_options(it, head_nfo, path) if not serie.library_url: serie = it category = serie.category # logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) )) for channel, url in serie.library_urls.items(): serie.channel = channel module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel]) url = module.host + urlsplit(url).path serie.url = url ###### Redirection to the NewPct1.py channel if it is a clone, or to another channel and url if there has been judicial intervention try: head_nfo, it = videolibrarytools.read_nfo( nfo_file) # Refresh the .nfo to collect updates if it.emergency_urls: serie.emergency_urls = it.emergency_urls serie.category = category except: logger.error(traceback.format_exc()) channel_enabled = channeltools.is_enabled(serie.channel) if channel_enabled: heading = config.get_localized_string(20000) p_dialog.update( int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (serie.contentSerieName, serie.channel.capitalize())) try: pathchannels = filetools.join(config.get_runtime_path(), "channels", serie.channel + '.py') logger.debug("loading channel: " + pathchannels + " " + serie.channel) if serie.library_filter_show: serie.show = serie.library_filter_show.get( serie.channel, serie.contentSerieName) obj = __import__('channels.%s' % serie.channel, fromlist=[pathchannels]) itemlist = obj.episodios(serie) try: if int(overwrite) == 3: # Overwrite all files (tvshow.nfo, 1x01.nfo, 1x01 [channel] .json, 1x01.strm, etc ...) insertados, sobreescritos, fallidos, notusedpath = videolibrarytools.save_tvshow( serie, itemlist) #serie= videolibrary.check_season_playcount(serie, serie.contentSeason) #if filetools.write(path + '/tvshow.nfo', head_nfo + it.tojson()): # serie.infoLabels['playcount'] = serie.playcount else: insertados, sobreescritos, fallidos = videolibrarytools.save_episodes( path, itemlist, serie, silent=True, overwrite=overwrite) #it = videolibrary.check_season_playcount(it, it.contentSeason) #if filetools.write(path + '/tvshow.nfo', head_nfo + it.tojson()): # serie.infoLabels['playcount'] = serie.playcount insertados_total += insertados except Exception as ex: logger.error( "Error when saving the chapters of the series") template = "An exception of type %s occured. Arguments:\n%r" message = template % (type(ex).__name__, ex.args) logger.error(message) except Exception as ex: logger.error("Error in obtaining the episodes of: %s" % serie.show) template = "An exception of type %s occured. Arguments:\n%r" message = template % (type(ex).__name__, ex.args) logger.error(message) else: logger.debug("Channel %s not active is not updated" % serie.channel) # Synchronize the episodes seen from the Kodi video library with that of KoD try: if config.is_xbmc(): # If it's Kodi, we do it from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kod( filetools.join(path, 'tvshow.nfo')) except: logger.error(traceback.format_exc()) return insertados_total > 0
def check_for_update(overwrite=True): logger.debug("Update Series...") p_dialog = None serie_actualizada = False update_when_finished = False hoy = datetime.date.today() estado_verify_playcount_series = False local_ended = True try: if config.get_setting("update", "videolibrary") != 0 or overwrite: config.set_setting("updatelibrary_last_check", hoy.strftime('%Y-%m-%d'), "videolibrary") heading = config.get_localized_string(60389) p_dialog = platformtools.dialog_progress_bg( config.get_localized_string(20000), heading) p_dialog.update(0, '') show_list = [] for path, folders, files in filetools.walk( videolibrarytools.TVSHOWS_PATH): show_list.extend([ filetools.join(path, f) for f in files if f == "tvshow.nfo" ]) if show_list: t = float(100) / len(show_list) for i, tvshow_file in enumerate(show_list): head_nfo, serie = videolibrarytools.read_nfo(tvshow_file) if serie.local_episodes_path: local_ended = True if serie.infoLabels[ 'number_of_episodes'] == len( serie.local_episodes_list) else False if serie.infoLabels['status'].lower( ) == 'ended' and local_ended: serie.active = 0 filetools.write(tvshow_file, head_nfo + serie.tojson()) path = filetools.dirname(tvshow_file) logger.debug("serie=" + serie.contentSerieName) p_dialog.update(int(math.ceil((i + 1) * t)), heading, serie.contentSerieName) # Check the status of the series.library_playcounts of the Series in case it is incomplete try: estado = False # If we have not done the verification or do not have a playcount, we enter estado = config.get_setting("verify_playcount", "videolibrary") if not estado or estado == False or not serie.library_playcounts: # If it hasn't happened before, we do it now serie, estado = videolibrary.verify_playcount_series( serie, path ) # Also happens if a PlayCount is missing completely except: logger.error(traceback.format_exc()) else: if estado: # If the update was successful ... estado_verify_playcount_series = True # ... is checked to change the Video Library option interval = int(serie.active) # Could be the bool type if not serie.active: # if the series is not active discard if not overwrite: # Synchronize the episodes seen from the Kodi video library with that of Alpha, even if the series is deactivated try: if config.is_xbmc(): # If it's Kodi, we do it from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kod( filetools.join(path, 'tvshow.nfo')) except: logger.error(traceback.format_exc()) continue # Obtain the update date and the next scheduled for this series update_next = serie.update_next if update_next: y, m, d = update_next.split('-') update_next = datetime.date(int(y), int(m), int(d)) else: update_next = hoy update_last = serie.update_last if update_last: y, m, d = update_last.split('-') update_last = datetime.date(int(y), int(m), int(d)) else: update_last = hoy # if the series is active ... if overwrite or config.get_setting("updatetvshows_interval", "videolibrary") == 0: # ... force update regardless of interval serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada: update_next = hoy + datetime.timedelta(days=interval) elif interval == 1 and update_next <= hoy: # ...daily update serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada and update_last <= hoy - datetime.timedelta( days=7): # if it hasn't been updated for a week, change the interval to weekly interval = 7 update_next = hoy + datetime.timedelta(days=interval) elif interval == 7 and update_next <= hoy: # ... weekly update serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada: if update_last <= hoy - datetime.timedelta(days=14): # if it has not been updated for 2 weeks, change the interval to monthly interval = 30 update_next += datetime.timedelta(days=interval) elif interval == 30 and update_next <= hoy: # ... monthly update serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada: update_next += datetime.timedelta(days=interval) if serie_actualizada: update_last = hoy update_next = hoy + datetime.timedelta(days=interval) head_nfo, serie = videolibrarytools.read_nfo( tvshow_file) # Reread the .nfo, which has been modified if interval != int(serie.active) or update_next.strftime( '%Y-%m-%d' ) != serie.update_next or update_last.strftime( '%Y-%m-%d') != serie.update_last: serie.update_last = update_last.strftime('%Y-%m-%d') if update_next > hoy: serie.update_next = update_next.strftime('%Y-%m-%d') serie.active = interval serie.channel = "videolibrary" serie.action = "get_seasons" filetools.write(tvshow_file, head_nfo + serie.tojson()) if serie_actualizada: if config.get_setting("search_new_content", "videolibrary") == 0: # We update the Kodi video library: Find content in the series folder if config.is_xbmc() and config.get_setting( "videolibrary_kodi"): from platformcode import xbmc_videolibrary xbmc_videolibrary.update( folder=filetools.basename(path)) else: update_when_finished = True if estado_verify_playcount_series: # If any playcount has been changed, ... estado = config.set_setting( "verify_playcount", True, "videolibrary") # ... we update the Videolibrary option if config.get_setting( "search_new_content", "videolibrary") == 1 and update_when_finished: # We update the Kodi video library: Find content in all series if config.is_xbmc() and config.get_setting( "videolibrary_kodi"): from platformcode import xbmc_videolibrary xbmc_videolibrary.update() p_dialog.close() else: logger.debug("Not update the video library, it is disabled") except Exception as ex: logger.error("An error occurred while updating the series") template = "An exception of type %s occured. Arguments:\n%r" message = template % (type(ex).__name__, ex.args) logger.error(message) if p_dialog: p_dialog.close() from core.item import Item item_dummy = Item() videolibrary.list_movies(item_dummy, silent=True) if config.get_setting('trakt_sync'): from core import trakt_tools trakt_tools.update_all()
def update(path, p_dialog, i, t, serie, overwrite): logger.info("Updating " + path) insertados_total = 0 nfo_file = xbmc.translatePath(filetools.join(path, 'tvshow.nfo')) head_nfo, it = videolibrarytools.read_nfo(nfo_file) videolibrarytools.update_renumber_options(it, head_nfo, path) if not serie.library_url: serie = it category = serie.category # logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) )) for channel, url in serie.library_urls.items(): serie.channel = channel serie.url = url ###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial try: head_nfo, it = videolibrarytools.read_nfo( nfo_file) #Refresca el .nfo para recoger actualizaciones if it.emergency_urls: serie.emergency_urls = it.emergency_urls serie.category = category except: logger.error(traceback.format_exc()) channel_enabled = channeltools.is_enabled(serie.channel) if channel_enabled: heading = config.get_localized_string(20000) p_dialog.update( int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (serie.contentSerieName, serie.channel.capitalize())) try: pathchannels = filetools.join(config.get_runtime_path(), "channels", serie.channel + '.py') logger.info("loading channel: " + pathchannels + " " + serie.channel) if serie.library_filter_show: serie.show = serie.library_filter_show.get( serie.channel, serie.contentSerieName) obj = __import__('channels.%s' % serie.channel, fromlist=[pathchannels]) itemlist = obj.episodios(serie) try: if int(overwrite) == 3: # Sobrescribir todos los archivos (tvshow.nfo, 1x01.nfo, 1x01 [canal].json, 1x01.strm, etc...) insertados, sobreescritos, fallidos, notusedpath = videolibrarytools.save_tvshow( serie, itemlist) #serie= videolibrary.check_season_playcount(serie, serie.contentSeason) #if filetools.write(path + '/tvshow.nfo', head_nfo + it.tojson()): # serie.infoLabels['playcount'] = serie.playcount else: insertados, sobreescritos, fallidos = videolibrarytools.save_episodes( path, itemlist, serie, silent=True, overwrite=overwrite) #it = videolibrary.check_season_playcount(it, it.contentSeason) #if filetools.write(path + '/tvshow.nfo', head_nfo + it.tojson()): # serie.infoLabels['playcount'] = serie.playcount insertados_total += insertados except Exception as ex: logger.error( "Error when saving the chapters of the series") template = "An exception of type %s occured. Arguments:\n%r" message = template % (type(ex).__name__, ex.args) logger.error(message) except Exception as ex: logger.error("Error in obtaining the episodes of: %s" % serie.show) template = "An exception of type %s occured. Arguments:\n%r" message = template % (type(ex).__name__, ex.args) logger.error(message) else: logger.debug("Channel %s not active is not updated" % serie.channel) #Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa try: if config.is_xbmc(): #Si es Kodi, lo hacemos from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kod( filetools.join(path, 'tvshow.nfo')) except: logger.error(traceback.format_exc()) return insertados_total > 0
def check_for_update(overwrite=True): logger.info("Update Series...") p_dialog = None serie_actualizada = False update_when_finished = False hoy = datetime.date.today() estado_verify_playcount_series = False local_ended = True try: if config.get_setting("update", "videolibrary") != 0 or overwrite: config.set_setting("updatelibrary_last_check", hoy.strftime('%Y-%m-%d'), "videolibrary") heading = config.get_localized_string(60389) p_dialog = platformtools.dialog_progress_bg( config.get_localized_string(20000), heading) p_dialog.update(0, '') show_list = [] for path, folders, files in filetools.walk( videolibrarytools.TVSHOWS_PATH): show_list.extend([ filetools.join(path, f) for f in files if f == "tvshow.nfo" ]) if show_list: t = float(100) / len(show_list) for i, tvshow_file in enumerate(show_list): head_nfo, serie = videolibrarytools.read_nfo(tvshow_file) if serie.local_episodes_path: local_ended = True if serie.infoLabels[ 'number_of_episodes'] == len( serie.local_episodes_list) else False if serie.infoLabels['status'].lower( ) == 'ended' and local_ended: serie.active = 0 filetools.write(tvshow_file, head_nfo + serie.tojson()) path = filetools.dirname(tvshow_file) logger.info("serie=" + serie.contentSerieName) p_dialog.update(int(math.ceil((i + 1) * t)), heading, serie.contentSerieName) #Verificamos el estado del serie.library_playcounts de la Serie por si está incompleto try: estado = False #Si no hemos hecho la verificación o no tiene playcount, entramos estado = config.get_setting("verify_playcount", "videolibrary") if not estado or estado == False or not serie.library_playcounts: #Si no se ha pasado antes, lo hacemos ahora serie, estado = videolibrary.verify_playcount_series( serie, path ) #También se pasa si falta un PlayCount por completo except: logger.error(traceback.format_exc()) else: if estado: #Si ha tenido éxito la actualización... estado_verify_playcount_series = True #... se marca para cambiar la opción de la Videoteca interval = int(serie.active) # Podria ser del tipo bool if not serie.active: # si la serie no esta activa descartar if not overwrite: #Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa, aunque la serie esté desactivada try: if config.is_xbmc(): #Si es Kodi, lo hacemos from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kod( filetools.join(path, 'tvshow.nfo')) except: logger.error(traceback.format_exc()) continue # obtenemos las fecha de actualizacion y de la proxima programada para esta serie update_next = serie.update_next if update_next: y, m, d = update_next.split('-') update_next = datetime.date(int(y), int(m), int(d)) else: update_next = hoy update_last = serie.update_last if update_last: y, m, d = update_last.split('-') update_last = datetime.date(int(y), int(m), int(d)) else: update_last = hoy # si la serie esta activa ... if overwrite or config.get_setting("updatetvshows_interval", "videolibrary") == 0: # ... forzar actualizacion independientemente del intervalo serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada: update_next = hoy + datetime.timedelta(days=interval) elif interval == 1 and update_next <= hoy: # ...actualizacion diaria serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada and update_last <= hoy - datetime.timedelta( days=7): # si hace una semana q no se actualiza, pasar el intervalo a semanal interval = 7 update_next = hoy + datetime.timedelta(days=interval) elif interval == 7 and update_next <= hoy: # ...actualizacion semanal serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada: if update_last <= hoy - datetime.timedelta(days=14): # si hace 2 semanas q no se actualiza, pasar el intervalo a mensual interval = 30 update_next += datetime.timedelta(days=interval) elif interval == 30 and update_next <= hoy: # ...actualizacion mensual serie_actualizada = update(path, p_dialog, i, t, serie, overwrite) if not serie_actualizada: update_next += datetime.timedelta(days=interval) if serie_actualizada: update_last = hoy update_next = hoy + datetime.timedelta(days=interval) head_nfo, serie = videolibrarytools.read_nfo( tvshow_file) #Vuelve a leer el.nfo, que ha sido modificado if interval != int(serie.active) or update_next.strftime( '%Y-%m-%d' ) != serie.update_next or update_last.strftime( '%Y-%m-%d') != serie.update_last: serie.update_last = update_last.strftime('%Y-%m-%d') if update_next > hoy: serie.update_next = update_next.strftime('%Y-%m-%d') serie.active = interval serie.channel = "videolibrary" serie.action = "get_seasons" filetools.write(tvshow_file, head_nfo + serie.tojson()) if serie_actualizada: if config.get_setting("search_new_content", "videolibrary") == 0: # Actualizamos la videoteca de Kodi: Buscar contenido en la carpeta de la serie if config.is_xbmc() and config.get_setting( "videolibrary_kodi"): from platformcode import xbmc_videolibrary xbmc_videolibrary.update( folder=filetools.basename(path)) else: update_when_finished = True if estado_verify_playcount_series: #Si se ha cambiado algún playcount, ... estado = config.set_setting( "verify_playcount", True, "videolibrary" ) #... actualizamos la opción de Videolibrary if config.get_setting( "search_new_content", "videolibrary") == 1 and update_when_finished: # Actualizamos la videoteca de Kodi: Buscar contenido en todas las series if config.is_xbmc() and config.get_setting( "videolibrary_kodi"): from platformcode import xbmc_videolibrary xbmc_videolibrary.update() p_dialog.close() else: logger.info("Not update the video library, it is disabled") except Exception as ex: logger.error("An error occurred while updating the series") template = "An exception of type %s occured. Arguments:\n%r" message = template % (type(ex).__name__, ex.args) logger.error(message) if p_dialog: p_dialog.close() from core.item import Item item_dummy = Item() videolibrary.list_movies(item_dummy, silent=True) if config.get_setting('trakt_sync'): from core import trakt_tools trakt_tools.update_all()
def get_results(nfo_path, root, Type, local=False): value = 0 if Type == 'movie': folder = "folder_movies" else: folder = "folder_tvshows" if filetools.exists(nfo_path): # We synchronize the episodes seen from the Kodi video library with that of KoD from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kod(nfo_path) head_nfo, item = videolibrarytools.read_nfo(nfo_path) # If you have not read the .nfo well, we will proceed to the next if not item: logger.error('.nfo erroneous in ' + str(nfo_path)) return Item(), 0 if len(item.library_urls) > 1: multichannel = True else: multichannel = False # continue loading the elements of the video library if Type == 'movie': item.path = filetools.split(nfo_path)[0] item.nfo = nfo_path sep = '/' if '/' in nfo_path else '\\' item.extra = filetools.join(config.get_setting("videolibrarypath"), config.get_setting(folder), item.path.split(sep)[-1]) strm_path = item.strm_path.replace("\\", "/").rstrip("/") if not item.thumbnail: item.thumbnail = item.infoLabels['thumbnail'] if '/' in item.path: item.strm_path = strm_path # If strm has been removed from kodi library, don't show it if not filetools.exists(filetools.join(item.path, filetools.basename(strm_path))) and not local: return Item(), 0 # Contextual menu: Mark as seen / not seen visto = item.library_playcounts.get(item.path.split(sep)[0], 0) item.infoLabels["playcount"] = visto if visto > 0: seen_text = config.get_localized_string(60016) counter = 0 else: seen_text = config.get_localized_string(60017) counter = 1 # Context menu: Delete series / channel channels_num = len(item.library_urls) if "downloads" in item.library_urls: channels_num -= 1 if channels_num > 1: delete_text = config.get_localized_string(60018) else: delete_text = config.get_localized_string(60019) item.context = [{"title": seen_text, "action": "mark_content_as_watched", "channel": "videolibrary", "playcount": counter}, {"title": delete_text, "action": "delete", "channel": "videolibrary", "multichannel": multichannel}] else: # Sometimes it gives random errors, for not finding the .nfo. Probably timing issues try: item.title = item.contentTitle item.path = filetools.split(nfo_path)[0] item.nfo = nfo_path sep = '/' if '/' in nfo_path else '\\' item.extra = filetools.join(config.get_setting("videolibrarypath"), config.get_setting(folder), item.path.split(sep)[-1]) # Contextual menu: Mark as seen / not seen visto = item.library_playcounts.get(item.contentTitle, 0) item.infoLabels["playcount"] = visto logger.debug('item\n' + str(item)) if visto > 0: seen_text = config.get_localized_string(60020) counter = 0 else: seen_text = config.get_localized_string(60021) counter = 1 except: logger.error('Not find: ' + str(nfo_path)) logger.error(traceback.format_exc()) return Item(), 0 # Context menu: Automatically search for new episodes or not if item.active and int(item.active) > 0: update_text = config.get_localized_string(60022) value = 0 else: update_text = config.get_localized_string(60023) value = 1 item.title += " [B]" + u"\u2022" + "[/B]" # Context menu: Delete series / channel channels_num = len(item.library_urls) if "downloads" in item.library_urls: channels_num -= 1 if channels_num > 1: delete_text = config.get_localized_string(60024) else: delete_text = config.get_localized_string(60025) item.context = [{"title": seen_text, "action": "mark_content_as_watched", "channel": "videolibrary", "playcount": counter}, {"title": update_text, "action": "mark_tvshow_as_updatable", "channel": "videolibrary", "active": value}, {"title": delete_text, "action": "delete", "channel": "videolibrary", "multichannel": multichannel}, {"title": config.get_localized_string(70269), "action": "update_tvshow", "channel": "videolibrary"}] if item.local_episodes_path == "": item.context.append({"title": config.get_localized_string(80048), "action": "add_local_episodes", "channel": "videolibrary"}) else: item.context.append({"title": config.get_localized_string(80049), "action": "remove_local_episodes", "channel": "videolibrary"}) else: item = Item() return item, value