Filtri Personalizzati per Community Channels
This commit is contained in:
@@ -3,14 +3,13 @@
|
||||
# -*- Created for Alfa-addon -*-
|
||||
# -*- By the Alfa Develop Group -*-
|
||||
|
||||
import re, urllib, os, inspect
|
||||
import requests
|
||||
import re, os, inspect, requests
|
||||
|
||||
from core import httptools, scrapertoolsV2, servertools, jsontools, tmdb, support
|
||||
from core.item import Item
|
||||
from core.support import typo
|
||||
from channelselector import get_thumb
|
||||
from platformcode import logger, config, platformtools
|
||||
from platformcode import config, platformtools
|
||||
from specials import autoplay
|
||||
|
||||
|
||||
@@ -20,6 +19,7 @@ list_language = ['ITA', 'SUB-ITA']
|
||||
list_servers = ['directo', 'akvideo', 'verystream', 'openload']
|
||||
list_quality = ['SD', '720', '1080', '4k']
|
||||
|
||||
|
||||
def mainlist(item):
|
||||
support.log()
|
||||
|
||||
@@ -48,8 +48,7 @@ def show_channels(item):
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=typo(config.get_localized_string(70676),'bold color kod'),
|
||||
action='add_channel',
|
||||
thumbnail=get_thumb('add.png')
|
||||
))
|
||||
thumbnail=get_thumb('add.png')))
|
||||
|
||||
for key, channel in json['channels'].items():
|
||||
# Find File Path
|
||||
@@ -81,6 +80,7 @@ def show_channels(item):
|
||||
path=path))
|
||||
return itemlist
|
||||
|
||||
|
||||
def show_menu(item):
|
||||
global list_data
|
||||
itemlist = []
|
||||
@@ -94,6 +94,7 @@ def show_menu(item):
|
||||
fanart = relative('fanart', option, item.path)
|
||||
plot = option['plot'] if option.has_key('plot') else item.plot
|
||||
url = relative('link', option, item.path)
|
||||
submenu = option['submenu'] if option.has_key('submenu') else []
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=format_title(option['title']),
|
||||
thumbnail=thumbnail,
|
||||
@@ -102,9 +103,26 @@ def show_menu(item):
|
||||
action='show_menu',
|
||||
url=url,
|
||||
path=item.path))
|
||||
if submenu:
|
||||
for key in submenu:
|
||||
if key != 'search':
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=typo(submenu[key],'submenu'),
|
||||
url=url,
|
||||
path=item.path,
|
||||
thumbnail=item.thumbnail,
|
||||
action='submenu',
|
||||
filterkey=key))
|
||||
if submenu.has_key('search'):
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=typo('Cerca ' + option['title'] +'...','color kod bold'),
|
||||
thumbnail=get_thumb('search.png'),
|
||||
action='search',
|
||||
url=url,
|
||||
path=item.path))
|
||||
# add Search
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=typo('Cerca...','color kod bold'),
|
||||
title=typo('Cerca nel Canale...','color kod bold'),
|
||||
thumbnail=get_thumb('search.png'),
|
||||
action='search',
|
||||
url=item.url,
|
||||
@@ -121,6 +139,40 @@ def show_menu(item):
|
||||
|
||||
return list_all(item)
|
||||
|
||||
|
||||
def submenu(item):
|
||||
support.log()
|
||||
|
||||
itemlist = []
|
||||
filter_list = []
|
||||
|
||||
json_data = load_json(item)
|
||||
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 json_data.has_key("episodes_list"): item.media_type = 'episodes_list'
|
||||
elif json_data.has_key("generic_list"): item.media_type= 'generic_list'
|
||||
media_type = item.media_type
|
||||
|
||||
for media in json_data[media_type]:
|
||||
if media.has_key(item.filterkey):
|
||||
if type(media[item.filterkey]) == str and media[item.filterkey] not in filter_list:
|
||||
filter_list.append(media[item.filterkey].lower())
|
||||
elif type(media[item.filterkey]) == list:
|
||||
for f in media[item.filterkey]:
|
||||
if f not in filter_list:
|
||||
filter_list.append(f.lower())
|
||||
filter_list.sort()
|
||||
for filter in filter_list:
|
||||
itemlist.append(Item(channel=item.channel,
|
||||
title=typo(filter, 'bold'),
|
||||
url=item.url,
|
||||
media_type=item.media_type,
|
||||
action='list_filtered',
|
||||
filterkey=item.filterkey,
|
||||
filter=filter))
|
||||
return itemlist
|
||||
|
||||
|
||||
def list_all(item):
|
||||
support.log()
|
||||
|
||||
@@ -180,8 +232,70 @@ def list_all(item):
|
||||
item.plot = '\n\n' + typo('','submenu') + '\n' + item.personal_plot + '\n' + typo('','submenu') + '\n\n' + item.plot
|
||||
return itemlist
|
||||
|
||||
|
||||
def list_filtered(item):
|
||||
support.log()
|
||||
|
||||
itemlist = []
|
||||
media_type = item.media_type
|
||||
json_data = load_json(item)
|
||||
contentTitle = contentSerieName = ''
|
||||
infoLabels = item.infoLabels if item.infoLabels else {}
|
||||
|
||||
if json_data:
|
||||
for media in json_data[media_type]:
|
||||
if media.has_key(item.filterkey) and (item.filter.lower() in media[item.filterkey]):
|
||||
|
||||
quality, language, plot, poster = set_extra_values(media)
|
||||
|
||||
fulltitle = media['title']
|
||||
title = set_title(fulltitle, language, quality)
|
||||
|
||||
infoLabels['year'] = media['year'] if media.has_key('year')else ''
|
||||
infoLabels['tmdb_id'] = media['tmdb_id'] if media.has_key('tmdb_id') else ''
|
||||
|
||||
if 'movies_list' in json_data or 'generic_list' in json_data:
|
||||
url= media
|
||||
contentTitle = fulltitle
|
||||
contentType = 'movie'
|
||||
action='findvideos'
|
||||
|
||||
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:
|
||||
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
||||
for item in itemlist:
|
||||
if item.personal_plot != item.plot and item.personal_plot:
|
||||
item.plot = '\n\n' + typo('','submenu') + '\n' + item.personal_plot + '\n' + typo('','submenu') + '\n\n' + item.plot
|
||||
return itemlist
|
||||
|
||||
|
||||
def get_seasons(item):
|
||||
support.log(item)
|
||||
support.log()
|
||||
itemlist = []
|
||||
infoLabels = item.infoLabels if item.infolabels else {}
|
||||
list_seasons = item.url
|
||||
@@ -218,7 +332,7 @@ def get_seasons(item):
|
||||
|
||||
|
||||
def episodios(item):
|
||||
support.log(item)
|
||||
support.log()
|
||||
|
||||
itemlist = []
|
||||
json_data = load_json(item)
|
||||
@@ -285,6 +399,7 @@ def findvideos(item):
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def add_channel(item):
|
||||
support.log()
|
||||
import xbmc
|
||||
@@ -333,6 +448,7 @@ def add_channel(item):
|
||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70683) % json_file['channel_name'])
|
||||
return
|
||||
|
||||
|
||||
def remove_channel(item):
|
||||
support.log()
|
||||
import xbmc
|
||||
@@ -387,60 +503,71 @@ def set_title(title, language, quality):
|
||||
|
||||
return title
|
||||
|
||||
|
||||
def format_title(title):
|
||||
t = scrapertoolsV2.find_single_match(title, r'\{([^\}]+)\}')
|
||||
if 'bold' not in t: t += ' bold'
|
||||
title = re.sub(r'(\{[^\}]+\})','',title)
|
||||
return typo(title,t)
|
||||
|
||||
|
||||
def search(item, text):
|
||||
support.log('Search ', text)
|
||||
itemlist = []
|
||||
json_data = load_json(item)
|
||||
support.log('JSON= ', json_data)
|
||||
|
||||
return load_links(item, itemlist, json_data, text)
|
||||
|
||||
|
||||
def load_links(item, itemlist, json_data, text):
|
||||
for option in json_data['menu']:
|
||||
json_data = load_json(option['link'] if option['link'].startswith('http') else item.path+option['link'])
|
||||
if not 'menu' in json_data:
|
||||
if "movies_list" in json_data: media_type= 'movies_list'
|
||||
elif "tvshows_list" in json_data: media_type = 'tvshows_list'
|
||||
elif "episodes_list" in json_data: media_type = 'episodes_list'
|
||||
if "generic_list" in json_data: media_type= 'generic_list'
|
||||
support.log()
|
||||
|
||||
if json_data:
|
||||
for media in json_data[media_type]:
|
||||
if text.lower() in media['title'].lower():
|
||||
quality, language, plot, poster = set_extra_values(media)
|
||||
def links(item, itemlist, json_data, text):
|
||||
support.log()
|
||||
if "movies_list" in json_data: media_type= 'movies_list'
|
||||
elif "tvshows_list" in json_data: media_type = 'tvshows_list'
|
||||
elif "episodes_list" in json_data: media_type = 'episodes_list'
|
||||
if "generic_list" in json_data: media_type= 'generic_list'
|
||||
|
||||
title = media['title']
|
||||
title = set_title(title, language, quality)
|
||||
if json_data:
|
||||
for media in json_data[media_type]:
|
||||
if text.lower() in media['title'].lower():
|
||||
quality, language, plot, poster = set_extra_values(media)
|
||||
|
||||
new_item = Item(channel=item.channel, title=format_title(title), quality=quality,
|
||||
language=language, plot=plot, personal_plot=plot, thumbnail=poster, path=item.path)
|
||||
title = media['title']
|
||||
title = set_title(title, language, quality)
|
||||
|
||||
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 ''
|
||||
new_item = Item(channel=item.channel, title=format_title(title), quality=quality,
|
||||
language=language, plot=plot, personal_plot=plot, thumbnail=poster, path=item.path)
|
||||
|
||||
if 'movies_list' in json_data or 'generic_list' in json_data:
|
||||
new_item.url = media
|
||||
new_item.contentTitle = media['title']
|
||||
new_item.action = 'findvideos'
|
||||
else:
|
||||
new_item.url = media['seasons_list']
|
||||
new_item.contentSerieName = media['title']
|
||||
new_item.action = 'seasons'
|
||||
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 ''
|
||||
|
||||
itemlist.append(new_item)
|
||||
if 'movies_list' in json_data or 'generic_list' in json_data:
|
||||
new_item.url = media
|
||||
new_item.contentTitle = media['title']
|
||||
new_item.action = 'findvideos'
|
||||
else:
|
||||
new_item.url = media['seasons_list']
|
||||
new_item.contentSerieName = media['title']
|
||||
new_item.action = 'seasons'
|
||||
|
||||
if not 'generic_list' in json_data:
|
||||
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
||||
for item in itemlist:
|
||||
if item.personal_plot != item.plot and item.personal_plot:
|
||||
item.plot = '\n\n' + typo('','submenu') + '\n' + item.personal_plot + '\n' + typo('','submenu') + '\n\n' + item.plot
|
||||
else:
|
||||
itemlist.append(new_item)
|
||||
|
||||
if not 'generic_list' in json_data:
|
||||
tmdb.set_infoLabels(itemlist, seekTmdb=True)
|
||||
for item in itemlist:
|
||||
if item.personal_plot != item.plot and item.personal_plot:
|
||||
item.plot = '\n\n' + typo('','submenu') + '\n' + item.personal_plot + '\n' + typo('','submenu') + '\n\n' + item.plot
|
||||
|
||||
if json_data.has_key('menu'):
|
||||
for option in json_data['menu']:
|
||||
json_data = load_json(option['link'] if option['link'].startswith('http') else item.path+option['link'])
|
||||
load_links(item, itemlist, json_data, text)
|
||||
else:
|
||||
links(item, itemlist, json_data, text)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
@@ -454,18 +581,19 @@ def relative(key, json, path):
|
||||
ret = ''
|
||||
return ret
|
||||
|
||||
def load_json(item):
|
||||
support.log(item)
|
||||
url= item if type(item) == str else item.url
|
||||
|
||||
if url:
|
||||
def load_json(item):
|
||||
support.log()
|
||||
url= item if type(item) == str else item.url
|
||||
try:
|
||||
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 = ''
|
||||
|
||||
except:
|
||||
json_data = {}
|
||||
|
||||
return json_data
|
||||
Reference in New Issue
Block a user