Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -68,6 +68,7 @@ def peliculas(item):
|
||||
|
||||
deflang= 'Sub-ITA'
|
||||
action = 'check'
|
||||
# debug = True
|
||||
|
||||
page = None
|
||||
post = "page=" + str(item.page if item.page else 1) if item.page > 1 else None
|
||||
@@ -91,15 +92,15 @@ def peliculas(item):
|
||||
if item.args == 'incorso':
|
||||
patron = r'<a href="(?P<url>[^"]+)"[^>]+>(?P<title>[^<(]+)(?:\s*\((?P<year>\d+)\))?(?:\s*\((?P<lang>[A-za-z-]+)\))?</a>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s*<img width="[^"]+" height="[^"]+" src="(?P<thumb>[^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>(?P<plot>[^<]+)<'
|
||||
else:
|
||||
patron = r'href="(?P<url>[^"]+)"[^>]*>(?P<title>[^<]+)(?:\((?P<lang>ITA)\))?(?:(?P<year>\((\d+)\)))?</a>.*?<p[^>]+>(?P<plot>[^<]+).*?<img src="(?P<thumbnail>[^"]+)'
|
||||
patron = r'<img src="(?P<thumb>[^"]+)" alt="(?P<title>[^"\(]+)(?:\((?P<lang>[Ii][Tt][Aa])\))?(?:\s*\((?P<year>\d+)\))?[^"]*"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+><a class="[^"]+" href="(?P<url>[^"]+)">[^>]+>[^>]+>[^>]+><p[^>]+>(?:(?P<plot>[^<]+))?<'
|
||||
|
||||
return locals()
|
||||
|
||||
|
||||
def check(item):
|
||||
movie = support.match(item, patron=r'Episodi:</b> (\d*) Movie')
|
||||
anime_id = support.match(movie.data, patron=r'anime_id=(\d+)').match
|
||||
item.url = host + "/loading_anime?anime_id=" + anime_id
|
||||
# anime_id = support.match(movie.data, patron=r'anime_id=(\d+)').match
|
||||
# item.url = host + "/loading_anime?anime_id=" + anime_id
|
||||
if movie.match:
|
||||
item.contentType = 'movie'
|
||||
episodes = episodios(item)
|
||||
@@ -113,7 +114,7 @@ def check(item):
|
||||
@support.scrape
|
||||
def episodios(item):
|
||||
if item.contentType != 'movie': anime = True
|
||||
patron = r'<a href="(?P<url>[^"]+)"[^>]+>\s*(?P<title>[^<]+)</a>'
|
||||
patron = r'episodi-link-button"> <a href="(?P<url>[^"]+)"[^>]+>\s*(?P<title>[^<]+)</a>'
|
||||
return locals()
|
||||
|
||||
|
||||
|
||||
@@ -132,8 +132,10 @@ def findvideos(item):
|
||||
if 'sub' in lang.lower():
|
||||
language = 'Sub-' + language
|
||||
quality = url.split('/')[-1].split('?')[0]
|
||||
url += "|User-Agent=" + support.httptools.get_user_agent()
|
||||
|
||||
itemlist.append(item.clone(action="play", title=language, url=url, contentLanguage = language, quality = quality, order = quality.replace('p','').zfill(4), server='directo',))
|
||||
|
||||
itemlist.sort(key=lambda x: (x.title, x.order), reverse=False)
|
||||
return support.server(item, itemlist=itemlist)
|
||||
return support.server(item, itemlist=itemlist)
|
||||
|
||||
|
||||
@@ -55,6 +55,6 @@ def search(item, text):
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
url = support.match(item, patron=r'<a class="bot1" href="([^"]+)"').match
|
||||
url = support.match(item, patron=r'<a class=["]?bot1["]? href="([^"]+)"').match
|
||||
url = support.httptools.downloadpage(url, followredirect=True).url
|
||||
return support.server(item, url)
|
||||
|
||||
@@ -566,6 +566,8 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
@return: the number of failed episodes
|
||||
"""
|
||||
logger.info()
|
||||
update = False
|
||||
exist = False
|
||||
episodelist = filter_list(episodelist, serie.action, path)
|
||||
# No episode list, nothing to save
|
||||
if not len(episodelist):
|
||||
@@ -574,6 +576,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
|
||||
# process local episodes
|
||||
local_episodes_path = ''
|
||||
local_episodelist = []
|
||||
nfo_path = filetools.join(path, "tvshow.nfo")
|
||||
head_nfo, item_nfo = read_nfo(nfo_path)
|
||||
if item_nfo.update_last:
|
||||
@@ -585,8 +588,51 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
return 0, 0, done
|
||||
item_nfo.local_episodes_path = local_episodes_path
|
||||
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
|
||||
|
||||
if local_episodes_path:
|
||||
process_local_episodes(local_episodes_path, path)
|
||||
from platformcode.xbmc_videolibrary import check_if_exist, clean
|
||||
if check_if_exist(local_episodes_path):
|
||||
exist = True
|
||||
local_episodelist += get_local_content(local_episodes_path)
|
||||
clean_list = []
|
||||
for f in filetools.listdir(path):
|
||||
match = scrapertools.find_single_match(f, r'[S]?(\d+)(?:x|_|\.)?[E]?(\d+)')
|
||||
if match:
|
||||
ep = '%dx%02d' % (int(match[0]), int(match[1]))
|
||||
if ep in local_episodelist:
|
||||
del_file = filetools.join(path, f)
|
||||
filetools.remove(del_file)
|
||||
if f.endswith('strm'):
|
||||
sep = '\\' if '\\' in path else '/'
|
||||
clean_path = path[:-len(sep)] if path.endswith(sep) else path
|
||||
clean_path = '%/' + clean_path.split(sep)[-1] + '/' + f
|
||||
clean_list.append(clean_path)
|
||||
clean_list.append(clean_path.replace('/','\\'))
|
||||
|
||||
# from core.support import dbg;dbg()
|
||||
if clean_list:
|
||||
clean(clean_list)
|
||||
update = True
|
||||
|
||||
if item_nfo.local_episodes_list:
|
||||
difference = [x for x in item_nfo.local_episodes_list if (x not in local_episodelist)]
|
||||
if len(difference) > 0:
|
||||
clean_list = []
|
||||
for f in difference:
|
||||
sep = '\\' if '\\' in local_episodes_path else '/'
|
||||
clean_path = local_episodes_path[:-len(sep)] if local_episodes_path.endswith(sep) else local_episodes_path
|
||||
clean_path = '%/' + clean_path.split(sep)[-1] + '/%' + f.replace('x','%') + '%'
|
||||
clean_list.append(clean_path)
|
||||
clean_list.append(clean_path.replace('/','\\'))
|
||||
from core.support import dbg;dbg()
|
||||
clean(clean_list)
|
||||
update = True
|
||||
|
||||
item_nfo.local_episodes_list = sorted(local_episodelist)
|
||||
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
|
||||
|
||||
else:
|
||||
process_local_episodes(local_episodes_path, path)
|
||||
|
||||
insertados = 0
|
||||
sobreescritos = 0
|
||||
@@ -672,7 +718,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
t = float(100) / len(new_episodelist)
|
||||
except:
|
||||
t = 0
|
||||
|
||||
local_episodelist += get_local_content(path)
|
||||
for i, e in enumerate(scraper.sort_episode_list(new_episodelist)):
|
||||
if not silent:
|
||||
p_dialog.update(int(math.ceil((i + 1) * t)), config.get_localized_string(60064), e.title)
|
||||
@@ -694,6 +740,10 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
nfo_path = filetools.join(path, "%s.nfo" % season_episode)
|
||||
json_path = filetools.join(path, ("%s [%s].json" % (season_episode, e.channel)).lower())
|
||||
|
||||
if season_episode in local_episodelist:
|
||||
logger.info('Skipped: Serie ' + serie.contentSerieName + ' ' + season_episode + ' available as local content')
|
||||
continue
|
||||
|
||||
# check if the episode has been downloaded
|
||||
if filetools.join(path, "%s [downloads].json" % season_episode) in ficheros:
|
||||
logger.info('INFO: "%s" episode %s has been downloaded, skipping it' % (serie.contentSerieName, season_episode))
|
||||
@@ -778,7 +828,7 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
if not silent:
|
||||
p_dialog.close()
|
||||
|
||||
if news_in_playcounts or emergency_urls_succ or serie.infoLabels["status"] == "Ended" or serie.infoLabels["status"] == "Canceled":
|
||||
if news_in_playcounts or emergency_urls_succ or serie.infoLabels["status"] == "Ended" or serie.infoLabels["status"] == "Canceled" or update:
|
||||
# If there are new episodes we mark them as unseen on tvshow.nfo ...
|
||||
tvshow_path = filetools.join(path, "tvshow.nfo")
|
||||
try:
|
||||
@@ -817,14 +867,16 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
|
||||
filetools.write(tvshow_path, head_nfo + tvshow_item.tojson())
|
||||
except:
|
||||
logger.error("Error updating tvshow.nfo")
|
||||
logger.error("Unable to save %s emergency urls in the video library" % tvshow_item.contentSerieName)
|
||||
logger.error("Unable to save %s emergency urls in the video library" % serie.contentSerieName)
|
||||
logger.error(traceback.format_exc())
|
||||
fallidos = -1
|
||||
else:
|
||||
# ... if it was correct we update the Kodi video library
|
||||
if config.is_xbmc() and config.get_setting("videolibrary_kodi") and not silent:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.update()
|
||||
update = True
|
||||
if update:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.update()
|
||||
|
||||
if fallidos == len(episodelist):
|
||||
fallidos = -1
|
||||
@@ -900,6 +952,19 @@ def process_local_episodes(local_episodes_path, path):
|
||||
|
||||
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
|
||||
|
||||
def get_local_content(path):
|
||||
logger.info()
|
||||
|
||||
local_episodelist = []
|
||||
for root, folders, files in filetools.walk(path):
|
||||
for file in files:
|
||||
season_episode = scrapertools.get_season_and_episode(file)
|
||||
if season_episode == "" or filetools.exists(filetools.join(path, "%s.strm" % season_episode)):
|
||||
continue
|
||||
local_episodelist.append(season_episode)
|
||||
local_episodelist = sorted(set(local_episodelist))
|
||||
|
||||
return local_episodelist
|
||||
|
||||
def add_movie(item):
|
||||
"""
|
||||
|
||||
@@ -904,7 +904,7 @@ def clean(path_list=[]):
|
||||
if path.startswith("special://"):
|
||||
path = path.replace('/profile/', '/%/').replace('/home/userdata/', '/%/')
|
||||
sep = '/'
|
||||
elif '://' in path:
|
||||
elif '://' in path or path.startswith('/') or path.startswith('%/'):
|
||||
sep = '/'
|
||||
else: sep = os.sep
|
||||
|
||||
@@ -1000,6 +1000,18 @@ def clean(path_list=[]):
|
||||
xbmc.sleep(1000)
|
||||
progress.close()
|
||||
|
||||
def check_if_exist(path):
|
||||
if '\\' in path: sep = '\\'
|
||||
else: sep = '/'
|
||||
if path.endswith(sep): path = path[:-len(sep)]
|
||||
ret = False
|
||||
sql_path = '%' + sep + path.split(sep)[-1] + sep + '%'
|
||||
sql = 'SELECT idShow FROM tvshow_view where strPath LIKE "%s"' % sql_path
|
||||
logger.info('sql: ' + sql)
|
||||
nun_records, records = execute_sql_kodi(sql)
|
||||
if records:
|
||||
ret = True
|
||||
return ret
|
||||
|
||||
def execute_sql_kodi(sql):
|
||||
"""
|
||||
|
||||
@@ -29,27 +29,20 @@ gc.disable()
|
||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||
|
||||
|
||||
def mainlist(item):
|
||||
logger.info()
|
||||
|
||||
itemlist = [Item(channel=item.channel, title=config.get_localized_string(70276), action='new_search', mode='all', thumbnail=get_thumb("search.png")),
|
||||
|
||||
Item(channel=item.channel, title=config.get_localized_string(70741) % config.get_localized_string(30122), action='new_search', mode='movie', thumbnail=get_thumb("search_movie.png")),
|
||||
|
||||
Item(channel=item.channel, title=config.get_localized_string(70741) % config.get_localized_string(30123), action='new_search', mode='tvshow', thumbnail=get_thumb("search_tvshow.png")),
|
||||
|
||||
Item(channel=item.channel, title=config.get_localized_string(70741) % config.get_localized_string(70314), action='new_search', page=1, mode='person', thumbnail=get_thumb("search_star.png")),
|
||||
|
||||
Item(channel=item.channel, title=config.get_localized_string(59995), action='saved_search', thumbnail=get_thumb('search.png')),
|
||||
|
||||
Item(channel=item.channel, title=config.get_localized_string(60420), action='sub_menu', thumbnail=get_thumb('search.png')),
|
||||
|
||||
Item(channel=item.channel, title=typo(config.get_localized_string(59994), 'color kod bold'), action='opciones', thumbnail=get_thumb('setting_0.png')),
|
||||
|
||||
Item(channel=item.channel, title=typo(config.get_localized_string(59994), 'color kod bold'), action='setting_channel_new', thumbnail=get_thumb('setting_0.png')),
|
||||
Item(channel='shortcuts', title=typo(config.get_localized_string(70286), 'color kod bold'), action='SettingOnPosition', category=5, setting=1, thumbnail=get_thumb('setting_0.png'))]
|
||||
|
||||
itemlist = set_context(itemlist)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
@@ -57,31 +50,21 @@ def sub_menu(item):
|
||||
logger.info()
|
||||
|
||||
itemlist = [Item(channel=item.channel, action='genres_menu', title=config.get_localized_string(70306), mode='movie', thumbnail=get_thumb("movie_genre.png")),
|
||||
|
||||
Item(channel=item.channel, action='years_menu', title=config.get_localized_string(70742), mode='movie', thumbnail=get_thumb("movie_year.png")),
|
||||
|
||||
Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70307), search_type='list', list_type='movie/popular', mode='movie', thumbnail=get_thumb("movie_popular.png")),
|
||||
|
||||
Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70308), search_type='list', list_type='movie/top_rated', mode='movie', thumbnail=get_thumb("movie_top.png")),
|
||||
|
||||
Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70309), search_type='list', list_type='movie/now_playing', mode='movie', thumbnail=get_thumb("movie_now_playing.png")),
|
||||
|
||||
Item(channel=item.channel, action='genres_menu', title=config.get_localized_string(70310), mode='tvshow', thumbnail=get_thumb("tvshow_genre.png")),
|
||||
|
||||
Item(channel=item.channel, action='years_menu', title=config.get_localized_string(70743), mode='tvshow', thumbnail=get_thumb("tvshow_year.png")),
|
||||
|
||||
Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70311), search_type='list', list_type='tv/popular', mode='tvshow', thumbnail=get_thumb("popular.png")),
|
||||
|
||||
Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70312), search_type='list', list_type='tv/on_the_air', mode='tvshow', thumbnail=get_thumb("tvshow_on_the_air.png")),
|
||||
|
||||
Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70313), search_type='list', list_type='tv/top_rated', mode='tvshow', thumbnail=get_thumb("tvshow_top.png")),
|
||||
|
||||
Item(channel="tvmoviedb", action="mainlist", title=config.get_localized_string(70274), thumbnail=get_thumb("search.png"))]
|
||||
|
||||
itemlist = set_context(itemlist)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def saved_search(item):
|
||||
logger.info()
|
||||
|
||||
@@ -416,16 +399,15 @@ def get_channels(item):
|
||||
return channels_list, title_list
|
||||
|
||||
|
||||
def opciones(item):
|
||||
return setting_channel_new(item)
|
||||
|
||||
def settings(item):
|
||||
return platformtools.show_channel_settings(caption=config.get_localized_string(59993))
|
||||
|
||||
|
||||
def set_workers():
|
||||
workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None
|
||||
return workers
|
||||
|
||||
|
||||
def setting_channel_new(item):
|
||||
import xbmcgui
|
||||
|
||||
@@ -521,8 +503,8 @@ def setting_channel_new(item):
|
||||
|
||||
# Dialog to select
|
||||
ret = platformtools.dialog_multiselect(config.get_localized_string(59994), lista, preselect=preselect, useDetails=True)
|
||||
if not ret:
|
||||
return False # order cancel
|
||||
|
||||
if ret == None: return False # order cancel
|
||||
seleccionados = [ids[i] for i in ret]
|
||||
|
||||
# Save changes to search channels
|
||||
|
||||
Reference in New Issue
Block a user