Ottimizzazione remove_host e contenuto dell'item al primo posto nella schermata InfoWindow

This commit is contained in:
mac12m99
2021-05-15 20:37:00 +02:00
parent 8eb5881559
commit b6dcb8f716
9 changed files with 156 additions and 159 deletions

View File

@@ -460,6 +460,7 @@ def scrape(func):
logger.debug('PATRON= ', patron)
if not data:
page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True)
item.url = page.url # might be a redirect
data = page.data
data = html_uniform(data)
scrapingTime = time()

View File

@@ -471,6 +471,9 @@ def find_and_set_infoLabels(item):
results = otmdb_global.get_list_results()
if len(results) > 1:
# select tmdb_id at the first position
if item.infoLabels['selected_tmdb_id']:
results.insert(0, results.pop([r.get('id') for r in results].index(int(item.infoLabels['selected_tmdb_id']))))
tmdb_result = platformtools.show_video_info(results, item=item, caption= content_type % title)
elif len(results) > 0:
tmdb_result = results[0]

View File

@@ -143,14 +143,11 @@ def save_movie(item, silent=False):
logger.debug("contentTitle NOT FOUND")
return 0, 0, -1, path # Salimos sin guardar
scraper_return = scraper.find_and_set_infoLabels(item)
# support.dbg()
# At this point we can have:
# scraper_return = True: An item with infoLabels with the updated information of the movie
# scraper_return = False: An item without movie information (it has been canceled in the window)
# item.infoLabels['code'] == "" : The required IMDB identifier was not found to continue, we quit
if not scraper_return or not item.infoLabels['code']:
if not item.infoLabels['code']:
logger.debug("NOT FOUND IN SCRAPER OR DO NOT HAVE code")
return 0, 0, -1, path
@@ -242,7 +239,7 @@ def save_movie(item, silent=False):
logger.debug("Creating .nfo: " + nfo_path)
inserted += 1
item = remove_host(item)
remove_host(item)
# write on db
if item.channel in channels and item.channel != 'download':
channels_url = [u.url for u in channels[item.channel]]
@@ -349,17 +346,13 @@ def save_tvshow(item, episodelist, silent=False):
return 0, 0, -1, path # Salimos sin guardar
contentTypeBackup = item.contentType # Fix errors in some channels
if not item.infoLabels['code']:
scraper_return = scraper.find_and_set_infoLabels(item)
else:
scraper_return = True
item.contentType = contentTypeBackup # Fix errors in some channels
# At this point we can have:
# scraper_return = True: An item with infoLabels with the updated information of the series
# scraper_return = False: An item without movie information (it has been canceled in the window)
# item.infoLabels['code'] == "" :T he required IMDB identifier was not found to continue, we quit
if not scraper_return or not item.infoLabels['code']:
if not item.infoLabels['code']:
logger.debug("NOT FOUND IN SCRAPER OR DO NOT HAVE code")
return 0, 0, -1, path
@@ -431,7 +424,7 @@ def save_tvshow(item, episodelist, silent=False):
tvshow_item.lang_list = []
item = remove_host(item)
remove_host(item)
item.renumber = add_renumber_options(item)
# write on db
if item.channel in channels and item.channel != 'download':
@@ -552,7 +545,7 @@ def save_episodes(item, episodelist, silent=False, overwrite=True):
# else:
epchannels = episode.get('channels',{})
e = remove_host(e)
remove_host(e)
e.contentTitle = e.infoLabels['title']
e.infoLabels = {}
@@ -882,17 +875,13 @@ def add_tvshow(item, channel=None):
def remove_host(item):
try :
channel = __import__('channels.' + item.channel, None, None, ['channels.' + item.channel])
except:
channel = __import__('specials.' + item.channel, None, None, ['specials.' + item.channel])
if PY3:
import urllib.parse as urlparse # It is very slow in PY2. In PY3 it is native
else:
import urlparse # We use the native of PY2 which is faster
parsed_url = urlparse.urlparse(item.url)
item.url = urlparse.urlunparse(('', '', parsed_url.path, parsed_url.params, parsed_url.query, parsed_url.fragment))
host = httptools.downloadpage(channel.host, only_headers=True).url
if host.endswith('/'): host = host[:-1]
item.url = item.url.replace(host, '')
return item
def get_id(item):
_id = ''

View File

@@ -26,7 +26,7 @@ intervenido_sucuri = 'Access Denied - Sucuri Website Firewall'
def update_title(item):
logger.debug()
from core import scraper,support
from core import scraper
"""
@@ -104,7 +104,7 @@ def update_title(item):
if item.channel == channel_py: # If it is a NewPct1 movie, we put the name of the clone
item.channel = scrapertools.find_single_match(item.url, r'http.?\:\/\/(?:www.)?(\w+)\.\w+\/')
# We delete the IDs and the year to force TMDB to ask us
if item.infoLabels['tmdb_id'] or item.infoLabels['tmdb_id'] == None: item.infoLabels['tmdb_id'] = ''
if item.infoLabels['tmdb_id'] or item.infoLabels['tmdb_id'] == None: item.infoLabels['selected_tmdb_id'] = item.infoLabels['tmdb_id']; item.infoLabels['tmdb_id'] = ''
if item.infoLabels['tvdb_id'] or item.infoLabels['tvdb_id'] == None: item.infoLabels['tvdb_id'] = ''
if item.infoLabels['imdb_id'] or item.infoLabels['imdb_id'] == None: item.infoLabels['imdb_id'] = ''
if item.infoLabels['season']: del item.infoLabels['season'] # It works wrong with num. seasonal. Then we restore it

View File

@@ -62,7 +62,7 @@ class addVideo(object):
conn.close()
def get_id(self):
Type = 'id' + self.item.contentType.replace('tv','').capitalize()
Type = 'id' + self.item.contentType.replace('tv', '').capitalize()
sql = 'select {} from {}_view where (uniqueid_value = "{}" and uniqueid_type = "kod")'.format(Type, self.item.contentType, self.item.videolibrary_id)
nun_records, records = execute_sql_kodi(sql, conn=conn)
if nun_records: return True, records[0][0]

View File

@@ -1230,15 +1230,15 @@ def execute_sql_kodi(sql, params=None, conn=None):
cursor.execute(sql, params)
else:
cursor.execute(sql)
conn_internal.commit()
records = cursor.fetchall()
if sql.lower().startswith("select"):
records = cursor.fetchall()
nun_records = len(records)
if nun_records == 1 and records[0][0] is None:
nun_records = 0
records = []
else:
conn_internal.commit()
nun_records = conn.total_changes
if not conn:

View File

@@ -4853,7 +4853,7 @@ msgid "Searching in Mymovies"
msgstr ""
msgctxt "#70513"
msgid ""
msgid "Choose another content, if it was wrongly identified"
msgstr ""
msgctxt "#70514"

View File

@@ -4852,8 +4852,8 @@ msgid "Searching in Mymovies"
msgstr "Ricerca in Mymovies"
msgctxt "#70513"
msgid ""
msgstr ""
msgid "Choose another content, if it was wrongly identified"
msgstr "Scegli un altro contenuto, se è stato erroneamente identificato"
msgctxt "#70514"
msgid ""

View File

@@ -1,133 +1,137 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<window>
<depth>0.52</depth>
<coordinates>
<left>0</left>
<top>0</top>
</coordinates>
<controls>
<!-- GROUP CONTROLS -->
<control type="group">
<left>0</left>
<top>0</top>
<animation type="WindowOpen" reversible="false">
<effect type="slide" start="0,100" end="0,0" delay="160" time="160" />
<effect type="fade" delay="160" end="100" time="100" />
</animation>
<animation type="WindowClose" reversible="false">
<effect type="slide" start="0,0" end="0,100" delay="160" time="160" />
<effect type="fade" delay="160" start="100" end="0" time="100" />
</animation>
<!-- BACKGROUND -->
<control type="image">
<width>1280</width>
<height>720</height>
<texture colordiffuse="FF232323">white.png</texture>
</control>
<!-- FANART -->
<control type="image" id='30000'>
<width>1280</width>
<height>720</height>
<texture colordiffuse="FF555555"></texture>
</control>
<!-- LOADING -->
<control type="image" id='30001'>
<top>355</top>
<left>490</left>
<width>300</width>
<height>10</height>
<texture>white.png</texture>
<animation effect="zoom" pulse ="true" center="auto" start="0,100" end="100,100" time="1000" condition="Control.IsVisible(30001)">Conditional</animation>
</control>
<control type="button" id="30003">
<top>40</top>
<right>40</right>
<height>50</height>
<width>50</width>
<textcolor>FFFFFFFF</textcolor>
<aligny>center</aligny>
<align>center</align>
<texturefocus colordiffuse="FFFFFFFF">close.png</texturefocus>
<texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus>
<ondown>30002</ondown>
</control>
<!-- SELECTION -->
<control type="fixedlist" id="30002">
<top>40</top>
<width>100%</width>
<height>640</height>
<viewtype>wrap</viewtype>
<orientation>horizontal</orientation>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<onup>30003</onup>
<itemlayout width="180">
<!-- Poster -->
<control type="image">
<top>370</top>
<depth>0.52</depth>
<coordinates>
<left>0</left>
<top>0</top>
</coordinates>
<controls>
<!-- GROUP CONTROLS -->
<control type="group">
<left>0</left>
<width>180</width>
<height>270</height>
<texture>$INFO[ListItem.Property(thumbnail)]</texture>
<aspectratio>scale</aspectratio>
<bordersize>10</bordersize>
</control>
</itemlayout>
<focusedlayout width="427">
<!-- Title -->
<control type="textbox">
<left>447</left>
<top>10</top>
<width>783</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>[B]$INFO[ListItem.Label] [COLOR FFAAAAAA] $INFO[ListItem.Property(year)][/COLOR][/B] </label>
<align>left</align>
<aligny>center</aligny>
</control>
<!-- info -->
<control type="textbox">
<left>447</left>
<top>50</top>
<width>783</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$ADDON[plugin.video.kod 60382] $INFO[ListItem.Property(genre)] | $ADDON[plugin.video.kod 60380] [B]$INFO[ListItem.Property(rating)][/B]</label>
<align>left</align>
</control>
<!-- Plot -->
<control type="textbox">
<left>447</left>
<top>90</top>
<width>783</width>
<height>250</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$INFO[ListItem.Property(plot)]</label>
<autoscroll time="3000" delay="3000" repeat="3000">True</autoscroll>
<align>left</align>
</control>
<!-- Poster -->
<control type="image">
<bottom>0</bottom>
<left>0</left>
<width>427</width>
<height>640</height>
<texture>$INFO[ListItem.Property(thumbnail)]</texture>
<aspectratio>scale</aspectratio>
<bordersize>10</bordersize>
</control>
</focusedlayout>
</control>
</control> <!-- GROUP CONTROLS END -->
</controls>
<top>0</top>
<animation type="WindowOpen" reversible="false">
<effect type="slide" start="0,100" end="0,0" delay="160" time="160"/>
<effect type="fade" delay="160" end="100" time="100"/>
</animation>
<animation type="WindowClose" reversible="false">
<effect type="slide" start="0,0" end="0,100" delay="160" time="160"/>
<effect type="fade" delay="160" start="100" end="0" time="100"/>
</animation>
<!-- BACKGROUND -->
<control type="image">
<width>1280</width>
<height>720</height>
<texture colordiffuse="FF232323">white.png</texture>
</control>
<!-- FANART -->
<control type="image" id='30000'>
<width>1280</width>
<height>720</height>
<texture colordiffuse="FF555555"></texture>
</control>
<!-- LOADING -->
<control type="image" id='30001'>
<top>355</top>
<left>490</left>
<width>300</width>
<height>10</height>
<texture>white.png</texture>
<animation effect="zoom" pulse="true" center="auto" start="0,100" end="100,100" time="1000"
condition="Control.IsVisible(30001)">Conditional
</animation>
</control>
<control type="button" id="30003">
<top>40</top>
<right>40</right>
<height>50</height>
<width>50</width>
<textcolor>FFFFFFFF</textcolor>
<aligny>center</aligny>
<align>center</align>
<texturefocus colordiffuse="FFFFFFFF">close.png</texturefocus>
<texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus>
<ondown>30002</ondown>
</control>
<!-- SELECTION -->
<control type="fixedlist" id="30002">
<top>40</top>
<width>100%</width>
<height>640</height>
<viewtype>wrap</viewtype>
<orientation>horizontal</orientation>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<onup>30003</onup>
<itemlayout width="180">
<!-- Poster -->
<control type="image">
<top>370</top>
<left>0</left>
<width>180</width>
<height>270</height>
<texture>$INFO[ListItem.Property(thumbnail)]</texture>
<aspectratio>scale</aspectratio>
<bordersize>10</bordersize>
</control>
</itemlayout>
<focusedlayout width="427">
<!-- Title -->
<control type="textbox">
<left>447</left>
<top>10</top>
<width>783</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>[B]$INFO[ListItem.Label] [COLOR FFAAAAAA] $INFO[ListItem.Property(year)][/COLOR][/B]
</label>
<align>left</align>
<aligny>center</aligny>
</control>
<!-- info -->
<control type="textbox">
<left>447</left>
<top>50</top>
<width>783</width>
<height>30</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$ADDON[plugin.video.kod 60382] $INFO[ListItem.Property(genre)] | $ADDON[plugin.video.kod
60380] [B]$INFO[ListItem.Property(rating)][/B]
</label>
<align>left</align>
</control>
<!-- Plot -->
<control type="textbox">
<left>447</left>
<top>90</top>
<width>783</width>
<height>250</height>
<font>font13</font>
<textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor>
<label>$INFO[ListItem.Property(plot)]</label>
<autoscroll time="3000" delay="3000" repeat="3000">True</autoscroll>
<align>left</align>
</control>
<!-- Poster -->
<control type="image">
<bottom>0</bottom>
<left>0</left>
<width>427</width>
<height>640</height>
<texture>$INFO[ListItem.Property(thumbnail)]</texture>
<aspectratio>scale</aspectratio>
<bordersize>10</bordersize>
</control>
</focusedlayout>
</control>
</control> <!-- GROUP CONTROLS END -->
</controls>
</window>