Fix e Migliorie a:

- Ricerca Globale
 - InfoPlus
This commit is contained in:
Alhaziel01
2021-09-16 20:03:51 +02:00
parent 938b8e6355
commit b80e6295ff
10 changed files with 498 additions and 607 deletions

View File

@@ -77,8 +77,8 @@ def peliculas(item):
item.title += support.typo(item.lang2, '_ [] color kod')
if item.args == 'update':
item.title = item.title.replace('-', ' ')
# if item.args == 'search':
# item.contentType = 'tvshow' if 'serie-' in item.url else 'movie'
if item.args == 'search':
item.contentType = 'undefined'
return item
@@ -123,6 +123,7 @@ def genres(item):
def search(item, texto):
logger.debug(item.url,texto)
item.contentType = 'undefined'
texto = texto.replace(' ', '+')
item.url = host + "/?s=" + texto
# item.contentType = 'tv'

View File

@@ -155,14 +155,16 @@ class scrape:
return self.itemlist
def _scrape(self, item):
if item.itemlist:
scrapingTime = time()
self.itemlist = itemlistdb()
self.seasons = item.allSeasons
else:
for n in range(2):
logger.debug('PATRON= ', self.patron)
if self.data and item.data:
item.data = ''
if not self.data:
page = httptools.downloadpage(item.url, headers=self.headers, ignore_response_code=True)
item.url = page.url # might be a redirect
@@ -230,7 +232,7 @@ class scrape:
if self.numerationEnabled and inspect.stack()[1][3] not in ['find_episodes']:
from platformcode import autorenumber
if self.function == 'episodios':
autorenumber.start(self.itemlist, self.item)
autorenumber.start(self.itemlist, item)
for i in self.itemlist:
if i.contentSeason and i.contentSeason not in self.seasons:
@@ -336,7 +338,7 @@ class scrape:
if self.function == 'episodios':
infolabels = item.infoLabels
else:
infolabels = {}
infolabels = {'mediatype':item.contentType}
if self.itemParams.year:
infolabels['year'] = self.itemParams.year
if self.itemParams.plot:
@@ -447,17 +449,17 @@ class scrape:
if (not self.itemParams.title or self.itemParams.title not in self.blacklist) and (self.search.lower() in self.itemParams.title.lower()):
it = item.clone(title=self.itemParams.title,
fulltitle=self.itemParams.title,
show=self.itemParams.title,
infoLabels=self.itemParams.infoLabels,
contentSeason= self.itemParams.infoLabels.get('season', ''),
contentEpisodeNumber= self.itemParams.infoLabels.get('episode', ''),
grouped = self.group,
episode2 = self.itemParams.second_episode,
extraInfo = self.itemParams.extraInfo,
disable_videolibrary = not self.args.get('addVideolibrary', True),
size = self.itemParams.size,
seed = self.itemParams.seed)
fulltitle=self.itemParams.title,
show=self.itemParams.title,
infoLabels=self.itemParams.infoLabels,
contentSeason= self.itemParams.infoLabels.get('season', ''),
contentEpisodeNumber= self.itemParams.infoLabels.get('episode', ''),
grouped = self.group,
episode2 = self.itemParams.second_episode,
extraInfo = self.itemParams.extraInfo,
disable_videolibrary = not self.args.get('addVideolibrary', True),
size = self.itemParams.size,
seed = self.itemParams.seed)
if self.itemParams.url: it.url = self.itemParams.url
if self.function == 'episodios': it.fulltitle = it.show = self.itemParams.title
@@ -899,22 +901,24 @@ def nextPage(itemlist, item, function_or_level=1, **kwargs):
def pagination(itemlist, item, function_level=1):
if 'channel_search' in [s[3] for s in inspect.stack()]:
return itemlist
itemlistdb(itemlist)
page = item.page if item.page else 1
if not item.page:
item.page = 1
perpage = config.get_setting('pagination', default=20)
action = function_level if type(function_level) == str else inspect.stack()[function_level][3]
itlist = []
for i, it in enumerate(itemlist):
if perpage and (page - 1) * perpage > i: continue # pagination
if perpage and i >= page * perpage: break # pagination
if perpage and (item.page - 1) * perpage > i: continue # pagination
if perpage and i >= item.page * perpage: break # pagination
itlist.append(it)
if len(itemlist) >= page * perpage:
if len(itemlist) >= item.page * perpage:
itemlistdb(itemlist)
itlist.append(
item.clone(channel=item.channel,
action=action,
contentType=item.contentType,
title=typo(config.get_localized_string(30992), 'color kod bold'),
page=page + 1,
page=item.page + 1,
total_pages=round(len(itemlist)/perpage),
nextPage = True,
itemlist = True,
@@ -926,7 +930,7 @@ def pagination(itemlist, item, function_level=1):
def season_pagination(itemlist, item, seasons, function_level=1):
if 'channel_search' in [s[3] for s in inspect.stack()]:
return itemlist
itemlistdb(itemlist)
action = function_level if type(function_level) == str else inspect.stack()[function_level][3]
itlist = []
if itemlist and not seasons:
@@ -936,8 +940,10 @@ def season_pagination(itemlist, item, seasons, function_level=1):
seasons.append(it.contentSeason)
if seasons:
itemlistdb(itemlist)
seasons.sort()
if not item.nextSeason: item.nextSeason = 0
if not item.nextSeason:
item.nextSeason = 0
try:
current = seasons[item.nextSeason]
@@ -949,22 +955,24 @@ def season_pagination(itemlist, item, seasons, function_level=1):
if item.nextSeason + 1 < len(seasons):
itlist.append(
item.clone(action=action,
title=typo('Stagione Successiva [{}]'.format(seasons[item.nextSeason + 1]), 'bold'),
allSeasons = seasons,
nextSeason = item.nextSeason + 1,
itemlist = True,
prevthumb = item.thumbnail,
thumbnail=thumb()))
Item(channel=item.channel,
action=action,
title=typo('Stagione Successiva [{}]'.format(seasons[item.nextSeason + 1]), 'bold'),
allSeasons = seasons,
nextSeason = item.nextSeason + 1,
itemlist = True,
prevthumb = item.thumbnail,
thumbnail=thumb()))
itlist.append(
item.clone(action='gotoseason',
real_action=action,
title=typo('Vai alla stagione…', 'bold'),
allSeasons = seasons,
nextSeason = item.nextSeason + 1,
itemlist = True,
prevthumb = item.thumbnail,
thumbnail=thumb()))
Item(channel=item.channel,
action='gotoseason',
real_action=action,
title=typo('Vai alla stagione…', 'bold'),
allSeasons = seasons,
nextSeason = item.nextSeason + 1,
itemlist = True,
prevthumb = item.thumbnail,
thumbnail=thumb()))
return itlist
except:
return itemlist
@@ -1015,6 +1023,7 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
videoitem.channel = item.channel
videoitem.fulltitle = item.fulltitle
videoitem.show = item.show
videoitem.ch_name = channeltools.get_channel_parameters(item.channel)['title']
if not videoitem.video_urls: videoitem.thumbnail = item.thumbnail
videoitem.contentType = item.contentType
videoitem.infoLabels = item.infoLabels

View File

@@ -214,7 +214,7 @@ def set_infoLabels_itemlist(itemlist, seekTmdb=False, search_language=def_lang,
logger.error(traceback.format_exc(1))
return (_i, _item, ret)
# from core.support import dbg;dbg()
# for i, item in enumerate(itemlist):
# r_list.append(sub_thread(item, i, seekTmdb))
with futures.ThreadPoolExecutor() as executor:
@@ -248,11 +248,11 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang):
def read_data(otmdb_aux):
# item.infoLabels = otmdb_aux.get_infoLabels(item.infoLabels)
infoLabels = otmdb_aux.get_infoLabels(item.infoLabels)
if not infoLabels['plot']: infoLabels['plot'] = otmdb_aux.get_plot('en')
if not infoLabels.get('plot'): infoLabels['plot'] = otmdb_aux.get_plot('en')
item.infoLabels = infoLabels
if item.infoLabels.get('thumbnail'):
item.thumbnail = item.infoLabels['thumbnail']
if item.infoLabels['fanart']:
if item.infoLabels.get('fanart'):
item.fanart = item.infoLabels['fanart']
if seekTmdb:
@@ -290,6 +290,7 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang):
if episode:
# Update data
read_data(otmdb_global)
item.infoLabels['mediatype'] = 'episode'
if episode.get('episode_title'):
item.infoLabels['title'] = episode['episode_title']
if episode.get('episode_plot'):
@@ -409,11 +410,11 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang):
# If the search has been successful and you are not looking for a list of items,
# carry out another search to expand the information
if search_type == 'multi':
search_type = 'movie' if otmdb.result.get('media_type') else 'tv'
search_type = otmdb.result.get('media_type')
otmdb = Tmdb(id_Tmdb=otmdb.result.get("id"), search_type=search_type,
search_language=search_language)
if otmdb is not None and otmdb.get_id():
# The search has found a valid result
read_data(otmdb)
@@ -427,6 +428,7 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang):
item.fulltitle = new_title
return True
# We check what type of content it is...
# from core.support import dbg;dbg()
if item.contentType == 'movie':
search_type = 'movie'
elif item.contentType == 'undefined': # don't know
@@ -977,6 +979,7 @@ class Tmdb(object):
self.total_results = 1
self.total_pages = 1
self.result = ResultDictDefault(result)
self.result['media_type'] = self.search_type.replace('tv', 'tvshow')
else:
# No search results
@@ -984,7 +987,6 @@ class Tmdb(object):
logger.debug(msg)
def __search(self, index_results=0, page=1):
# from core.support import dbg;dbg()
self.result = ResultDictDefault()
results = []
text_simple = self.search_text.lower()
@@ -1044,6 +1046,8 @@ class Tmdb(object):
self.total_results = total_results
self.total_pages = total_pages
self.result = ResultDictDefault(self.results[index_results])
# self.result['mediatype'] = self.result['media_type']
if not config.get_setting('tmdb_plus_info'):
self.result = self.get_mpaa(self.result)
return len(self.results)
@@ -1649,7 +1653,8 @@ class Tmdb(object):
continue
if k == 'media_type':
ret_infoLabels['mediatype'] = 'tvshow' if v == 'tv' else 'movie'
# from core.support import dbg;dbg()
ret_infoLabels['mediatype'] = v if v in ['tv', 'tvshow'] else 'movie'
elif k == 'overview':
if origen:

View File

@@ -65,6 +65,7 @@ class InfoPlus(xbmcgui.WindowXML):
platformtools.dialog_busy(True)
if self.item:
# Find Video Info
tmdb.set_infoLabels_item(self.item)
self.info = self.item.infoLabels
title = typo(self.info.get('title'), 'bold')
@@ -83,9 +84,17 @@ class InfoPlus(xbmcgui.WindowXML):
rating = self.info.get('rating', 'N/A')
color = 'FFFFFFFF' if rating == 'N/A' else 'FFDB2360' if rating < 4 else 'FFD2D531' if rating < 7 else 'FF21D07A'
self.listitem.setProperty('color',color)
info = ''
if self.info.get('year'): info = str(self.info.get('year'))
if self.info.get('duration'): info = '{}[B]•[/B]{}'.format(info, self.info.get('duration'))
if self.info.get('Mpaa'): info = '{}[B]•[/B]{}'.format(info, self.info.get('Mpaa'))
self.listitem.setProperty('info',info)
# Set infoLabels
platformtools.set_infolabels(self.listitem, self.item)
# Add Cast Info
for cast in self.info.get('castandrole',[]):
@@ -365,9 +374,9 @@ class CastWindow(xbmcgui.WindowXML):
def showImages(images, position):
xbmc.executebuiltin('Dialog.Close(all)')
ImagesWindow('imageWindow.xml', config.get_runtime_path(), images=images, position=position)
return ImagesWindow('imageWindow.xml', config.get_runtime_path()).start(images=images, position=position)
class ImagesWindow(xbmcgui.WindowXMLDialog):
def __init__(self, *args, **kwargs):
def start(self, *args, **kwargs):
self.images = []
self.position = kwargs.get('position')
for i, image in enumerate(kwargs.get('images', [])):

View File

@@ -11,7 +11,6 @@
<control type='group' id="1"/>
<control type='group' id="2"/>
<control type='group' id="3"/>
<control type='group' id="4"/>
<control type="image"> <!-- BACKGROUND -->
<description>Window Background</description>
@@ -37,32 +36,39 @@
<height>100%</height>
<aspectratio>scale</aspectratio>
<texture colordiffuse="FF555555">$INFO[Container(102).ListItem.Art(fanart)]</texture>
<visible>!String.IsEmpty(Container(102).ListItem.Art(fanart))</visible>
<visible>!Control.IsVisible(2) + !String.IsEmpty(Container(102).ListItem.Art(fanart))</visible>
</control>
<control type="image">
<description>Episode Fanart</description>
<width>100%</width>
<height>100%</height>
<aspectratio>scale</aspectratio>
<texture colordiffuse="FF555555">$INFO[Container(103).ListItem.Art(thumb)]</texture>
<visible>Control.IsVisible(2) + !String.IsEmpty(Container(103).ListItem.Art(thumb))</visible>
</control>
<control type="textbox" id='100'>
<description>Title</description>
<left>480</left>
<top>270</top>
<width>1000</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<!-- <visible>Integer.IsGreater(Container(101).NumItems, 0)</visible> -->
<align>left</align>
<aligny>center</aligny>
<animation effect="slide" tween="linear" center="0" end="-450,-240" time="600" condition="Integer.IsGreater(Container(101).NumItems, 0)">Conditional</animation>
</control>
<control type="group"> <!-- SEARCH GROUP-->
<description>Search Group</description>
<visible>Control.IsVisible(1)</visible>
<control type="textbox" id='100'>
<description>Title</description>
<left>30</left>
<top>30</top>
<width>1000</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<visible>Integer.IsGreater(Container(101).NumItems, 0)</visible>
<align>left</align>
<aligny>center</aligny>
</control>
<control type="group"> <!-- Search Result Group -->
<control type="group">
<description>Search Result Group</description>
<visible>Integer.IsGreater(Container(102).NumItems, 0)</visible>
<animation effect="fade" time="200">Visible</animation>
<control type='group'>
<left>400</left>
<top>90</top>
@@ -120,21 +126,6 @@
</control>
</control>
<control type="textbox">
<visible>String.IsEmpty(Container(102).ListItem.Property(rating))</visible>
<description>Item Title</description>
<left>0</left>
<top>0</top>
<width>840</width>
<height>60</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$INFO[Container(102).ListItem.Label]</label>
<align>left</align>
<aligny>center</aligny>
</control>
<control type="textbox">
<description>Item Count</description>
<left>640</left>
@@ -176,10 +167,10 @@
<itemgap>10</itemgap>
<orientation>horizontal</orientation>
<align>left</align>
<control type='textbox'>
<control type='label'>
<description>Year</description>
<height>30</height>
<width>45</width>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
@@ -187,7 +178,7 @@
<align>left</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Separator</description>
<height>30</height>
<width>10</width>
@@ -199,10 +190,10 @@
<align>center</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Duration</description>
<height>30</height>
<width>50</width>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
@@ -210,7 +201,7 @@
<align>left</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Separator</description>
<height>30</height>
<width>10</width>
@@ -222,10 +213,10 @@
<align>center</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Mpaa</description>
<height>30</height>
<width>60</width>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
@@ -237,14 +228,14 @@
<control type='textbox'>
<description>Genre</description>
<visible>!String.isEmpty(Container(102).ListItem.Genre</visible>
<visible>!String.isEmpty(Container(102).ListItem.Genre)</visible>
<right>0</right>
<height>30</height>
<width>600</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>[B]$ADDON[plugin.video.kod 70499][/B] $INFO[Container(102).ListItem.Genre]</label>
<label>$INFO[Container(102).ListItem.Genre]</label>
<align>right</align>
<aligny>center</aligny>
</control>
@@ -266,11 +257,14 @@
</control>
<control type="fixedlist" id="102">
<animation effect="slide" start="0,100" time="200" condition="Integer.IsGreater(Container(102).NumItems, 0)">Conditional</animation>
<animation effect="fade" start="0" time="200" condition="Integer.IsGreater(Container(102).NumItems, 0)">Conditional</animation>
<animation effect="slide" end="0,100" time="200">WindowClose</animation>
<animation effect="fade" time="100">WindowClose</animation>
<animation type="Conditional" condition="Integer.IsGreater(Container(102).NumItems, 0)" reversible="false">
<effect type="slide" delay="160" start="0,100" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="WindowClose" reversible="false">
<effect type="slide" start="0,0" end="0,100" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<description>Search Results list</description>
<bottom>70</bottom>
<left>0</left>
@@ -318,41 +312,59 @@
</control>
</itemlayout>
<focusedlayout height="570" width="380">
<control type="group">
<control type="image">
<description>Item Poster</description>
<top>0</top>
<left>0</left>
<width>380</width>
<height>570</height>
<texture>$INFO[ListItem.Art(poster)]</texture>
<bordersize>10</bordersize>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Item Poster</description>
<bottom>0</bottom>
<left>0</left>
<width>150</width>
<height>150</height>
<texture>$INFO[ListItem.Property(channelthumb)]</texture>
<bordersize>10</bordersize>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Item Poster</description>
<top>0</top>
<right>0</right>
<width>150</width>
<height>150</height>
<texture>sub.png</texture>
<visible>!String.IsEmpty(ListItem.Property(sub))</visible>
<bordersize>10</bordersize>
<aspectratio>scale</aspectratio>
</control>
</control>
</focusedlayout>
</control>
<control type="group">
<description>Poster</description>
<bottom>70</bottom>
<height>570</height>
<width>380</width>
<visible>Integer.IsGreater(Container(102).NumItems, 0)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="-100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="-100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<animation type="WindowClose" reversible="false">
<effect type="slide" start="0,0" end="-100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<control type="image">
<description>Item Poster</description>
<top>0</top>
<left>0</left>
<width>380</width>
<height>570</height>
<texture>$INFO[Container(102).ListItem.Art(poster)]</texture>
<bordersize>10</bordersize>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Item Poster</description>
<bottom>0</bottom>
<left>0</left>
<width>150</width>
<height>150</height>
<texture>$INFO[Container(102).ListItem.Property(channelthumb)]</texture>
<bordersize>10</bordersize>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Item Poster</description>
<top>0</top>
<right>0</right>
<width>150</width>
<height>150</height>
<texture>sub.png</texture>
<visible>!String.IsEmpty(Container(102).ListItem.Property(sub))</visible>
<bordersize>10</bordersize>
<aspectratio>scale</aspectratio>
</control>
</control>
</control> <!-- END Search Result Group -->
<control type='image'>
<width>100%</width>
@@ -379,7 +391,7 @@
<animation effect="slide" start="0,-160" time="200" condition="!Control.HasFocus(101)">Conditional</animation>
<visible>Integer.IsGreater(Container(101).NumItems, 0)</visible>
<control type="button" id='506'>
<control type="button" id='505'>
<description>Chennels Bar Tab</description>
<top>0</top>
<left>575</left>
@@ -493,37 +505,19 @@
<control type="group"> <!-- EPISODES GROUP-->
<description>Episodes Group</description>
<visible>Control.IsVisible(2)</visible>
<control type="image">
<description>Poster</description>
<visible>Control.IsVisible(2)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="-100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="-100,0" time="200" />
<effect type="fade" start="100" end="" time="200" />
</animation>
<top>0</top>
<left>0</left>
<width>480</width>
<height>720</height>
<texture>$INFO[Container(102).ListItem.Art(poster)]</texture>
</control>
<left>520</left>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<control type="textbox">
<description>Main Title</description>
<visible>Control.IsVisible(2)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<left>520</left>
<left>0</left>
<top>40</top>
<width>1150</width>
<height>30</height>
@@ -535,30 +529,20 @@
<label>$INFO[Container(102).ListItem.Label()]</label>
</control>
<control type="list" id="200"> <!-- Episodes List -->
<control type="list" id="103"> <!-- Episodes List -->
<description>Episodes List</description>
<visible>Control.IsVisible(2)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<top>110</top>
<left>520</left>
<width>700</width>
<left>50</left>
<width>640</width>
<height>570</height>
<onleft>503</onleft>
<onright>503</onright>
<onup>503</onup>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="60" width="700">
<control type="textbox">
<description>Episode Title</description>
<top>0</top>
<left>20</left>
<width>660</width>
<width>600</width>
<height>60</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
@@ -568,189 +552,111 @@
<label>$INFO[ListItem.Label()]</label>
</control>
</itemlayout>
<focusedlayout height="60" width="700">
<control type="image">
<description>Selected Background</description>
<top>0</top>
<left>0</left>
<width>700</width>
<height>60</height>
<texture colordiffuse="CC000000">white.png</texture>
<aspectratio>scale</aspectratio>
<focusedlayout height="90" width="700">
<control type="group">
<visible>String.IsEmpty(ListItem.Art(thumb))</visible>
<width>100%</width>
<height>90</height>
<control type="image">
<description>Selected Background</description>
<top>0</top>
<left>0</left>
<width>100%</width>
<height>100%</height>
<texture colordiffuse="CCFFFFFF">white.png</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="textbox">
<description>Episode Title</description>
<top>0</top>
<left>20</left>
<width>600</width>
<height>100%</height>
<font>font13</font>
<textcolor>FF232323</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>$INFO[ListItem.Label]</label>
</control>
</control>
<control type="textbox">
<description>Episode Title</description>
<top>0</top>
<left>20</left>
<width>660</width>
<height>60</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B]$INFO[ListItem.Label][/B]</label>
<control type="group">
<visible>!String.IsEmpty(ListItem.Art(thumb))</visible>
<width>100%</width>
<height>90</height>
<control type="image">
<description>Selected Background</description>
<top>0</top>
<left>0</left>
<width>100%</width>
<height>100%</height>
<texture colordiffuse="CCFFFFFF">white.png</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Selected Background</description>
<top>0</top>
<left>0</left>
<width>160</width>
<height>90</height>
<texture>$INFO[ListItem.Art(thumb)]</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="textbox">
<description>Episode Title</description>
<top>0</top>
<left>180</left>
<width>480</width>
<height>100%</height>
<font>font13</font>
<textcolor>FF232323</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>$INFO[ListItem.Label]</label>
</control>
</control>
</focusedlayout>
</control> <!-- END Episodes List -->
<control type='button' id='506'>
<description>Next Season/Page</description>
<top>380</top>
<right>20</right>
<height>30</height>
<width>30</width>
<texturefocus colordiffuse="FFFFFFFF">next.png</texturefocus>
<texturenofocus colordiffuse="80FFFFFF">next.png</texturenofocus>
</control>
<control type='button' id='507'>
<description>Previous Season/Page</description>
<top>380</top>
<left>0</left>
<height>30</height>
<width>30</width>
<texturefocus colordiffuse="FFFFFFFF">previous.png</texturefocus>
<texturenofocus colordiffuse="80FFFFFF">previous.png</texturenofocus>
</control>
</control> <!-- END EPISODES GROUP -->
<control type="group"> <!-- SERVERS GROUP-->
<description>Servers Group</description>
<visible>Control.IsVisible(3)</visible>
<control type="image">
<visible>Control.IsVisible(3)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="-100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="-100,0" time="200" />
<effect type="fade" start="100" end="" time="200" />
</animation>
<description>Poster</description>
<top>0</top>
<left>0</left>
<width>480</width>
<height>720</height>
<texture>$INFO[Container(102).ListItem.Art(poster)]</texture>
</control>
<control type="textbox">
<visible>Control.IsVisible(3)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<visible>Control.IsVisible(3)</visible>
<description>Main Title</description>
<left>520</left>
<top>40</top>
<width>1150</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>$INFO[Container(102).ListItem.Label]</label>
</control>
<control type="list" id="300"> <!-- Servers List -->
<visible>Control.IsVisible(3)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="100,0" time="200" />
<effect type="fade" start="100" end="0" time="200" />
</animation>
<description>Servers List</description>
<bottom>40</bottom>
<left>520</left>
<width>700</width>
<height>570</height>
<onleft>503</onleft>
<onright>503</onright>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="140" width="700">
<control type="image">
<description>Servers Icon</description>
<top>5</top>
<left>5</left>
<width>120</width>
<height>120</height>
<texture>$INFO[ListItem.Art(poster)]</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="textbox">
<description>Server Title</description>
<left>150</left>
<top>30</top>
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B]$INFO[ListItem.Label][/B]</label>
</control>
<control type="textbox">
<description>Channel</description>
<left>150</left>
<top>60</top>
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B][COLOR FFAAAAAA]$INFO[ListItem.Property(channel)][/COLOR][/B]</label>
</control>
</itemlayout>
<focusedlayout height="140" width="700">
<control type="image">
<description>Selection Background</description>
<width>700</width>
<height>130</height>
<texture colordiffuse="88000000">white.png</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Servers Color</description>
<top>0</top>
<left>0</left>
<width>130</width>
<height>130</height>
<texture colordiffuse="$INFO[ListItem.Property(color)]">white.png</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
<description>Servers Icon</description>
<top>5</top>
<left>5</left>
<width>120</width>
<height>120</height>
<texture>$INFO[ListItem.Art(poster)]</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="textbox">
<description>Server Title</description>
<left>150</left>
<top>30</top>
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B]$INFO[ListItem.Label][/B]</label>
</control>
<control type="textbox">
<description>Channel</description>
<left>150</left>
<top>60</top>
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B][COLOR FFAAAAAA]$INFO[ListItem.Property(channel)][/COLOR][/B]</label>
</control>
</focusedlayout>
</control> <!-- END Servers List -->
</control> <!-- END SERVERS GROUP -->
<control type="image">
<description>Poster</description>
<visible>Control.IsVisible(2)</visible>
<animation type="Visible" reversible="false">
<effect type="slide" delay="160" start="-100,0" end="0,0" time="200" />
<effect type="fade" delay="160" start="0" end="100" time="200" />
</animation>
<animation type="Hidden" reversible="false">
<effect type="slide" start="0,0" end="-100,0" time="200" />
<effect type="fade" start="100" end="" time="200" />
</animation>
<top>0</top>
<left>0</left>
<width>480</width>
<height>720</height>
<texture>$INFO[Container(102).ListItem.Art(poster)]</texture>
</control>
</control> <!-- CONTROLS GROUP -->
<control type="progress" id="500">
@@ -780,7 +686,7 @@
<align>right</align>
<aligny>center</aligny>
<animation effect="slide" tween="linear" center="0" end="-450,-240" time="600" condition="Integer.IsGreater(Container(102).NumItems, 0)">Conditional</animation>
<visible>Control.IsVisible(500)</visible>
<!-- <visible>Control.IsVisible(500)</visible> -->
</control>
<control type="textbox">
@@ -795,7 +701,7 @@
<align>center</align>
<aligny>center</aligny>
<label>[UPPERCASE]$ADDON[plugin.video.kod 60473][/UPPERCASE]</label>
<visible>Control.IsVisible(4)</visible>
<visible>Control.IsVisible(3)</visible>
</control>
<control type="group">
@@ -841,20 +747,5 @@
<texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus>
</control>
</control>
<control type="textbox" id="505">
<description>Quality Tag</description>
<top>670</top>
<right>20</right>
<width>200</width>
<height>40</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>right</align>
<aligny>center</aligny>
<visible>Control.IsVisible(3)</visible>
</control>
</controls>
</window>

View File

@@ -113,18 +113,18 @@
<description>Video Info</description>
<visible>Integer.IsGreater(Container(100).NumItems, 0)</visible>
<top>0</top>
<height>261</height>
<height>311</height>
<control type='grouplist'>
<top>0</top>
<height>30</height>
<width>300</width>
<width>100%</width>
<itemgap>10</itemgap>
<orientation>horizontal</orientation>
<align>left</align>
<control type='textbox'>
<control type='label'>
<description>Year</description>
<height>30</height>
<width>45</width>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
@@ -132,7 +132,7 @@
<align>left</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Separator</description>
<height>30</height>
<width>10</width>
@@ -144,10 +144,10 @@
<align>center</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Duration</description>
<height>30</height>
<width>50</width>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
@@ -155,7 +155,7 @@
<align>left</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Separator</description>
<height>30</height>
<width>10</width>
@@ -167,10 +167,10 @@
<align>center</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<control type='label'>
<description>Mpaa</description>
<height>30</height>
<width>60</width>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
@@ -178,22 +178,46 @@
<align>left</align>
<aligny>center</aligny>
</control>
<control type='label'>
<description>Separator</description>
<height>30</height>
<width>10</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<visible>!String.IsEmpty(Container(100).ListItem.Status)</visible>
<label>[B]•[/B]</label>
<align>center</align>
<aligny>center</aligny>
</control>
<control type='label'>
<description>Status</description>
<height>30</height>
<width>auto</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$INFO[Container(100).ListItem.Status]</label>
<align>left</align>
<aligny>center</aligny>
</control>
</control>
<control type='textbox'>
<control type='label'>
<description>Genre</description>
<right>0</right>
<top>40</top>
<left>0</left>
<height>30</height>
<width>400</width>
<width>100%</width>
<font>font13</font>
<textcolor>ffFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$INFO[Container(100).ListItem.Genre]</label>
<align>right</align>
<align>left</align>
<aligny>center</aligny>
</control>
<control type='textbox'>
<description>Plot</description>
<top>50</top>
<top>90</top>
<left>0</left>
<height>200</height>
<font>font13</font>
@@ -206,7 +230,7 @@
</control>
<control type='image'>
<description>Separator</description>
<top>260</top>
<top>310</top>
<left>0</left>
<height>0.5</height>
<texture>white.png</texture>
@@ -439,7 +463,7 @@
<top>240</top>
<left>0</left>
<height>0.5</height>
<texture>white.png</texture>ù
<texture>white.png</texture>
</control>
</control>
<!-- Trailers -->

View File

@@ -99,15 +99,15 @@
<control type="textbox">
<description>Channel</description>
<left>150</left>
<top>60</top>
<top>65</top>
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<textcolor>FFAAAAAA</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B][COLOR FFAAAAAA]$INFO[ListItem.Property(channel)][/COLOR][/B]</label>
<label>[B]$INFO[ListItem.Property(channel)][/B]</label>
</control>
</itemlayout>
<focusedlayout height="140" width="700">
@@ -115,7 +115,7 @@
<description>Selection Background</description>
<width>700</width>
<height>130</height>
<texture colordiffuse="88000000">white.png</texture>
<texture colordiffuse="CCFFFFFF">white.png</texture>
<aspectratio>scale</aspectratio>
</control>
<control type="image">
@@ -143,7 +143,7 @@
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<textcolor>FF232323</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
@@ -152,15 +152,15 @@
<control type="textbox">
<description>Channel</description>
<left>150</left>
<top>60</top>
<top>65</top>
<width>450</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<textcolor>FF555555</textcolor>
<shadowcolor>00000000</shadowcolor>
<align>left</align>
<aligny>center</aligny>
<label>[B][COLOR FFAAAAAA]$INFO[ListItem.Property(channel)][/COLOR][/B]</label>
<label>[B]$INFO[ListItem.Property(channel)][/B]</label>
</control>
</focusedlayout>
</control>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,16 +1,15 @@
# -*- coding: utf-8 -*-
from logging import Logger
import threading
from core import jsontools, support
import xbmc, xbmcgui, sys, channelselector, time, os
import xbmc, xbmcgui, sys, channelselector, time, threading
from core.support import dbg, tmdb
from core.item import Item
from core import channeltools, servertools, scrapertools
from core import channeltools, scrapertools, support
from platformcode import platformtools, config, logger
from platformcode.launcher import run
from threading import Thread
from platformcode.dbconverter import reload
from collections import OrderedDict
if sys.version_info[0] >= 3:
PY3 = True
@@ -24,13 +23,9 @@ def_lang = info_language[config.get_setting("info_language", "videolibrary")]
close_action = False
update_lock = threading.Lock()
workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None
def set_workers():
workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None
return workers
def new_search(*args):
xbmc.executebuiltin('Dialog.Close(all)')
w = SearchWindow('GlobalSearch.xml', config.get_runtime_path())
@@ -53,25 +48,23 @@ FULLSCREEN = 18
# Container
SEARCH = 1
EPISODES = 2
SERVERS = 3
NORESULTS = 4
NORESULTS = 3
# Search
MAINTITLE = 100
CHANNELS = 101
RESULTS = 102
EPISODESLIST = 103
PROGRESS = 500
COUNT = 501
MENU = 502
BACK = 503
CLOSE = 504
QUALITYTAG = 505
TAB = 506
TAB = 505
NEXT = 506
PREV = 507
# Servers
EPISODESLIST = 200
SERVERLIST = 300
class SearchWindow(xbmcgui.WindowXML):
def start(self, item, moduleDict={}, searchActions=[], thActions=None):
@@ -79,7 +72,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.exit = False
self.item = item
self.channels = []
self.channels = OrderedDict({'valid':[]})
self.persons = []
self.episodes = []
self.results = {}
@@ -93,6 +86,11 @@ class SearchWindow(xbmcgui.WindowXML):
self.items = []
self.search_threads = []
self.reload = False
self.nextAction = None
self.next = None
self.previous = None
self.FOCUS = False
if not thActions and not self.searchActions:
self.thActions = Thread(target=self.getActionsThread)
@@ -201,8 +199,6 @@ class SearchWindow(xbmcgui.WindowXML):
it.setArt({'poster':result.get('thumbnail', noThumb), 'fanart':result.get('fanart', '')})
platformtools.set_infolabels(it, new_item)
# logger.debug(jsontools.dump(result))
# logger.debug(new_item)
color = 'FFFFFFFF' if not rating else 'FFDB2360' if rating < 4 else 'FFD2D531' if rating < 7 else 'FF21D07A'
it.setProperties({'rating': str(int(rating) * 10) if rating else 100, 'color':color, 'item': new_item.tourl(), 'search': 'search'})
@@ -325,13 +321,12 @@ class SearchWindow(xbmcgui.WindowXML):
self.MAINTITLE.setText('{} | {}/{} [{}"]'.format(self.mainTitle,self.count, len(self.searchActions), int(time.time() - self.time)))
if percent == 100:
if len(self.channels) == 1:
if len(self.channels['valid']) or len(self.channels) == 2:
self.setFocusId(RESULTS)
elif not self.results:
self.PROGRESS.setVisible(False)
elif not len(self.channels['valid']) and not len(self.channels):
self.NORESULTS.setVisible(True)
self.setFocusId(CLOSE)
self.channels = []
OrderedDict({'valid':[]})
self.moduleDict = {}
self.searchActions = []
@@ -342,13 +337,25 @@ class SearchWindow(xbmcgui.WindowXML):
self.count = 0
Thread(target=self.timer).start()
# for searchAction in self.getActions():
# self.search_threads.append(self.get_channel_results(searchAction))
try:
with futures.ThreadPoolExecutor(max_workers=set_workers()) as executor:
with futures.ThreadPoolExecutor(max_workers=workers) as executor:
for searchAction in self.getActions():
if self.exit: return
self.search_threads.append(executor.submit(self.get_channel_results, searchAction))
for res in futures.as_completed(self.search_threads):
if res.result():
valid, results = res.result()
self.channels['valid'].extend(valid)
if results:
name = results[0].channel
if name not in results:
self.channels[name] = []
self.channels[name].extend(results)
if valid or results:
self.update()
except:
import traceback
logger.error(traceback.format_exc())
@@ -382,6 +389,9 @@ class SearchWindow(xbmcgui.WindowXML):
valid = []
other = []
if self.exit:
return [], [], []
try:
results, valid, other = channel_search(self.item.text)
@@ -401,110 +411,79 @@ class SearchWindow(xbmcgui.WindowXML):
import traceback
logger.error(traceback.format_exc())
if self.exit:
return
update_lock.acquire()
self.count += 1
self.update(valid, other if other else results)
update_lock.release()
return valid, other if other else results
def makeItem(self, item):
if type(item) == str: item = Item().fromurl(item)
channelParams = channeltools.get_channel_parameters(item.channel)
info = item.infoLabels
title = item.title
tagline = info.get('tagline')
if 'download' in item.action or 'videolibrary' in item.action:
title = '{}{}'.format(item.title, item.contentTitle)
else:
title = '[B]{}[/B]'.format(item.contentTitle) + ('\n[I]{}[/I]'.format(tagline) if tagline else '')
if tagline == title: tagline = ''
if item.contentType == 'episode':
tagline = ''
title = '{:02d}. {}'.format(item.contentEpisodeNumber, item.contentTitle)
if item.contentSeason:
title = '{}x{}'.format(item.contentSeason, title)
if item.contentLanguage:
title = '{} [{}]'.format(title, item.contentLanguage)
if item.quality:
title = title = '{} [{}]'.format(title, item.quality)
if tagline:
title = '[B]{}[/B]'.format(title) + ('\n[I]{}[/I]'.format(tagline))
thumb = item.thumbnail if item.thumbnail else 'Infoplus/' + item.contentType.replace('show', '') + '.png'
it = xbmcgui.ListItem(title)
it.setArt({'poster':thumb, 'fanart':item.fanart})
it.setArt({'poster':thumb, 'fanart':item.fanart, 'thumb':thumb if config.get_setting('episode_info') else ''})
platformtools.set_infolabels(it, item)
logger.debug(item)
# logger.debug(item)
rating = info.get('rating')
color = 'FFFFFFFF' if not rating else 'FFDB2360' if rating < 4 else 'FFD2D531' if rating < 7 else 'FF21D07A'
it.setProperties({'rating': str(int(info.get('rating',10) * 10)), 'color': color,
'item': item.tourl(), 'verified': item.verified, 'channel':channelParams['title'], 'channelthumb': channelParams['thumbnail'], 'sub':'true' if 'sub' in item.contentLanguage.lower() else ''})
if item.server:
servername = servertools.get_server_parameters(item.server.lower()).get('name', item.server)
if item. quality: servername ='{} [{}]'.format(servername, item.quality)
it.setLabel(servername)
color = scrapertools.find_single_match(item.alive, r'(FF[^\]]+)')
it.setArt({'poster': config.get_online_server_thumb(item.server)})
it.setProperties({'quality':'[{}]'.format(item.quality) if item.quality else '',
'channel': channeltools.get_channel_parameters(item.channel).get('title', ''),
'color': color if color else 'FF0082C2'})
return it
def update(self, valid, results):
if self.exit:
return
def update(self):
channels = []
for name, value in self.channels.items():
thumb = 'valid.png'
if name != 'valid':
thumb = channeltools.get_channel_parameters(name)['thumbnail']
if value:
item = xbmcgui.ListItem(name)
item.setArt({'poster': thumb })
item.setProperties({'position': '0',
'results': str(len(value))})
channels.append(item)
if self.item.mode != 'all' and 'valid' not in self.results:
self.results['valid'] = 0
item = xbmcgui.ListItem('valid')
item.setArt({'poster':'valid.png'})
item.setProperties({'position': '0',
'results': '0'})
self.channels.append(item)
pos = self.CHANNELS.getSelectedPosition()
self.CHANNELS.addItems(self.channels)
self.CHANNELS.selectItem(pos)
if valid and self.CHANNELS.size():
item = self.CHANNELS.getListItem(0)
resultsList = item.getProperty('items')
for result in valid:
resultsList += result.tourl() + '|'
item.setProperty('items', resultsList)
self.channels[0].setProperty('results', str(len(resultsList.split('|')) - 1 ))
if self.CHANNELS.getSelectedPosition() == 0:
items = []
for result in valid:
if result: items.append(self.makeItem(result))
pos = self.RESULTS.getSelectedPosition()
self.RESULTS.addItems(items)
if pos < 0:
self.setFocusId(RESULTS)
pos = 0
self.RESULTS.selectItem(pos)
if results:
resultsList = ''
channelParams = channeltools.get_channel_parameters(results[0].channel)
name = channelParams['title']
item = xbmcgui.ListItem(name)
item.setArt({'poster':channelParams['thumbnail']})
item.setProperties({'position': '0',
'results': str(len(results))
})
for result in results:
resultsList += result.tourl() + '|'
item.setProperties({'items': resultsList, 'results': str(len(resultsList.split('|')) - 1)})
self.results[name] = len(self.results)
self.channels.append(item)
if channels:
pos = self.CHANNELS.getSelectedPosition()
if pos < 0: pos = 0
self.CHANNELS.reset()
self.CHANNELS.addItems(self.channels)
self.CHANNELS.addItems(channels)
self.CHANNELS.selectItem(pos)
if len(self.channels) == 1:
self.setFocusId(CHANNELS)
channelResults = self.CHANNELS.getListItem(self.results[name]).getProperty('items').split('|')
items = []
for result in channelResults:
if result: items.append(self.makeItem(result))
self.RESULTS.reset()
self.RESULTS.addItems(items)
focus = self.getFocusId()
items = [self.makeItem(r) for r in self.channels[self.CHANNELS.getSelectedItem().getLabel()]]
subpos = self.RESULTS.getSelectedPosition()
self.RESULTS.reset()
self.RESULTS.addItems(items)
self.RESULTS.selectItem(subpos)
if not self.FOCUS:
if len(self.channels['valid']):
self.FOCUS = True
self.setFocusId(RESULTS)
elif focus not in [RESULTS]:
self.FOCUS = True
self.setFocusId(CHANNELS)
def onInit(self):
self.NORESULTS = self.getControl(NORESULTS)
@@ -514,17 +493,18 @@ class SearchWindow(xbmcgui.WindowXML):
self.mainTitle = config.get_localized_string(30993).replace('...', '') % '"%s"' % self.item.text
# collect controls
self.NEXT = self.getControl(NEXT)
self.NEXT.setVisible(False)
self.PREV = self.getControl(PREV)
self.PREV.setVisible(False)
self.CHANNELS = self.getControl(CHANNELS)
self.RESULTS = self.getControl(RESULTS)
self.PROGRESS = self.getControl(PROGRESS)
self.COUNT = self.getControl(COUNT)
self.MAINTITLE = self.getControl(MAINTITLE)
self.MAINTITLE.setText(self.mainTitle)
self.SEARCH = self.getControl(SEARCH)
self.EPISODES = self.getControl(EPISODES)
self.EPISODESLIST = self.getControl(EPISODESLIST)
self.SERVERS = self.getControl(SERVERS)
self.SERVERLIST = self.getControl(SERVERLIST)
self.Focus(self.focus)
if self.item.mode.split('_')[0] in ['all', 'search']:
@@ -543,45 +523,39 @@ class SearchWindow(xbmcgui.WindowXML):
self.focus = CHANNELS
self.SEARCH.setVisible(True)
self.EPISODES.setVisible(False)
self.SERVERS.setVisible(False)
if focusid in [EPISODES]:
self.focus = focusid
self.SEARCH.setVisible(False)
self.EPISODES.setVisible(True)
self.SERVERS.setVisible(False)
if focusid in [SERVERS]:
self.focus = SERVERLIST
self.SEARCH.setVisible(False)
self.EPISODES.setVisible(False)
self.SERVERS.setVisible(True)
def onAction(self, action):
global close_action
action = action.getId()
focus = self.getFocusId()
if action in [CONTEXT] and focus in [RESULTS, EPISODESLIST, SERVERLIST]:
if action in [CONTEXT] and focus in [RESULTS, EPISODESLIST]:
self.context()
elif focus in [EPISODESLIST] and action in [LEFT, RIGHT]:
if action in [LEFT]:
item = self.previous
if action in [RIGHT]:
item = self.next
if item:
platformtools.dialog_busy(True)
self.loadEpisodes(item)
platformtools.dialog_busy(False)
elif action in [SWIPEUP] and self.CHANNELS.isVisible():
self.setFocusId(CHANNELS)
pos = self.CHANNELS.getSelectedPosition()
self.CHANNELS.selectItem(pos)
elif action in [LEFT, RIGHT, MOUSEMOVE] and focus in [CHANNELS] and self.CHANNELS.isVisible():
items = []
name = self.CHANNELS.getSelectedItem().getLabel()
subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
channelResults = self.CHANNELS.getListItem(self.results[name]).getProperty('items').split('|')
for result in channelResults:
if result: items.append(self.makeItem(result))
self.RESULTS.reset()
self.RESULTS.addItems(items)
self.RESULTS.selectItem(subpos)
self.channelItems()
elif (action in [DOWN] and focus in [BACK, CLOSE, MENU]) or focus not in [BACK, CLOSE, MENU, SERVERLIST, EPISODESLIST, RESULTS, CHANNELS]:
if self.SERVERS.isVisible(): self.setFocusId(SERVERLIST)
elif self.EPISODES.isVisible(): self.setFocusId(EPISODESLIST)
elif (action in [DOWN] and focus in [BACK, CLOSE, MENU]) or focus not in [BACK, CLOSE, MENU, EPISODESLIST, RESULTS, CHANNELS]:
if self.EPISODES.isVisible(): self.setFocusId(EPISODESLIST)
elif self.RESULTS.isVisible() and self.RESULTS.size() > 0: self.setFocusId(RESULTS)
elif self.CHANNELS.isVisible(): self.setFocusId(CHANNELS)
@@ -610,17 +584,7 @@ class SearchWindow(xbmcgui.WindowXML):
if self.RESULTS.getSelectedItem(): search = self.RESULTS.getSelectedItem().getProperty('search')
else: search = None
if control_id in [CHANNELS, TAB]:
items = []
name = self.CHANNELS.getSelectedItem().getLabel()
subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
channelResults = self.CHANNELS.getListItem(self.results[name]).getProperty('items').split('|')
for result in channelResults:
if result: items.append(self.makeItem(result))
self.RESULTS.reset()
self.RESULTS.addItems(items)
self.RESULTS.selectItem(subpos)
self.CHANNELS.getSelectedItem().setProperty('position', str(subpos))
self.setFocusId(CHANNELS)
self.channelItems()
elif control_id in [BACK]:
self.Back()
@@ -656,6 +620,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.close()
elif control_id in [RESULTS, EPISODESLIST]:
platformtools.dialog_busy(True)
if control_id in [RESULTS]:
name = self.CHANNELS.getSelectedItem().getLabel()
@@ -665,84 +630,77 @@ class SearchWindow(xbmcgui.WindowXML):
item_url = self.EPISODESLIST.getSelectedItem().getProperty('item')
if item_url:
item = Item().fromurl(item_url)
else: # no results item
platformtools.dialog_busy(False)
return
if item.action in ['add_movie_to_library', 'add_serie_to_library','save_download']: # special items (add to videolibrary, download ecc.)
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item_url + ")")
if item.action:
item.window = True
item.folder = False
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")")
platformtools.dialog_busy(False)
return
try:
self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
self.itemsResult = getattr(self.channel, item.action)(item)
except:
import traceback
logger.error('error importing/getting search items of ' + item.channel)
logger.error(traceback.format_exc())
self.itemsResult = []
if self.itemsResult and self.itemsResult[0].action in ['play', '']:
if config.get_setting('checklinks') and not config.get_setting('autoplay'):
self.itemsResult = servertools.check_list_links(self.itemsResult, config.get_setting('checklinks_number'))
for s in self.itemsResult: logger.debug(s)
servers = [self.makeItem(s) for s in self.itemsResult if s.server]
if not servers:
servers = [xbmcgui.ListItem(config.get_localized_string(60347))]
servers[0].setArt({'poster': support.thumb('nofolder')})
self.Focus(SERVERS)
self.SERVERLIST.reset()
self.SERVERLIST.addItems(servers)
self.setFocusId(SERVERLIST)
if config.get_setting('autoplay'):
platformtools.dialog_busy(False)
else:
self.episodes = self.itemsResult if self.itemsResult else []
self.itemsResult = []
ep = []
for item in self.episodes:
title = item.contentTitle
if item.contentEpisodeNumber: title = '{:02d}. {}'.format(item.contentEpisodeNumber, title)
if item.contentSeason: title = '{}x{}'.format(item.contentSeason, title)
it = xbmcgui.ListItem(title)
it.setProperty('item', item.tourl())
ep.append(it)
if not ep:
ep = [xbmcgui.ListItem(config.get_localized_string(60347))]
ep[0].setArt({'poster', support.thumb('nofolder')})
self.Focus(EPISODES)
self.EPISODESLIST.reset()
self.EPISODESLIST.addItems(ep)
self.setFocusId(EPISODESLIST)
self.loadEpisodes(item)
platformtools.dialog_busy(False)
def channelItems(self):
items = []
name = self.CHANNELS.getSelectedItem().getLabel()
subpos = int(self.CHANNELS.getSelectedItem().getProperty('position'))
channelResults = self.channels.get(name)
for result in channelResults:
if result: items.append(self.makeItem(result))
self.RESULTS.reset()
self.RESULTS.addItems(items)
self.RESULTS.selectItem(subpos)
elif control_id in [SERVERLIST]:
server = Item().fromurl(self.getControl(control_id).getSelectedItem().getProperty('item'))
return self.play(server)
def loadEpisodes(self ,item):
try:
self.channel = __import__('channels.%s' % item.channel, fromlist=["channels.%s" % item.channel])
self.itemsResult = getattr(self.channel, item.action)(item)
except:
import traceback
logger.error('error importing/getting search items of ' + item.channel)
logger.error(traceback.format_exc())
self.itemsResult = []
self.episodes = self.itemsResult if self.itemsResult else []
self.itemsResult = []
ep = []
isnext = False
for e in self.episodes:
if e.action in ['findvideos']:
ep.append(self.makeItem(e))
if e.nextSeason and e.action in ['episodios']:
self.nextAction = e.clone()
isnext = True
if self.nextAction:
self.next = None
self.previous = None
if isnext:
self.next = self.nextAction.clone()
if self.nextAction.nextSeason > 1 or not self.next:
self.previous = self.nextAction.clone(nextSeason = self.nextAction.nextSeason - 2 if self.next else 0)
self.NEXT.setVisible(True if self.next else False)
self.PREV.setVisible(True if self.previous else False)
if not ep:
ep = [xbmcgui.ListItem(config.get_localized_string(60347))]
ep[0].setArt({'poster', support.thumb('nofolder')})
self.Focus(EPISODES)
self.EPISODESLIST.reset()
self.EPISODESLIST.addItems(ep)
self.setFocusId(EPISODESLIST)
def Back(self):
self.getControl(QUALITYTAG).setText('')
if self.SERVERS.isVisible():
if self.episodes:
self.Focus(EPISODES)
self.setFocusId(EPISODESLIST)
else:
self.Focus(SEARCH)
self.setFocusId(RESULTS)
self.RESULTS.selectItem(self.pos)
elif self.EPISODES.isVisible():
if self.EPISODES.isVisible():
self.episodes = []
self.Focus(SEARCH)
self.setFocusId(RESULTS)
@@ -765,9 +723,6 @@ class SearchWindow(xbmcgui.WindowXML):
if focus == EPISODESLIST: # context on episode
item_url = self.EPISODESLIST.getSelectedItem().getProperty('item')
parent = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item'))
elif focus == SERVERLIST:
item_url = self.SERVERLIST.getSelectedItem().getProperty('item')
parent = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item'))
else:
item_url = self.RESULTS.getSelectedItem().getProperty('item')
parent = self.item
@@ -778,10 +733,7 @@ class SearchWindow(xbmcgui.WindowXML):
context_commands = [c[1].replace('Container.Refresh', 'RunPlugin').replace('Container.Update', 'RunPlugin').replace(')','&no_reload=True)') for c in commands]
index = xbmcgui.Dialog().contextmenu(context)
self.reload = True
if index > 0: xbmc.executebuiltin(context_commands[index])
def play(self, server=None):
platformtools.prevent_busy(server)
server.window = True
server.globalsearch = True
return run(server)
xbmc.executebuiltin(context_commands[index])
# if index > 0: xbmc.executebuiltin(context_commands[index])