Merge branch 'stable' into stable

This commit is contained in:
mac12m99
2019-11-01 21:30:27 +01:00
committed by GitHub
201 changed files with 5075 additions and 4327 deletions
+10 -6
View File
@@ -16,6 +16,8 @@ PLAYED = False
autoplay_node = {}
colorKOD = '0xFF65B3DA'
def context():
'''
@@ -36,7 +38,7 @@ def context():
context = context()
def show_option(channel, itemlist, text_color='yellow', thumbnail=None, fanart=None):
def show_option(channel, itemlist, text_color=colorKOD, thumbnail=None, fanart=None):
'''
Agrega la opcion Configurar AutoPlay en la lista recibida
@@ -54,8 +56,8 @@ def show_option(channel, itemlist, text_color='yellow', thumbnail=None, fanart=N
if thumbnail == None:
thumbnail = get_thumb('autoplay.png')
if fanart == None:
fanart = get_thumb('autoplay.png')
# if fanart == None:
# fanart = get_thumb('autoplay.png')
plot_autoplay = config.get_localized_string(60399)
itemlist.append(
@@ -63,10 +65,12 @@ def show_option(channel, itemlist, text_color='yellow', thumbnail=None, fanart=N
title=config.get_localized_string(60071),
action="autoplay_config",
text_color=text_color,
text_bold=True,
thumbnail=thumbnail,
fanart=fanart,
# fanart=fanart,
plot=plot_autoplay,
from_channel=channel
from_channel=channel,
folder=False
))
return itemlist
@@ -641,7 +645,7 @@ def get_languages(channel):
:return: list
'''
logger.info()
list_language = ['No filtrar']
list_language = ['Non filtrare']
list_controls, dict_settings = channeltools.get_channel_controls_settings(channel)
for control in list_controls:
try:
+5 -1
View File
@@ -192,6 +192,8 @@ def config_item(item, itemlist=[], typography='', active=False):
def renumber(itemlist, item='', typography=''):
log()
if 'fromchannel' in item:
item.channel = item.fromchannel if item.fromchannel else item.channel
# Seleziona la funzione Adatta, Menu Contestuale o Rinumerazione
if item:
settings_node = jsontools.get_node_from_file(item.channel, 'settings')
@@ -259,7 +261,7 @@ def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE,
return error(itemlist)
if len(EpisodeDict) >= len(itemlist):
for item in itemlist:
number = scrapertoolsV2.find_single_match(item.title, r'\d+')
number = scrapertoolsV2.find_single_match(item.title, r'\d+').lstrip("0")
item.title = typo(EpisodeDict[str(number)] + ' - ', typography) + item.title
else:
make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE)
@@ -268,6 +270,7 @@ def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE,
make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE)
def make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE, TITLE):
from core import support
log()
page = 1
EpList = []
@@ -324,6 +327,7 @@ def make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE
for item in itemlist:
# Otiene Numerazione Episodi
episode = int(scrapertoolsV2.find_single_match(item.title, r'\d+'))
log('EPISODE= ',episode)
number = episode + FirstOfSeason - addiction
count = number + addiction
# find = episode + FirstOfSeason
+101 -15
View File
@@ -8,11 +8,13 @@ import re
import time
import unicodedata
from core import filetools, jsontools, scraper, scrapertools, servertools, videolibrarytools, support
from core.downloader import Downloader
from core.item import Item
from platformcode import config, logger
from platformcode import platformtools
from core.support import log
STATUS_COLORS = {0: "orange", 1: "orange", 2: "green", 3: "red"}
STATUS_CODES = type("StatusCode", (), {"stoped": 0, "canceled": 1, "completed": 2, "error": 3})
@@ -20,6 +22,9 @@ DOWNLOAD_LIST_PATH = config.get_setting("downloadlistpath")
DOWNLOAD_PATH = config.get_setting("downloadpath")
STATS_FILE = os.path.join(config.get_data_path(), "servers.json")
FOLDER_MOVIES = config.get_setting("folder_movies")
FOLDER_TVSHOWS = config.get_setting("folder_tvshows")
TITLE_FILE = "[COLOR %s][%i%%][/COLOR] %s"
TITLE_TVSHOW = "[COLOR %s][%i%%][/COLOR] %s [%s]"
@@ -262,10 +267,20 @@ def menu(item):
def move_to_libray(item):
download_path = filetools.join(config.get_setting("downloadpath"), item.downloadFilename)
library_path = filetools.join(config.get_videolibrary_path(), *filetools.split(item.downloadFilename))
final_path = download_path
if item.contentType == 'movie':
FOLDER = FOLDER_MOVIES
path_title = "%s [%s]" % (item.contentTitle.strip(), item.infoLabels['IMDBNumber'])
move_path = filetools.join(config.get_videolibrary_path(), FOLDER, path_title)
else:
FOLDER = FOLDER_TVSHOWS
path_title = "%s [%s]" % (item.contentSerieName, item.infoLabels['IMDBNumber'])
move_path = filetools.join(config.get_videolibrary_path(), FOLDER)
download_path = filetools.join(config.get_setting("downloadpath"), item.downloadFilename)
library_path = filetools.join(move_path, *filetools.split(item.downloadFilename))
final_path = download_path
if config.get_setting("library_add", "downloads") == True and config.get_setting("library_move", "downloads") == True:
if not filetools.isdir(filetools.dirname(library_path)):
filetools.mkdir(filetools.dirname(library_path))
@@ -279,8 +294,35 @@ def move_to_libray(item):
if len(filetools.listdir(filetools.dirname(download_path))) == 0:
filetools.rmdir(filetools.dirname(download_path))
logger.info('ITEM = ' + str(item))
name = item.contentTitle if item.contentType == 'movie' else str(item.infoLabels['season']) + 'x' + str(item.infoLabels['episode']).zfill(2)
list_item = os.listdir(filetools.join(config.get_videolibrary_path(), FOLDER, path_title))
clean = False
for File in list_item:
filename = File.lower()
name = name.lower()
if filename.startswith(name) and (filename.endswith('.strm') or filename.endswith('.json') or filename.endswith('.nfo')):
clean = True
logger.info('Delete File: ' + str(os.path.join(config.get_videolibrary_path(), FOLDER, path_title, File)))
os.remove(os.path.join(config.get_videolibrary_path(), FOLDER, path_title, File))
from platformcode import xbmc_videolibrary
xbmc_videolibrary.update(FOLDER)
if clean == True:
import xbmc
while xbmc.getCondVisibility('Library.IsScanningVideo()'):
xbmc.sleep(500)
xbmc_videolibrary.clean()
if config.get_setting("library_add", "downloads") == True:
if config.get_setting("library_add", "downloads") == True and config.get_setting("library_move", "downloads") == False:
if filetools.isfile(final_path):
if item.contentType == "movie" and item.infoLabels["tmdb_id"]:
library_item = Item(title=config.get_localized_string(70228) % item.downloadFilename, channel="downloads",
@@ -293,7 +335,7 @@ def move_to_libray(item):
tvshow = Item(channel="downloads", contentType="tvshow",
infoLabels={"tmdb_id": item.infoLabels["tmdb_id"]})
videolibrarytools.save_tvshow(tvshow, [library_item])
def update_json(path, params):
item = Item().fromjson(filetools.read(path))
@@ -639,6 +681,8 @@ def select_server(item):
"downloadServer": {"url": play_items[seleccion - 1].url, "server": play_items[seleccion - 1].server}})
elif seleccion == 0:
update_json(item.path, {"downloadServer": {}})
if seleccion == 0:
update_json(item.path, {"downloadServer": {}})
platformtools.itemlist_refresh()
@@ -668,6 +712,11 @@ def start_download(item):
def get_episodes(item):
logger.info("contentAction: %s | contentChannel: %s | contentType: %s" % (
item.contentAction, item.contentChannel, item.contentType))
if 'dlseason' in item:
season = True
season_number = item.dlseason
else:
season = False
# El item que pretendemos descargar YA es un episodio
if item.contentType == "episode":
@@ -714,14 +763,43 @@ def get_episodes(item):
# Episodio, Temporada y Titulo
if not episode.contentTitle:
episode.contentTitle = re.sub("\[[^\]]+\]|\([^\)]+\)|\d*x\d*\s*-", "", episode.title).strip()
episode.contentTitle = re.sub(r"\[[^\]]+\]|\([^\)]+\)|\d*x\d*\s*-", "", episode.title).strip()
episode.downloadFilename = filetools.validate_path(os.path.join(item.downloadFilename, "%dx%0.2d - %s" % (
episode.contentSeason, episode.contentEpisodeNumber, episode.contentTitle.strip())))
itemlist.append(episode)
if season:
log('SEASON= ',season)
log(int(scrapertools.find_single_match(episode.title, r'(\d+)x')))
log(season_number,' ',type(season_number))
if scrapertools.find_single_match(episode.title, r'(\d+)x') == season_number:
itemlist.append(episode)
else:
itemlist.append(episode)
# Cualquier otro resultado no nos vale, lo ignoramos
else:
logger.info("Omitting invalid item: %s" % episode.tostring())
# if Multiple Languages or Qualities
list_lang = []
list_quality = []
for item in itemlist:
if not item.language: item.language = item.contentLanguage
if item.language not in list_lang: list_lang.append(item.language)
if item.infoLabels['quality'] not in list_quality: list_quality.append(item.infoLabels['quality'])
if len(list_lang) > 1:
selection = platformtools.dialog_select(config.get_localized_string(70725),list_lang)
it = []
for item in itemlist:
if not item.language: item.language = item.contentLanguage
if item.language == list_lang[selection]:
it.append(item)
itemlist = it
if len(list_quality) > 1:
selection = platformtools.dialog_select(config.get_localized_string(70726),list_quality)
it = []
for item in itemlist:
if item.infoLabels['quality'] == list_quality[selection]: it.append(item)
itemlist = it
return itemlist
@@ -759,11 +837,17 @@ def save_download(item):
del item.from_action
del item.from_channel
item.contentChannel = item.channel
item.contentAction = item.action
item.contentChannel = item.fromchannel if item.fromchannel else item.channel
item.contentAction = item.fromaction if item.fromaction else item.action
if item.contentType in ["tvshow", "episode", "season"]:
save_download_tvshow(item)
if 'download' in item:
heading = config.get_localized_string(70594) # <- Enter the season number
item.dlseason = platformtools.dialog_numeric(0, heading, '')
if item.dlseason:
save_download_tvshow(item)
else:
save_download_tvshow(item)
elif item.contentType == "movie":
save_download_movie(item)
@@ -804,7 +888,7 @@ def save_download_movie(item):
progreso.update(0, config.get_localized_string(60062))
item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentTitle.strip(), item.contentChannel))
item.downloadFilename = filetools.validate_path("%s [%s] [%s]" % (item.contentTitle.strip(), item.contentChannel, item.infoLabels['IMDBNumber']))
write_json(item)
@@ -825,9 +909,11 @@ def save_download_tvshow(item):
item.show = item.fulltitle
scraper.find_and_set_infoLabels(item)
item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentSerieName, item.contentChannel))
item.contentSerieName = item.fulltitle
item.downloadFilename = filetools.validate_path("%s [%s]" % (item.contentSerieName, item.infoLabels['IMDBNumber']))
if config.get_setting("lowerize_title", "videolibrary") == 0:
item.downloadFilename = item.downloadFilename.lower()
progreso.update(0, config.get_localized_string(70186), config.get_localized_string(70187) % item.contentChannel)
episodes = get_episodes(item)
@@ -842,7 +928,7 @@ def save_download_tvshow(item):
if not platformtools.dialog_yesno(config.get_localized_string(30101), config.get_localized_string(70189)):
platformtools.dialog_ok(config.get_localized_string(30101),
str(len(episodes)) + " capitulos de: " + item.contentSerieName,
str(len(episodes)) + config.get_localized_string(30110) + item.contentSerieName,
config.get_localized_string(30109))
else:
for i in episodes:
+1 -1
View File
@@ -49,7 +49,7 @@ def mainlist(item):
"action": "delFavourite",
"channel": "favorites",
"from_title": item.title},
{"title": "Renombrar",
{"title": config.get_localized_string(70278), # Rename
"action": "renameFavourite",
"channel": "favorites",
"from_title": item.title}
+2
View File
@@ -163,6 +163,8 @@ def load(item):
def check_conditions(_filter, list_item, item, list_language, list_quality, quality_count=0, language_count=0):
if not item.language: item.language = item.contentLanguage
is_language_valid = True
if _filter.language:
# logger.debug("title es %s" % item.title)
+2 -2
View File
@@ -28,8 +28,8 @@ perfil = [['0xFF0B7B92', '0xFF89FDFB', '0xFFACD5D4'],
['0xFFA5DEE5', '0xFFE0F9B5', '0xFFFEFDCA'],
['0xFFF23557', '0xFF22B2DA', '0xFFF0D43A']]
#color1, color2, color3 = ["white", "white", "white"]
color1, color2, color3 = perfil[__perfil__]
color1, color2, color3 = ["white", "white", "white"]
# color1, color2, color3 = perfil[__perfil__]
list_newest = []
list_newest_tourl = []
+2 -1
View File
@@ -15,6 +15,7 @@ from core import tmdb
from core.item import Item
from platformcode import config, logger
from platformcode import platformtools
from core.support import typo
addon = xbmcaddon.Addon('metadata.themoviedb.org')
def_lang = addon.getSetting('language')
@@ -719,7 +720,7 @@ def discover_list(item):
#if not 'similar' in item.list_type:
# itemlist.append(item.clone(title='Pagina Siguente', page=next_page))
#else:
itemlist.append(Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70065),
itemlist.append(Item(channel=item.channel, action='discover_list', title=typo(config.get_localized_string(30992), 'color kod bold'),
search_type=item.search_type, list_type=item.list_type, type=item.type, page=next_page))
return itemlist
+13 -13
View File
@@ -68,7 +68,7 @@ def list_movies(item, silent=False):
canal = generictools.verify_channel(canal_org)
try:
channel_verify = __import__('channels.%s' % canal, fromlist=["channels.%s" % canal])
logger.debug('El canal %s parece correcto' % channel_verify)
logger.debug('Channel %s seems correct' % channel_verify)
except:
dead_item = Item(multicanal=multicanal,
contentType='movie',
@@ -78,9 +78,9 @@ def list_movies(item, silent=False):
library_urls=new_item.library_urls,
infoLabels={'title': new_item.contentTitle})
if canal not in dead_list and canal not in zombie_list:
confirm = platformtools.dialog_yesno('Videoteca',
'Parece que el canal [COLOR red]%s[/COLOR] ya no existe.' % canal.upper(),
'Deseas eliminar los enlaces de este canal?')
confirm = platformtools.dialog_yesno(config.get_localized_string(30131),
config.get_localized_string(30132) % canal.upper(),
config.get_localized_string(30133))
elif canal in zombie_list:
confirm = False
@@ -198,9 +198,9 @@ def list_tvshows(item):
library_urls=item_tvshow.library_urls,
infoLabels={'title': item_tvshow.contentTitle})
if canal not in dead_list and canal not in zombie_list:
confirm = platformtools.dialog_yesno('Videoteca',
'Parece que el canal [COLOR red]%s[/COLOR] ya no existe.' % canal.upper(),
'Deseas eliminar los enlaces de este canal?')
confirm = platformtools.dialog_yesno(config.get_localized_string(30131),
config.get_localized_string(30132) % canal.upper(),
config.get_localized_string(30133))
elif canal in zombie_list:
confirm = False
@@ -238,7 +238,7 @@ def list_tvshows(item):
contador = 1
except:
logger.error('No encuentra: ' + str(tvshow_path))
logger.error('Not find: ' + str(tvshow_path))
logger.error(traceback.format_exc())
continue
@@ -435,7 +435,7 @@ def findvideos(item):
autoplay.set_status(False)
if not item.contentTitle or not item.strm_path:
logger.debug("No se pueden buscar videos por falta de parametros")
logger.debug("Unable to search for videos due to lack of parameters")
return []
content_title = filter(lambda c: c not in ":*?<>|\/", item.contentTitle.strip().lower())
@@ -533,7 +533,7 @@ def findvideos(item):
from core import servertools
list_servers = servertools.find_video_items(item_json)
except Exception, ex:
logger.error("Ha fallado la funcion findvideos para el canal %s" % nom_canal)
logger.error("The findvideos function for the channel %s failed" % nom_canal)
template = "An exception of type %s occured. Arguments:\n%r"
message = template % (type(ex).__name__, ex.args)
logger.error(message)
@@ -623,7 +623,7 @@ def update_videolibrary(item):
break
if ficheros and not strm:
logger.debug("Borrando carpeta de pelicula eliminada: %s" % raiz)
logger.debug("Deleting deleted movie folder: %s" % raiz)
filetools.rmdirtree(raiz)
@@ -668,7 +668,7 @@ def verify_playcount_series(item, path):
nfo_path = filetools.join(path, "tvshow.nfo")
head_nfo, it = videolibrarytools.read_nfo(nfo_path) #Obtenemos el .nfo de la Serie
if not hasattr(it, 'library_playcounts') or not it.library_playcounts: #Si el .nfo no tiene library_playcounts se lo creamos
logger.error('** No tiene PlayCount')
logger.error('** It does not have PlayCount')
it.library_playcounts = {}
# Obtenemos los archivos de los episodios
@@ -879,7 +879,7 @@ def delete(item):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.clean()
logger.info("Eliminados todos los enlaces")
logger.info("All links removed")
platformtools.itemlist_refresh()
# logger.info(item.contentTitle)