|
|
|
|
@@ -2,25 +2,30 @@
|
|
|
|
|
# -*- Channel Community -*-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import re, inspect, xbmcgui
|
|
|
|
|
import re, inspect, mimetypes, xbmcgui
|
|
|
|
|
|
|
|
|
|
from core import httptools, jsontools, tmdb, support, filetools
|
|
|
|
|
from core.item import Item
|
|
|
|
|
from lib import unshortenit
|
|
|
|
|
from platformcode import config, platformtools, logger
|
|
|
|
|
from channelselector import get_thumb
|
|
|
|
|
from collections import OrderedDict
|
|
|
|
|
from core import servertools
|
|
|
|
|
|
|
|
|
|
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
|
|
|
|
try: lang = info_language[config.get_setting("info_language", "videolibrary")]
|
|
|
|
|
except: lang = 'it'
|
|
|
|
|
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
|
|
|
|
try:
|
|
|
|
|
lang = info_language[config.get_setting("info_language", "videolibrary")]
|
|
|
|
|
except:
|
|
|
|
|
lang = 'it'
|
|
|
|
|
|
|
|
|
|
defpage = ["", "20", "40", "60", "80", "100"]
|
|
|
|
|
defp = defpage[config.get_setting('pagination','community')]
|
|
|
|
|
defp = defpage[config.get_setting('pagination', 'community')]
|
|
|
|
|
disable_pagination = False
|
|
|
|
|
show_seasons = config.get_setting('show_seasons','community')
|
|
|
|
|
show_seasons = config.get_setting('show_seasons', 'community')
|
|
|
|
|
|
|
|
|
|
tmdb_api = 'a1ab8b8669da03637a4b98fa39c39228'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mainlist(item):
|
|
|
|
|
logger.debug()
|
|
|
|
|
|
|
|
|
|
@@ -38,19 +43,19 @@ def show_channels(item):
|
|
|
|
|
itemlist = []
|
|
|
|
|
|
|
|
|
|
# add context menu
|
|
|
|
|
context = [{"title": config.get_localized_string(50005), "action": "remove_channel", "channel": "community"}]
|
|
|
|
|
context = [{"title": config.get_localized_string(50005), "action": "remove_channel", "channel": "community"}]
|
|
|
|
|
|
|
|
|
|
# read json
|
|
|
|
|
json = load_and_check(item)
|
|
|
|
|
|
|
|
|
|
itemlist.append(Item(channel=item.channel,
|
|
|
|
|
title=support.typo(config.get_localized_string(70676),'bold color kod'),
|
|
|
|
|
title=support.typo(config.get_localized_string(70676), 'bold color kod'),
|
|
|
|
|
action='add_channel',
|
|
|
|
|
thumbnail=get_thumb('add.png')))
|
|
|
|
|
|
|
|
|
|
for key, channel in json['channels'].items():
|
|
|
|
|
path = filetools.dirname(channel['path']) # relative path
|
|
|
|
|
channel_json = load_json(channel) # read channel json
|
|
|
|
|
path = filetools.dirname(channel['path']) # relative path
|
|
|
|
|
channel_json = load_json(channel) # read channel json
|
|
|
|
|
|
|
|
|
|
# retrieve information from json
|
|
|
|
|
thumbnail = relative('thumbnail', channel_json, path)
|
|
|
|
|
@@ -59,13 +64,13 @@ def show_channels(item):
|
|
|
|
|
plot = channel_json['plot'] if 'plot' in channel_json else ''
|
|
|
|
|
|
|
|
|
|
itemlist.append(Item(channel=item.channel,
|
|
|
|
|
title=support.typo(channel['channel_name'],'bold'),
|
|
|
|
|
title=support.typo(channel['channel_name'], 'bold'),
|
|
|
|
|
url=channel['url'] if 'url' in channel else path,
|
|
|
|
|
thumbnail=thumbnail,
|
|
|
|
|
fanart=fanart,
|
|
|
|
|
plot=plot,
|
|
|
|
|
action='show_menu',
|
|
|
|
|
channel_id = key,
|
|
|
|
|
channel_id=key,
|
|
|
|
|
context=context,
|
|
|
|
|
path=path))
|
|
|
|
|
|
|
|
|
|
@@ -77,8 +82,7 @@ def show_menu(item):
|
|
|
|
|
logger.debug()
|
|
|
|
|
itemlist = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if item.menu: # if second level menu
|
|
|
|
|
if item.menu: # if second level menu
|
|
|
|
|
get_sub_menu(item, item.menu, 'level2', itemlist)
|
|
|
|
|
else:
|
|
|
|
|
if type(item.url) == dict:
|
|
|
|
|
@@ -103,14 +107,12 @@ def show_menu(item):
|
|
|
|
|
itemlist += get_seasons(item)
|
|
|
|
|
elif key in ['episodes_list']:
|
|
|
|
|
itemlist += episodios(item, json, key)
|
|
|
|
|
elif key in ['links']:
|
|
|
|
|
elif key in ['links', 'find_links']:
|
|
|
|
|
itemlist += findvideos(item)
|
|
|
|
|
elif key in ['search'] and 'url' in json['search']:
|
|
|
|
|
search_json = json['search']
|
|
|
|
|
itemlist += get_search_menu(item, search_json)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if 'channel_name' in json and not 'disable_search' in json and 'search' not in json:
|
|
|
|
|
itemlist += get_search_menu(item, json, channel_name=json['channel_name'])
|
|
|
|
|
logger.debug('PAGINATION:', disable_pagination)
|
|
|
|
|
@@ -118,7 +120,7 @@ def show_menu(item):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def search(item, text):
|
|
|
|
|
logger.info('search',text)
|
|
|
|
|
logger.info('search', text)
|
|
|
|
|
itemlist = []
|
|
|
|
|
|
|
|
|
|
if item.custom_search:
|
|
|
|
|
@@ -142,6 +144,7 @@ def search(item, text):
|
|
|
|
|
|
|
|
|
|
return itemlist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def global_search(item, text):
|
|
|
|
|
itemlist = []
|
|
|
|
|
json = load_json(item)
|
|
|
|
|
@@ -149,7 +152,8 @@ def global_search(item, text):
|
|
|
|
|
|
|
|
|
|
if 'menu' in json:
|
|
|
|
|
for option in json['menu']:
|
|
|
|
|
if option in ['submenu', 'level2'] and 'seach' in json['menu'][option] and 'url' in json['menu'][option]['search']:
|
|
|
|
|
if option in ['submenu', 'level2'] and 'seach' in json['menu'][option] and 'url' in json['menu'][option][
|
|
|
|
|
'search']:
|
|
|
|
|
item.custom_search = json['menu'][option]['search']['url']
|
|
|
|
|
itemlist += search(item, text)
|
|
|
|
|
else:
|
|
|
|
|
@@ -158,15 +162,13 @@ def global_search(item, text):
|
|
|
|
|
if item.url:
|
|
|
|
|
itemlist += global_search(item, text)
|
|
|
|
|
|
|
|
|
|
if any(key in json for key in ['movies_list','tvshows_list', 'generic_list']):
|
|
|
|
|
if any(key in json for key in ['movies_list', 'tvshows_list', 'generic_list']):
|
|
|
|
|
itemlist += search(item, text)
|
|
|
|
|
return itemlist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def peliculas(item, json='', key='', itemlist=[]):
|
|
|
|
|
item.plot = item.thumb = item.fanart =''
|
|
|
|
|
item.plot = item.thumb = item.fanart = ''
|
|
|
|
|
logger.debug('PAGINATION:', item.disable_pagination)
|
|
|
|
|
if not json:
|
|
|
|
|
key = item.key
|
|
|
|
|
@@ -174,25 +176,28 @@ def peliculas(item, json='', key='', itemlist=[]):
|
|
|
|
|
else:
|
|
|
|
|
json = json[key]
|
|
|
|
|
|
|
|
|
|
# logger.debug('DEBUG:', json)
|
|
|
|
|
|
|
|
|
|
infoLabels = item.infoLabels if item.infoLabels else {}
|
|
|
|
|
contentType = 'tvshow' if 'tvshow' in key else 'movie'
|
|
|
|
|
itlist = filterkey = []
|
|
|
|
|
action = 'findvideos'
|
|
|
|
|
|
|
|
|
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search'] and not item.filterkey and not item.disable_pagination:
|
|
|
|
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
|
|
|
|
|
'search'] and not item.filterkey and not item.disable_pagination:
|
|
|
|
|
Pagination = int(defp) if defp.isdigit() else ''
|
|
|
|
|
else: Pagination = ''
|
|
|
|
|
else:
|
|
|
|
|
Pagination = ''
|
|
|
|
|
pag = item.page if item.page else 1
|
|
|
|
|
|
|
|
|
|
for i, option in enumerate(json):
|
|
|
|
|
if Pagination and (pag - 1) * Pagination > i: continue # pagination
|
|
|
|
|
if Pagination and i >= pag * Pagination: break
|
|
|
|
|
if item.filterkey and item.filterkey in option:
|
|
|
|
|
filterkey = [it.lower() for it in option[item.filterkey]] if type(option[item.filterkey]) == list else [option[item.filterkey].lower()]
|
|
|
|
|
filterkey = [it.lower() for it in option[item.filterkey]] if type(option[item.filterkey]) == list else [
|
|
|
|
|
option[item.filterkey].lower()]
|
|
|
|
|
else:
|
|
|
|
|
filterkey = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
title = option['title'] if 'title' in option else ''
|
|
|
|
|
|
|
|
|
|
if 'tvshows_list' in key and 'links' not in option:
|
|
|
|
|
@@ -200,26 +205,32 @@ def peliculas(item, json='', key='', itemlist=[]):
|
|
|
|
|
|
|
|
|
|
# filter elements
|
|
|
|
|
if (not item.filter or item.filter.lower() in filterkey) and item.search.lower() in title.lower() and title:
|
|
|
|
|
|
|
|
|
|
if 'generic_list' in key and 'links' not in option and 'url' in option:
|
|
|
|
|
option['links'] = []
|
|
|
|
|
option['links'].append({'url': option['url']})
|
|
|
|
|
option['url'] = ''
|
|
|
|
|
|
|
|
|
|
extra = set_extra_values(item, option, item.path)
|
|
|
|
|
|
|
|
|
|
infoLabels['year'] = option['year'] if 'year' in option else ''
|
|
|
|
|
infoLabels['tmdb_id'] = option['tmdb_id'] if 'tmdb_id' in option else ''
|
|
|
|
|
|
|
|
|
|
it = Item(channel = item.channel,
|
|
|
|
|
title = set_title(title, extra.language, extra.quality),
|
|
|
|
|
fulltitle = title,
|
|
|
|
|
show = title,
|
|
|
|
|
contentTitle = title if contentType == 'movie' else '',
|
|
|
|
|
contentSerieName = title if contentType != 'movie' else '',
|
|
|
|
|
contentType = contentType,
|
|
|
|
|
infoLabels = infoLabels,
|
|
|
|
|
url = extra.url,
|
|
|
|
|
path = item.path,
|
|
|
|
|
thumbnail = extra.thumb,
|
|
|
|
|
fanart = extra.fanart,
|
|
|
|
|
plot = extra.plot,
|
|
|
|
|
personal_plot = extra.plot,
|
|
|
|
|
action = action)
|
|
|
|
|
it = Item(channel=item.channel,
|
|
|
|
|
title=set_title(title, extra.language, extra.quality),
|
|
|
|
|
fulltitle=title,
|
|
|
|
|
show=title,
|
|
|
|
|
contentTitle=title if contentType == 'movie' else '',
|
|
|
|
|
contentSerieName=title if contentType != 'movie' else '',
|
|
|
|
|
contentType=contentType,
|
|
|
|
|
infoLabels=infoLabels,
|
|
|
|
|
url=extra.url,
|
|
|
|
|
path=item.path,
|
|
|
|
|
thumbnail=extra.thumb,
|
|
|
|
|
fanart=extra.fanart,
|
|
|
|
|
plot=extra.plot,
|
|
|
|
|
personal_plot=extra.plot,
|
|
|
|
|
action=action)
|
|
|
|
|
itlist.append(it)
|
|
|
|
|
|
|
|
|
|
if not 'generic_list' in key:
|
|
|
|
|
@@ -242,8 +253,10 @@ def get_seasons(item):
|
|
|
|
|
itemlist = []
|
|
|
|
|
infoLabels = item.infoLabels
|
|
|
|
|
json = item.url if type(item.url) == dict else item.url
|
|
|
|
|
if 'seasons_list' in json: json = json['seasons_list']
|
|
|
|
|
elif 'tvshows_list' in json: return show_menu(item)
|
|
|
|
|
if 'seasons_list' in json:
|
|
|
|
|
json = json['seasons_list']
|
|
|
|
|
elif 'tvshows_list' in json:
|
|
|
|
|
return show_menu(item)
|
|
|
|
|
for option in json:
|
|
|
|
|
infoLabels['season'] = option['season']
|
|
|
|
|
title = config.get_localized_string(60027) % option['season']
|
|
|
|
|
@@ -263,12 +276,14 @@ def get_seasons(item):
|
|
|
|
|
contentType='season' if show_seasons else 'tvshow',
|
|
|
|
|
path=extra.path))
|
|
|
|
|
|
|
|
|
|
if inspect.stack()[2][3] in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'get_newest'] or show_seasons == False:
|
|
|
|
|
if inspect.stack()[2][3] in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
|
|
|
|
|
'get_newest'] or show_seasons == False:
|
|
|
|
|
itlist = []
|
|
|
|
|
for item in itemlist:
|
|
|
|
|
itlist = episodios(item)
|
|
|
|
|
itemlist = itlist
|
|
|
|
|
if inspect.stack()[2][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'get_newest'] and defp and not item.disable_pagination:
|
|
|
|
|
if inspect.stack()[2][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
|
|
|
|
|
'get_newest'] and defp and not item.disable_pagination:
|
|
|
|
|
itemlist = pagination(item, itemlist)
|
|
|
|
|
|
|
|
|
|
if show_seasons:
|
|
|
|
|
@@ -277,10 +292,10 @@ def get_seasons(item):
|
|
|
|
|
return itemlist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def episodios(item, json ='', key='', itemlist =[]):
|
|
|
|
|
def episodios(item, json='', key='', itemlist=[]):
|
|
|
|
|
logger.debug()
|
|
|
|
|
infoLabels = item.infoLabels
|
|
|
|
|
itm=item
|
|
|
|
|
itm = item
|
|
|
|
|
|
|
|
|
|
if type(item.url) == dict:
|
|
|
|
|
if 'seasons_list' in item.url:
|
|
|
|
|
@@ -304,9 +319,11 @@ def episodios(item, json ='', key='', itemlist =[]):
|
|
|
|
|
ep = 1
|
|
|
|
|
season = infoLabels['season'] if 'season' in infoLabels else item.contentSeason if item.contentSeason else 1
|
|
|
|
|
|
|
|
|
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search'] and not show_seasons:
|
|
|
|
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes',
|
|
|
|
|
'search'] and not show_seasons:
|
|
|
|
|
Pagination = int(defp) if defp.isdigit() else ''
|
|
|
|
|
else: Pagination = ''
|
|
|
|
|
else:
|
|
|
|
|
Pagination = ''
|
|
|
|
|
pag = item.page if item.page else 1
|
|
|
|
|
|
|
|
|
|
# make items
|
|
|
|
|
@@ -315,7 +332,7 @@ def episodios(item, json ='', key='', itemlist =[]):
|
|
|
|
|
if Pagination and i >= pag * Pagination: break
|
|
|
|
|
# build numeration of episodes
|
|
|
|
|
numeration = option['number'] if 'number' in option else option['title']
|
|
|
|
|
match = support.match(numeration , patron=r'(?P<season>\d+)x(?P<episode>\d+)').match
|
|
|
|
|
match = support.match(numeration, patron=r'(?P<season>\d+)x(?P<episode>\d+)').match
|
|
|
|
|
if match:
|
|
|
|
|
episode_number = match[1]
|
|
|
|
|
ep = int(match[1]) + 1
|
|
|
|
|
@@ -338,25 +355,25 @@ def episodios(item, json ='', key='', itemlist =[]):
|
|
|
|
|
title = '%sx%s%s' % (season_number, episode_number, title)
|
|
|
|
|
extra = set_extra_values(item, option, item.path)
|
|
|
|
|
if not item.filterseason or season_number == int(item.filterseason):
|
|
|
|
|
itemlist.append(Item(channel = item.channel,
|
|
|
|
|
title = set_title(title, extra.language, extra.quality),
|
|
|
|
|
fulltitle = item.fulltitle,
|
|
|
|
|
show = item.show,
|
|
|
|
|
url = option,
|
|
|
|
|
action = 'findvideos',
|
|
|
|
|
plot = extra.plot,
|
|
|
|
|
thumbnail= extra.thumb if extra.thumb else item.thumbnail,
|
|
|
|
|
fanart = extra.fanart,
|
|
|
|
|
contentSeason = season_number,
|
|
|
|
|
contentEpisode = episode_number,
|
|
|
|
|
infoLabels = infoLabels,
|
|
|
|
|
contentType = 'episode',
|
|
|
|
|
path = item.path))
|
|
|
|
|
itemlist.append(Item(channel=item.channel,
|
|
|
|
|
title=set_title(title, extra.language, extra.quality),
|
|
|
|
|
fulltitle=item.fulltitle,
|
|
|
|
|
show=item.show,
|
|
|
|
|
url=option,
|
|
|
|
|
action='findvideos',
|
|
|
|
|
plot=extra.plot,
|
|
|
|
|
thumbnail=extra.thumb if extra.thumb else item.thumbnail,
|
|
|
|
|
fanart=extra.fanart,
|
|
|
|
|
contentSeason=season_number,
|
|
|
|
|
contentEpisode=episode_number,
|
|
|
|
|
infoLabels=infoLabels,
|
|
|
|
|
contentType='episode',
|
|
|
|
|
path=item.path))
|
|
|
|
|
|
|
|
|
|
# if showseason
|
|
|
|
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'get_newest', 'search']:
|
|
|
|
|
if show_seasons and not item.filterseason:
|
|
|
|
|
itm.contentType='season'
|
|
|
|
|
itm.contentType = 'season'
|
|
|
|
|
season_list = []
|
|
|
|
|
for item in itemlist:
|
|
|
|
|
if item.contentSeason not in season_list:
|
|
|
|
|
@@ -371,7 +388,7 @@ def episodios(item, json ='', key='', itemlist =[]):
|
|
|
|
|
url=itm.url,
|
|
|
|
|
action='episodios',
|
|
|
|
|
contentSeason=season,
|
|
|
|
|
contentType = 'episode',
|
|
|
|
|
contentType='episode',
|
|
|
|
|
infoLabels=infoLabels,
|
|
|
|
|
filterseason=str(season),
|
|
|
|
|
path=item.path))
|
|
|
|
|
@@ -391,17 +408,46 @@ def episodios(item, json ='', key='', itemlist =[]):
|
|
|
|
|
|
|
|
|
|
# Find Servers
|
|
|
|
|
def findvideos(item):
|
|
|
|
|
logger.debug()
|
|
|
|
|
# logger.debug('DEBUG', item)
|
|
|
|
|
item.contentTitle = item.fulltitle
|
|
|
|
|
itemlist = []
|
|
|
|
|
json = []
|
|
|
|
|
if 'links' in item.url:
|
|
|
|
|
json = item.url['links']
|
|
|
|
|
elif 'find_links' in item.url:
|
|
|
|
|
for link in item.url['find_links']:
|
|
|
|
|
link['url'] = unshortenit.findlinks(link['url'])
|
|
|
|
|
mimetype = findS = None
|
|
|
|
|
mimetype = mimetypes.MimeTypes().guess_type(link['url'])[0]
|
|
|
|
|
if mimetype is None:
|
|
|
|
|
findS = servertools.get_server_from_url(link['url'])
|
|
|
|
|
if mimetype is None and findS is None:
|
|
|
|
|
data = support.match(link['url']).data
|
|
|
|
|
itemlist_url = servertools.find_video_items(data=data)
|
|
|
|
|
if len(itemlist_url):
|
|
|
|
|
for item_url in itemlist_url:
|
|
|
|
|
valid = True
|
|
|
|
|
patterns = link.get('patterns', False)
|
|
|
|
|
if patterns:
|
|
|
|
|
valid = False
|
|
|
|
|
for pattern in patterns:
|
|
|
|
|
match = re.search(pattern, item_url.url)
|
|
|
|
|
if match:
|
|
|
|
|
valid = True
|
|
|
|
|
break
|
|
|
|
|
if valid:
|
|
|
|
|
json.append({"url": item_url.url})
|
|
|
|
|
else:
|
|
|
|
|
json.append(link)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
json = item.url
|
|
|
|
|
url = item.url
|
|
|
|
|
item.url = {}
|
|
|
|
|
json.append({"url": url})
|
|
|
|
|
|
|
|
|
|
# support.dbg()
|
|
|
|
|
for option in json:
|
|
|
|
|
extra = set_extra_values(item, option, item.path)
|
|
|
|
|
|
|
|
|
|
itemlist.append(
|
|
|
|
|
item.clone(url=option['url'],
|
|
|
|
|
action='play',
|
|
|
|
|
@@ -409,32 +455,34 @@ def findvideos(item):
|
|
|
|
|
contentLanguage=extra.language,
|
|
|
|
|
extraInfo=extra.info))
|
|
|
|
|
|
|
|
|
|
videolibrary = item.url.get('videolibrary', True)
|
|
|
|
|
item.autoplay = item.url.get('autoplay', False)
|
|
|
|
|
|
|
|
|
|
item.url = '' # do not pass referer
|
|
|
|
|
return support.server(item, itemlist=itemlist)
|
|
|
|
|
return support.server(item, itemlist=itemlist, Videolibrary=videolibrary)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################ Menu ################################
|
|
|
|
|
|
|
|
|
|
def get_menu(item, json, key, itemlist=[]):
|
|
|
|
|
logger.debug()
|
|
|
|
|
json = json[key]
|
|
|
|
|
for option in json:
|
|
|
|
|
title = option['title'] if 'title' in option else json[option] if 'search' not in option else ''
|
|
|
|
|
extra = set_extra_values(item, option, item.path)
|
|
|
|
|
level2 = option if 'level2' in option else []
|
|
|
|
|
it = Item(channel = item.channel,
|
|
|
|
|
title = support.typo(title, 'bullet bold'),
|
|
|
|
|
fulltitle = title,
|
|
|
|
|
show = title,
|
|
|
|
|
url = extra.url,
|
|
|
|
|
path = item.path,
|
|
|
|
|
thumbnail = extra.thumb,
|
|
|
|
|
fanart = extra.fanart,
|
|
|
|
|
plot = extra.plot,
|
|
|
|
|
action = 'show_menu',
|
|
|
|
|
menu = level2 if not item.menu else None,
|
|
|
|
|
filterkey = extra.filterkey,
|
|
|
|
|
filter = extra.filter)
|
|
|
|
|
level2 = option if 'level2' in option else []
|
|
|
|
|
it = Item(channel=item.channel,
|
|
|
|
|
title=support.typo(title, 'bullet bold'),
|
|
|
|
|
fulltitle=title,
|
|
|
|
|
show=title,
|
|
|
|
|
url=extra.url,
|
|
|
|
|
path=item.path,
|
|
|
|
|
thumbnail=extra.thumb,
|
|
|
|
|
fanart=extra.fanart,
|
|
|
|
|
plot=extra.plot,
|
|
|
|
|
action='show_menu',
|
|
|
|
|
menu=level2 if not item.menu else None,
|
|
|
|
|
filterkey=extra.filterkey,
|
|
|
|
|
filter=extra.filter)
|
|
|
|
|
if title:
|
|
|
|
|
itemlist.append(it)
|
|
|
|
|
|
|
|
|
|
@@ -442,7 +490,7 @@ def get_menu(item, json, key, itemlist=[]):
|
|
|
|
|
get_search_menu(it, json, itemlist)
|
|
|
|
|
|
|
|
|
|
elif 'submenu' in option:
|
|
|
|
|
get_sub_menu(it, option, 'submenu' ,itemlist)
|
|
|
|
|
get_sub_menu(it, option, 'submenu', itemlist)
|
|
|
|
|
|
|
|
|
|
for item in itemlist:
|
|
|
|
|
if not item.thumbnail: support.thumb(item)
|
|
|
|
|
@@ -463,20 +511,20 @@ def get_sub_menu(item, json, key, itemlist=[]):
|
|
|
|
|
extra = set_extra_values(item, json[option], item.path)
|
|
|
|
|
if not extra.url: extra.url = item.url
|
|
|
|
|
filterkey = option
|
|
|
|
|
level2 = option if 'level2' in option else []
|
|
|
|
|
it = Item(channel = item.channel,
|
|
|
|
|
title = support.typo(title,'submenu'),
|
|
|
|
|
fulltitle = title,
|
|
|
|
|
show = title,
|
|
|
|
|
url = extra.url,
|
|
|
|
|
path = item.path,
|
|
|
|
|
thumbnail = extra.thumb,
|
|
|
|
|
fanart = extra.fanart,
|
|
|
|
|
plot = extra.plot,
|
|
|
|
|
action = 'show_menu',
|
|
|
|
|
menu = level2 if not item.menu else None,
|
|
|
|
|
filterkey = filterkey,
|
|
|
|
|
description = extra.description)
|
|
|
|
|
level2 = option if 'level2' in option else []
|
|
|
|
|
it = Item(channel=item.channel,
|
|
|
|
|
title=support.typo(title, 'submenu'),
|
|
|
|
|
fulltitle=title,
|
|
|
|
|
show=title,
|
|
|
|
|
url=extra.url,
|
|
|
|
|
path=item.path,
|
|
|
|
|
thumbnail=extra.thumb,
|
|
|
|
|
fanart=extra.fanart,
|
|
|
|
|
plot=extra.plot,
|
|
|
|
|
action='show_menu',
|
|
|
|
|
menu=level2 if not item.menu else None,
|
|
|
|
|
filterkey=filterkey,
|
|
|
|
|
description=extra.description)
|
|
|
|
|
itemlist.append(it)
|
|
|
|
|
|
|
|
|
|
if 'search' in option:
|
|
|
|
|
@@ -500,7 +548,7 @@ def get_search_menu(item, json='', itemlist=[], channel_name=''):
|
|
|
|
|
extra = set_extra_values(item, json, item.path)
|
|
|
|
|
|
|
|
|
|
itemlist.append(Item(channel=item.channel,
|
|
|
|
|
title=support.typo(title,'submenu bold'),
|
|
|
|
|
title=support.typo(title, 'submenu bold'),
|
|
|
|
|
fulltitle=title,
|
|
|
|
|
show=title,
|
|
|
|
|
thumbnail=extra.thumb,
|
|
|
|
|
@@ -515,7 +563,7 @@ def get_search_menu(item, json='', itemlist=[], channel_name=''):
|
|
|
|
|
return itemlist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def submenu(item, json, key, itemlist = [], filter_list = []):
|
|
|
|
|
def submenu(item, json, key, itemlist=[], filter_list=[]):
|
|
|
|
|
logger.debug(item)
|
|
|
|
|
import sys
|
|
|
|
|
if sys.version_info[0] >= 3:
|
|
|
|
|
@@ -527,8 +575,10 @@ def submenu(item, json, key, itemlist = [], filter_list = []):
|
|
|
|
|
if type(item.description) == dict:
|
|
|
|
|
description = item.description
|
|
|
|
|
else:
|
|
|
|
|
if ':/' in item.description: url = item.description
|
|
|
|
|
else: url = filetools.join(item.path, item.description)
|
|
|
|
|
if ':/' in item.description:
|
|
|
|
|
url = item.description
|
|
|
|
|
else:
|
|
|
|
|
url = filetools.join(item.path, item.description)
|
|
|
|
|
description = load_json(url, no_order=True)
|
|
|
|
|
else:
|
|
|
|
|
description = None
|
|
|
|
|
@@ -585,8 +635,11 @@ def filter_thread(filter, key, item, description):
|
|
|
|
|
results = tmdb_inf.results[0]
|
|
|
|
|
id = results['id']
|
|
|
|
|
if id:
|
|
|
|
|
thumbnail = 'https://image.tmdb.org/t/p/original' + results['profile_path'] if results['profile_path'] else item.thumbnail
|
|
|
|
|
json_file = httptools.downloadpage('http://api.themoviedb.org/3/person/'+ str(id) + '?api_key=' + tmdb_api + '&language=en', use_requests=True).data
|
|
|
|
|
thumbnail = 'https://image.tmdb.org/t/p/original' + results['profile_path'] if results[
|
|
|
|
|
'profile_path'] else item.thumbnail
|
|
|
|
|
json_file = httptools.downloadpage(
|
|
|
|
|
'http://api.themoviedb.org/3/person/' + str(id) + '?api_key=' + tmdb_api + '&language=en',
|
|
|
|
|
use_requests=True).data
|
|
|
|
|
plot += jsontools.load(json_file)['biography']
|
|
|
|
|
|
|
|
|
|
if description:
|
|
|
|
|
@@ -596,7 +649,6 @@ def filter_thread(filter, key, item, description):
|
|
|
|
|
fanart = extra.fanart if extra.fanart else item.fanart
|
|
|
|
|
plot = extra.plot if extra.plot else item.plot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
item = Item(channel=item.channel,
|
|
|
|
|
title=support.typo(filter, 'bold'),
|
|
|
|
|
url=item.url,
|
|
|
|
|
@@ -674,25 +726,28 @@ def set_extra_values(item, json, path):
|
|
|
|
|
if key == 'quality':
|
|
|
|
|
ret.quality = json[key]
|
|
|
|
|
if ret.quality and not ret.quality[0].isdigit(): ret.quality = ret.quality.upper()
|
|
|
|
|
elif key == 'language':
|
|
|
|
|
elif key == 'language':
|
|
|
|
|
ret.language = json[key].upper()
|
|
|
|
|
elif key == 'plot':
|
|
|
|
|
elif key == 'plot':
|
|
|
|
|
ret.plot = json[key]
|
|
|
|
|
elif key in ['poster', 'thumbnail']:
|
|
|
|
|
ret.thumb = json[key] if ':/' in json[key] else filetools.join(path,json[key]) if '/' in json[key] else get_thumb(json[key])
|
|
|
|
|
elif key == 'fanart':
|
|
|
|
|
ret.fanart = json[key] if ':/' in json[key] else filetools.join(path,json[key])
|
|
|
|
|
ret.thumb = json[key] if ':/' in json[key] else filetools.join(path, json[key]) if '/' in json[
|
|
|
|
|
key] else get_thumb(json[key])
|
|
|
|
|
elif key == 'fanart':
|
|
|
|
|
ret.fanart = json[key] if ':/' in json[key] else filetools.join(path, json[key])
|
|
|
|
|
elif key in ['url', 'link']:
|
|
|
|
|
ret.url = json[key] if ':/' in json[key] or type(json[key]) == dict else filetools.join(path,json[key])
|
|
|
|
|
elif key == 'seasons_list':
|
|
|
|
|
ret.url = json[key] if ':/' in json[key] or type(json[key]) == dict else filetools.join(path, json[key])
|
|
|
|
|
elif key == 'seasons_list':
|
|
|
|
|
ret.url = {}
|
|
|
|
|
ret.url['seasons_list'] = json['seasons_list']
|
|
|
|
|
elif key == 'episodes_list':
|
|
|
|
|
elif key == 'episodes_list':
|
|
|
|
|
ret.url = {}
|
|
|
|
|
ret.url['episodes_list'] = json['episodes_list']
|
|
|
|
|
elif key == 'links':
|
|
|
|
|
ret.url={}
|
|
|
|
|
ret.url['links'] = json[key]
|
|
|
|
|
elif key in ['links', 'find_links']:
|
|
|
|
|
ret.url = {}
|
|
|
|
|
ret.url[key] = json[key]
|
|
|
|
|
ret.url['videolibrary'] = json.get('videolibrary', True)
|
|
|
|
|
ret.url['autoplay'] = json.get('autoplay', False)
|
|
|
|
|
elif key == 'filter':
|
|
|
|
|
filterkey = json[key].keys()[0]
|
|
|
|
|
ret.filter = json[key][filterkey]
|
|
|
|
|
@@ -712,6 +767,7 @@ def set_extra_values(item, json, path):
|
|
|
|
|
if not ret.plot:
|
|
|
|
|
ret.plot = item.plot
|
|
|
|
|
|
|
|
|
|
logger.debug(ret.url)
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -721,8 +777,8 @@ def set_title(title, language='', quality='', info=''):
|
|
|
|
|
|
|
|
|
|
t = support.match(title, patron=r'\{([^\}]+)\}').match
|
|
|
|
|
if 'bold' not in t: t += ' bold'
|
|
|
|
|
title = re.sub(r'(\{[^\}]+\})','',title)
|
|
|
|
|
title = support.typo(title,t)
|
|
|
|
|
title = re.sub(r'(\{[^\}]+\})', '', title)
|
|
|
|
|
title = support.typo(title, t)
|
|
|
|
|
|
|
|
|
|
if quality:
|
|
|
|
|
title += support.typo(quality, '_ [] color kod bold')
|
|
|
|
|
@@ -744,14 +800,15 @@ def relative(key, json, path):
|
|
|
|
|
ret = ''
|
|
|
|
|
if key in json:
|
|
|
|
|
if key in ['thumbnail', 'poster']:
|
|
|
|
|
ret = json[key] if ':/' in json[key] else filetools.join(path,json[key]) if '/' in json[key] else get_thumb(json[key]) if json[key] else ''
|
|
|
|
|
ret = json[key] if ':/' in json[key] else filetools.join(path, json[key]) if '/' in json[
|
|
|
|
|
key] else get_thumb(json[key]) if json[key] else ''
|
|
|
|
|
else:
|
|
|
|
|
ret = json[key] if ':/' in json[key] else filetools.join(path,json[key]) if '/' in json[key] else ''
|
|
|
|
|
ret = json[key] if ':/' in json[key] else filetools.join(path, json[key]) if '/' in json[key] else ''
|
|
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def pagination(item, itemlist = []):
|
|
|
|
|
def pagination(item, itemlist=[]):
|
|
|
|
|
logger.debug()
|
|
|
|
|
itlist = []
|
|
|
|
|
|
|
|
|
|
@@ -764,12 +821,13 @@ def pagination(item, itemlist = []):
|
|
|
|
|
encoded_itemlist.append(it.tourl())
|
|
|
|
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search']:
|
|
|
|
|
Pagination = int(defp) if defp.isdigit() else ''
|
|
|
|
|
else: Pagination = ''
|
|
|
|
|
else:
|
|
|
|
|
Pagination = ''
|
|
|
|
|
pag = item.page if item.page else 1
|
|
|
|
|
|
|
|
|
|
for i, item in enumerate(itemlist):
|
|
|
|
|
if Pagination and (pag - 1) * Pagination > i: continue # pagination
|
|
|
|
|
if Pagination and i >= pag * Pagination: break # pagination
|
|
|
|
|
if Pagination and i >= pag * Pagination: break # pagination
|
|
|
|
|
|
|
|
|
|
itlist.append(item)
|
|
|
|
|
|
|
|
|
|
@@ -777,28 +835,30 @@ def pagination(item, itemlist = []):
|
|
|
|
|
if inspect.stack()[1][3] != 'get_newest':
|
|
|
|
|
itlist.append(
|
|
|
|
|
Item(channel=item.channel,
|
|
|
|
|
action = 'pagination',
|
|
|
|
|
contentType=item.contentType,
|
|
|
|
|
title=support.typo(config.get_localized_string(30992), 'color kod bold'),
|
|
|
|
|
fulltitle= item.fulltitle,
|
|
|
|
|
show= item.show,
|
|
|
|
|
url=item.url,
|
|
|
|
|
args=item.args,
|
|
|
|
|
page=pag + 1,
|
|
|
|
|
path=item.path,
|
|
|
|
|
media_type=item.media_type,
|
|
|
|
|
thumbnail=support.thumb(),
|
|
|
|
|
itemlist= encoded_itemlist))
|
|
|
|
|
action='pagination',
|
|
|
|
|
contentType=item.contentType,
|
|
|
|
|
title=support.typo(config.get_localized_string(30992), 'color kod bold'),
|
|
|
|
|
fulltitle=item.fulltitle,
|
|
|
|
|
show=item.show,
|
|
|
|
|
url=item.url,
|
|
|
|
|
args=item.args,
|
|
|
|
|
page=pag + 1,
|
|
|
|
|
path=item.path,
|
|
|
|
|
media_type=item.media_type,
|
|
|
|
|
thumbnail=support.thumb(),
|
|
|
|
|
itemlist=encoded_itemlist))
|
|
|
|
|
return itlist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_channel(item):
|
|
|
|
|
logger.debug()
|
|
|
|
|
channel_to_add = {}
|
|
|
|
|
json_file = ''
|
|
|
|
|
result = platformtools.dialog_select(config.get_localized_string(70676), [config.get_localized_string(70678), config.get_localized_string(70679)])
|
|
|
|
|
result = platformtools.dialog_select(config.get_localized_string(70676),
|
|
|
|
|
[config.get_localized_string(70678), config.get_localized_string(70679)])
|
|
|
|
|
if result == -1:
|
|
|
|
|
return
|
|
|
|
|
if result==0:
|
|
|
|
|
if result == 0:
|
|
|
|
|
file_path = xbmcgui.Dialog().browseSingle(1, config.get_localized_string(70680), 'files')
|
|
|
|
|
try:
|
|
|
|
|
channel_to_add['path'] = file_path
|
|
|
|
|
@@ -808,7 +868,7 @@ def add_channel(item):
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
elif result==1:
|
|
|
|
|
elif result == 1:
|
|
|
|
|
url = platformtools.dialog_input("", config.get_localized_string(70681), False)
|
|
|
|
|
try:
|
|
|
|
|
if url[:4] != 'http':
|
|
|
|
|
@@ -832,19 +892,21 @@ def add_channel(item):
|
|
|
|
|
community_json = jsontools.load(community_json.read())
|
|
|
|
|
id = 1
|
|
|
|
|
while str(id) in community_json['channels']:
|
|
|
|
|
id +=1
|
|
|
|
|
community_json['channels'][str(id)]=(channel_to_add)
|
|
|
|
|
id += 1
|
|
|
|
|
community_json['channels'][str(id)] = (channel_to_add)
|
|
|
|
|
|
|
|
|
|
with open(path, "w") as file:
|
|
|
|
|
file.write(jsontools.dump(community_json))
|
|
|
|
|
file.write(jsontools.dump(community_json))
|
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
|
|
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70683) % json_file['channel_name'])
|
|
|
|
|
platformtools.dialog_notification(config.get_localized_string(20000),
|
|
|
|
|
config.get_localized_string(70683) % json_file['channel_name'])
|
|
|
|
|
import xbmc
|
|
|
|
|
xbmc.sleep(1000)
|
|
|
|
|
platformtools.itemlist_refresh()
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_channel(item):
|
|
|
|
|
logger.debug()
|
|
|
|
|
|
|
|
|
|
@@ -857,9 +919,10 @@ def remove_channel(item):
|
|
|
|
|
to_delete = community_json['channels'][id]['channel_name']
|
|
|
|
|
del community_json['channels'][id]
|
|
|
|
|
with open(path, "w") as file:
|
|
|
|
|
file.write(jsontools.dump(community_json))
|
|
|
|
|
file.write(jsontools.dump(community_json))
|
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
|
|
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70684) % to_delete)
|
|
|
|
|
platformtools.dialog_notification(config.get_localized_string(20000),
|
|
|
|
|
config.get_localized_string(70684) % to_delete)
|
|
|
|
|
platformtools.itemlist_refresh()
|
|
|
|
|
return
|
|
|
|
|
|