Fix e migliorie a Community channels
This commit is contained in:
@@ -608,7 +608,7 @@ def set_context_commands(item, parent_item):
|
|||||||
|
|
||||||
# elif item.contentSerieName:
|
# elif item.contentSerieName:
|
||||||
# Descargar serie
|
# Descargar serie
|
||||||
elif item.contentType == "tvshow" and item.action in ["episodios", "episodesxseason"]:
|
elif item.contentType == "tvshow" and item.action in ["episodios"]:
|
||||||
item.contentType == "tvshow"
|
item.contentType == "tvshow"
|
||||||
context_commands.append((config.get_localized_string(60355), "XBMC.RunPlugin(%s?%s)" %
|
context_commands.append((config.get_localized_string(60355), "XBMC.RunPlugin(%s?%s)" %
|
||||||
(sys.argv[0], item.clone(channel="downloads", action="save_download",
|
(sys.argv[0], item.clone(channel="downloads", action="save_download",
|
||||||
|
|||||||
+165
-94
@@ -21,7 +21,7 @@ list_servers = ['directo', 'akvideo', 'verystream', 'openload']
|
|||||||
list_quality = ['SD', '720', '1080', '4k']
|
list_quality = ['SD', '720', '1080', '4k']
|
||||||
|
|
||||||
def mainlist(item):
|
def mainlist(item):
|
||||||
logger.info()
|
support.log()
|
||||||
|
|
||||||
path = os.path.join(config.get_data_path(), 'community_channels.json')
|
path = os.path.join(config.get_data_path(), 'community_channels.json')
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
@@ -34,32 +34,40 @@ def mainlist(item):
|
|||||||
|
|
||||||
|
|
||||||
def show_channels(item):
|
def show_channels(item):
|
||||||
logger.info()
|
support.log()
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
|
||||||
context = [{"title": config.get_localized_string(50005),
|
context = [{"title": config.get_localized_string(50005),
|
||||||
"action": "remove_channel",
|
"action": "remove_channel",
|
||||||
"channel": "community"}]
|
"channel": "community"}]
|
||||||
|
|
||||||
path = os.path.join(config.get_data_path(), 'community_channels.json')
|
path = os.path.join(config.get_data_path(), 'community_channels.json')
|
||||||
file = open(path, "r")
|
file = open(path, "r")
|
||||||
json = jsontools.load(file.read())
|
json = jsontools.load(file.read())
|
||||||
|
|
||||||
itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(70676),'bold color kod'), action='add_channel', thumbnail=get_thumb('add.png')))
|
itemlist.append(Item(channel=item.channel,
|
||||||
|
title=typo(config.get_localized_string(70676),'bold color kod'),
|
||||||
|
action='add_channel',
|
||||||
|
thumbnail=get_thumb('add.png')
|
||||||
|
))
|
||||||
|
|
||||||
for key, channel in json['channels'].items():
|
for key, channel in json['channels'].items():
|
||||||
|
# Find File Path
|
||||||
if 'http' in channel['path']: file_path = requests.get(channel['path']).url
|
if 'http' in channel['path']: file_path = requests.get(channel['path']).url
|
||||||
else: file_path = channel['path']
|
else: file_path = channel['path']
|
||||||
|
|
||||||
|
# make relative path
|
||||||
path = os.path.dirname(os.path.abspath(file_path))
|
path = os.path.dirname(os.path.abspath(file_path))
|
||||||
if 'http' in path: path = path[path.find('http'):].replace('\\','/').replace(':/','://')
|
if 'http' in path: path = path[path.find('http'):].replace('\\','/').replace(':/','://')
|
||||||
if file_path.startswith('http'):
|
if file_path.startswith('http'): file_url = httptools.downloadpage(file_path, follow_redirects=True).data
|
||||||
file_url = httptools.downloadpage(file_path, follow_redirects=True).data
|
else: file_url = open(file_path, "r").read()
|
||||||
else:
|
|
||||||
file_url = open(file_path, "r").read()
|
# loa djson
|
||||||
json_url = jsontools.load(file_url)
|
json_url = jsontools.load(file_url)
|
||||||
thumbnail = json_url['thumbnail'] if 'thumbnail' in json_url and ':/' in json_url['thumbnail'] else path + json_url['thumbnail'] if 'thumbnail' in json_url and '/' in json_url['thumbnail'] else ''
|
|
||||||
fanart = json_url['fanart'] if 'fanart' in json_url and ':/' in json_url['fanart'] else path + json_url['fanart'] if 'fanart' in json_url and '/' in json_url['fanart'] else ''
|
thumbnail = relative('thumbnail', json_url, path)
|
||||||
plot = json_url['plot'] if 'plot' in json_url else ''
|
fanart = relative('fanart', json_url, path)
|
||||||
|
plot = json_url['plot'] if json_url.has_key('plot') else ''
|
||||||
|
|
||||||
itemlist.append(Item(channel=item.channel,
|
itemlist.append(Item(channel=item.channel,
|
||||||
title=typo(channel['channel_name'],'bold'),
|
title=typo(channel['channel_name'],'bold'),
|
||||||
@@ -73,94 +81,97 @@ def show_channels(item):
|
|||||||
path=path))
|
path=path))
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
def load_json(item):
|
|
||||||
support.log(item)
|
|
||||||
url= item if type(item) == str else item.url
|
|
||||||
|
|
||||||
if url:
|
|
||||||
if url.startswith('http'):
|
|
||||||
json_file = httptools.downloadpage(url).data
|
|
||||||
else:
|
|
||||||
json_file = open(url, "r").read()
|
|
||||||
|
|
||||||
json_data = jsontools.load(json_file)
|
|
||||||
else:
|
|
||||||
json_data = ''
|
|
||||||
|
|
||||||
return json_data
|
|
||||||
|
|
||||||
def show_menu(item):
|
def show_menu(item):
|
||||||
global list_data
|
global list_data
|
||||||
itemlist = []
|
itemlist = []
|
||||||
logger.info()
|
support.log()
|
||||||
|
|
||||||
json_data = load_json(item)
|
json_data = load_json(item)
|
||||||
|
|
||||||
if "menu" in json_data:
|
if "menu" in json_data:
|
||||||
for option in json_data['menu']:
|
for option in json_data['menu']:
|
||||||
if 'thumbnail' in json_data:
|
thumbnail = relative('thumbnail', option, item.path)
|
||||||
thumbnail = option['thumbnail'] if ':/' in option['thumbnail'] else item.path + option['thumbnail'] if '/' in option['thumbnail'] else get_thumb(option['thumbnail'])
|
fanart = relative('fanart', option, item.path)
|
||||||
else:
|
plot = option['plot'] if option.has_key('plot') else item.plot
|
||||||
thumbnail = ''
|
url = relative('link', option, item.path)
|
||||||
if 'fanart' in option and option['fanart']:
|
itemlist.append(Item(channel=item.channel,
|
||||||
fanart = option['fanart'] if ':/' in option['fanart'] else item.path + option['fanart']
|
title=format_title(option['title']),
|
||||||
else:
|
thumbnail=thumbnail,
|
||||||
fanart = item.fanart
|
fanart=fanart,
|
||||||
if 'plot' in option and option['plot']:
|
plot=plot,
|
||||||
plot = option['plot']
|
action='show_menu',
|
||||||
else:
|
url=url,
|
||||||
plot = item.plot
|
path=item.path))
|
||||||
url = '' if not option['link'] else option['link'] if ':/' in option['link'] else item.path + option['link']
|
# add Search
|
||||||
itemlist.append(Item(channel=item.channel, title=format_title(option['title']), thumbnail=thumbnail, fanart=fanart, plot=plot, action='show_menu', url=url, path=item.path))
|
itemlist.append(Item(channel=item.channel,
|
||||||
itemlist.append(Item(channel=item.channel, title=typo('Cerca...','color kod bold'), thumbnail=get_thumb('search.png'), action='search', url=item.url, path=item.path))
|
title=typo('Cerca...','color kod bold'),
|
||||||
if 'channel_name' in json_data: autoplay.show_option(item.channel, itemlist)
|
thumbnail=get_thumb('search.png'),
|
||||||
|
action='search',
|
||||||
|
url=item.url,
|
||||||
|
path=item.path))
|
||||||
|
# autoplay config only in main menu
|
||||||
|
if json_data.has_key('channel_name'): autoplay.show_option(item.channel, itemlist)
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
if "movies_list" in json_data:
|
# select type of list
|
||||||
item.media_type='movies_list'
|
if json_data.has_key("movies_list"): item.media_type= 'movies_list'
|
||||||
|
elif json_data.has_key("tvshows_list"): item.media_type = 'tvshows_list'
|
||||||
elif "tvshows_list" in json_data:
|
elif json_data.has_key("episodes_list"): item.media_type = 'episodes_list'
|
||||||
item.media_type = 'tvshows_list'
|
elif json_data.has_key("generic_list"): item.media_type= 'generic_list'
|
||||||
|
|
||||||
elif "episodes_list" in json_data:
|
|
||||||
item.media_type = 'episodes_list'
|
|
||||||
|
|
||||||
if "generic_list" in json_data:
|
|
||||||
item.media_type='generic_list'
|
|
||||||
|
|
||||||
return list_all(item)
|
return list_all(item)
|
||||||
|
|
||||||
def list_all(item):
|
def list_all(item):
|
||||||
logger.info()
|
support.log()
|
||||||
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
media_type = item.media_type
|
media_type = item.media_type
|
||||||
json_data = load_json(item)
|
json_data = load_json(item)
|
||||||
|
contentTitle = contentSerieName = ''
|
||||||
|
infoLabels = item.infoLabels if item.infoLabels else {}
|
||||||
|
|
||||||
if json_data:
|
if json_data:
|
||||||
for media in json_data[media_type]:
|
for media in json_data[media_type]:
|
||||||
|
|
||||||
quality, language, plot, poster = set_extra_values(media)
|
quality, language, plot, poster = set_extra_values(media)
|
||||||
|
|
||||||
title = media['title']
|
fulltitle = media['title']
|
||||||
title = set_title(title, language, quality)
|
title = set_title(fulltitle, language, quality)
|
||||||
|
|
||||||
new_item = Item(channel=item.channel, title=format_title(title), fulltitle=title, show=title, quality=quality,
|
infoLabels['year'] = media['year'] if media.has_key('year')else ''
|
||||||
language=language, plot=plot, personal_plot=plot, thumbnail=poster, path=item.path)
|
infoLabels['tmdb_id'] = media['tmdb_id'] if media.has_key('tmdb_id') else ''
|
||||||
|
|
||||||
new_item.infoLabels['year'] = media['year'] if 'year' in media else ''
|
|
||||||
new_item.infoLabels['tmdb_id'] = media['tmdb_id'] if 'tmdb_id' in media else ''
|
|
||||||
|
|
||||||
if 'movies_list' in json_data or 'generic_list' in json_data:
|
if 'movies_list' in json_data or 'generic_list' in json_data:
|
||||||
new_item.url = media
|
url= media
|
||||||
new_item.contentTitle = media['title']
|
contentTitle = fulltitle
|
||||||
new_item.action = 'findvideos'
|
contentType = 'movie'
|
||||||
if 'movies_list' in json_data: new_item.contentType = 'movie'
|
action='findvideos'
|
||||||
else:
|
|
||||||
new_item.url = media['seasons_list']
|
|
||||||
new_item.contentSerieName = media['title']
|
|
||||||
new_item.action = 'get_seasons'
|
|
||||||
|
|
||||||
itemlist.append(new_item)
|
else:
|
||||||
|
contentSerieName = fulltitle
|
||||||
|
contentType = 'tvshow'
|
||||||
|
if media.has_key('seasons_list'):
|
||||||
|
url = media['seasons_list']
|
||||||
|
action = 'get_seasons'
|
||||||
|
else:
|
||||||
|
url = relative('link', media, item.path)
|
||||||
|
action = 'episodios'
|
||||||
|
|
||||||
|
itemlist.append(Item(channel=item.channel,
|
||||||
|
contentType=contentType,
|
||||||
|
title=format_title(title),
|
||||||
|
fulltitle=fulltitle,
|
||||||
|
show=fulltitle,
|
||||||
|
quality=quality,
|
||||||
|
language=language,
|
||||||
|
plot=plot,
|
||||||
|
personal_plot=plot,
|
||||||
|
thumbnail=poster,
|
||||||
|
path=item.path,
|
||||||
|
url=url,
|
||||||
|
contentTitle=contentTitle,
|
||||||
|
contentSerieName=contentSerieName,
|
||||||
|
action=action))
|
||||||
|
|
||||||
if not 'generic_list' in json_data:
|
if not 'generic_list' in json_data:
|
||||||
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
||||||
@@ -170,24 +181,32 @@ def list_all(item):
|
|||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
def get_seasons(item):
|
def get_seasons(item):
|
||||||
|
support.log(item)
|
||||||
itemlist = []
|
itemlist = []
|
||||||
infoLabels = item.infoLabels if item.infolabels else {}
|
infoLabels = item.infoLabels if item.infolabels else {}
|
||||||
list_seasons = item.url
|
list_seasons = item.url
|
||||||
|
|
||||||
for season in list_seasons:
|
for season in list_seasons:
|
||||||
support.log()
|
|
||||||
infoLabels['season'] = season['season']
|
infoLabels['season'] = season['season']
|
||||||
title = config.get_localized_string(60027) % season['season']
|
title = config.get_localized_string(60027) % season['season']
|
||||||
url = '' if not season['link'] else season['link'] if ':/' in season['link'] else item.path + season['link']
|
url = relative('link', season, item.path)
|
||||||
itemlist.append(Item(channel=item.channel, title=format_title(title), fulltitle=item.fulltitle, show=item.show, url=url, action='episodesxseason',
|
|
||||||
contentSeason=season['season'], infoLabels=infoLabels ,contentType = 'tvshow'))
|
itemlist.append(Item(channel=item.channel,
|
||||||
|
title=format_title(title),
|
||||||
|
fulltitle=item.fulltitle,
|
||||||
|
show=item.show,
|
||||||
|
thumbnails=item.thumbnails,
|
||||||
|
url=url,
|
||||||
|
action='episodios',
|
||||||
|
contentSeason=season['season'],
|
||||||
|
infoLabels=infoLabels,
|
||||||
|
contentType='tvshow'))
|
||||||
|
|
||||||
|
|
||||||
logger.info('CANALE= '+ str(inspect.stack()[1][3]))
|
|
||||||
if inspect.stack()[1][3] in ['add_tvshow', "get_seasons"]:
|
if inspect.stack()[1][3] in ['add_tvshow', "get_seasons"]:
|
||||||
it = []
|
it = []
|
||||||
for item in itemlist:
|
for item in itemlist:
|
||||||
logger.info(str(item))
|
it += episodios(item)
|
||||||
it += episodesxseason(item)
|
|
||||||
|
|
||||||
itemlist = it
|
itemlist = it
|
||||||
else:
|
else:
|
||||||
@@ -198,30 +217,55 @@ def get_seasons(item):
|
|||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
def episodesxseason(item):
|
def episodios(item):
|
||||||
logger.info()
|
support.log(item)
|
||||||
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
json_data = load_json(item)
|
json_data = load_json(item)
|
||||||
infoLabels = item.infoLabels
|
infoLabels = item.infoLabels
|
||||||
|
ep = 1
|
||||||
season_number = infoLabels['season']
|
season_number = infoLabels['season'] if infoLabels.has_key('season') else item.contentSeason if item.contentSeason else 1
|
||||||
for episode in json_data['episodes_list']:
|
for episode in json_data['episodes_list']:
|
||||||
episode_number = episode['number']
|
match = support.match(episode['number'], r'(?P<season>\d+)x(?P<episode>\d+)')[0][0]
|
||||||
|
if not match: match = support.match(episode['title'], r'(?P<season>\d+)x(?P<episode>\d+)')[0][0]
|
||||||
|
if match:
|
||||||
|
episode_number = match[1]
|
||||||
|
season_number = match[0]
|
||||||
|
else:
|
||||||
|
season_number = episode['season'] if episode.has_key('season') else 1
|
||||||
|
episode_number = episode['number'] if episode.has_key('number') else ''
|
||||||
|
if not episode_number:
|
||||||
|
episode_number = str(ep)
|
||||||
|
ep +=1
|
||||||
|
|
||||||
infoLabels['season'] = season_number
|
infoLabels['season'] = season_number
|
||||||
infoLabels['episode'] = episode_number
|
infoLabels['episode'] = episode_number
|
||||||
|
|
||||||
title = '%sx%s - %s' % (item.contentSeason, episode_number, episode['title'])
|
plot = episode['plot'] if episode.has_key('plot') else item.plot
|
||||||
|
thumbnail = episode['poster'] if episode.has_key('poster') else episode['thumbnail'] if episode.has_key('thumbnail') else item.thumbnail
|
||||||
|
|
||||||
itemlist.append(Item(channel=item.channel, title=format_title(title), url=episode, action='findvideos',
|
title = ' - ' + episode['title'] if episode.has_key('title') else ''
|
||||||
contentSeason= item.contentSeason, contentEpisode=episode_number, infoLabels=infoLabels, contentType = 'episode'))
|
title = '%sx%s%s' % (season_number, episode_number, title)
|
||||||
|
|
||||||
|
itemlist.append(Item(channel= item.channel,
|
||||||
|
title= format_title(title),
|
||||||
|
fulltitle = item.fulltitle,
|
||||||
|
show = item.show,
|
||||||
|
url= episode,
|
||||||
|
action= 'findvideos',
|
||||||
|
plot= plot,
|
||||||
|
thumbnail= thumbnail,
|
||||||
|
contentSeason= season_number,
|
||||||
|
contentEpisode= episode_number,
|
||||||
|
infoLabels= infoLabels,
|
||||||
|
contentType= 'episode'))
|
||||||
|
|
||||||
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
def findvideos(item):
|
def findvideos(item):
|
||||||
logger.info()
|
support.log()
|
||||||
itemlist = []
|
itemlist = []
|
||||||
if 'links' in item.url:
|
if 'links' in item.url:
|
||||||
for url in item.url['links']:
|
for url in item.url['links']:
|
||||||
@@ -239,7 +283,7 @@ def findvideos(item):
|
|||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
def add_channel(item):
|
def add_channel(item):
|
||||||
logger.info()
|
support.log()
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
channel_to_add = {}
|
channel_to_add = {}
|
||||||
@@ -287,7 +331,7 @@ def add_channel(item):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def remove_channel(item):
|
def remove_channel(item):
|
||||||
logger.info()
|
support.log()
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
path = os.path.join(config.get_data_path(), 'community_channels.json')
|
path = os.path.join(config.get_data_path(), 'community_channels.json')
|
||||||
@@ -308,7 +352,7 @@ def remove_channel(item):
|
|||||||
|
|
||||||
|
|
||||||
def set_extra_values(dict):
|
def set_extra_values(dict):
|
||||||
logger.info()
|
support.log()
|
||||||
quality = ''
|
quality = ''
|
||||||
language = ''
|
language = ''
|
||||||
plot = ''
|
plot = ''
|
||||||
@@ -326,7 +370,7 @@ def set_extra_values(dict):
|
|||||||
return quality, language, plot, poster
|
return quality, language, plot, poster
|
||||||
|
|
||||||
def set_title(title, language, quality):
|
def set_title(title, language, quality):
|
||||||
logger.info()
|
support.log()
|
||||||
|
|
||||||
if not config.get_setting('unify'):
|
if not config.get_setting('unify'):
|
||||||
if quality != '':
|
if quality != '':
|
||||||
@@ -347,7 +391,7 @@ def format_title(title):
|
|||||||
return typo(title,t)
|
return typo(title,t)
|
||||||
|
|
||||||
def search(item, text):
|
def search(item, text):
|
||||||
logger.info('Search '+ text)
|
support.log('Search ', text)
|
||||||
itemlist = []
|
itemlist = []
|
||||||
json_data = load_json(item)
|
json_data = load_json(item)
|
||||||
|
|
||||||
@@ -395,3 +439,30 @@ def load_links(item, itemlist, json_data, text):
|
|||||||
else:
|
else:
|
||||||
load_links(item, itemlist, json_data, text)
|
load_links(item, itemlist, json_data, text)
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
def relative(key, json, path):
|
||||||
|
if json.has_key(key):
|
||||||
|
if key == 'thumbnail':
|
||||||
|
ret = json[key] if ':/' in json[key] else 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 path + json[key] if '/' in json[key] else ''
|
||||||
|
else:
|
||||||
|
ret = ''
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def load_json(item):
|
||||||
|
support.log(item)
|
||||||
|
url= item if type(item) == str else item.url
|
||||||
|
|
||||||
|
if url:
|
||||||
|
if url.startswith('http'):
|
||||||
|
json_file = httptools.downloadpage(url).data
|
||||||
|
else:
|
||||||
|
json_file = open(url, "r").read()
|
||||||
|
|
||||||
|
json_data = jsontools.load(json_file)
|
||||||
|
else:
|
||||||
|
json_data = ''
|
||||||
|
|
||||||
|
return json_data
|
||||||
@@ -731,11 +731,9 @@ def get_episodes(item):
|
|||||||
# importamos el canal
|
# importamos el canal
|
||||||
if item.contentChannel == 'community':
|
if item.contentChannel == 'community':
|
||||||
channel = __import__('specials.%s' % item.contentChannel, None, None, ["specials.%s" % item.contentChannel])
|
channel = __import__('specials.%s' % item.contentChannel, None, None, ["specials.%s" % item.contentChannel])
|
||||||
episodes = getattr(channel, 'episodesxseason')(item)
|
|
||||||
else:
|
else:
|
||||||
channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel])
|
channel = __import__('channels.%s' % item.contentChannel, None, None, ["channels.%s" % item.contentChannel])
|
||||||
episodes = getattr(channel, item.contentAction)(item)
|
episodes = getattr(channel, item.contentAction)(item)
|
||||||
|
|
||||||
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user