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
+1
View File
@@ -460,6 +460,7 @@ def scrape(func):
logger.debug('PATRON= ', patron) logger.debug('PATRON= ', patron)
if not data: if not data:
page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True) page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True)
item.url = page.url # might be a redirect
data = page.data data = page.data
data = html_uniform(data) data = html_uniform(data)
scrapingTime = time() scrapingTime = time()
+3
View File
@@ -471,6 +471,9 @@ def find_and_set_infoLabels(item):
results = otmdb_global.get_list_results() results = otmdb_global.get_list_results()
if len(results) > 1: 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) tmdb_result = platformtools.show_video_info(results, item=item, caption= content_type % title)
elif len(results) > 0: elif len(results) > 0:
tmdb_result = results[0] tmdb_result = results[0]
+11 -22
View File
@@ -143,14 +143,11 @@ def save_movie(item, silent=False):
logger.debug("contentTitle NOT FOUND") logger.debug("contentTitle NOT FOUND")
return 0, 0, -1, path # Salimos sin guardar return 0, 0, -1, path # Salimos sin guardar
scraper_return = scraper.find_and_set_infoLabels(item)
# support.dbg()
# At this point we can have: # At this point we can have:
# scraper_return = True: An item with infoLabels with the updated information of the movie # 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) # 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 # 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") logger.debug("NOT FOUND IN SCRAPER OR DO NOT HAVE code")
return 0, 0, -1, path return 0, 0, -1, path
@@ -242,7 +239,7 @@ def save_movie(item, silent=False):
logger.debug("Creating .nfo: " + nfo_path) logger.debug("Creating .nfo: " + nfo_path)
inserted += 1 inserted += 1
item = remove_host(item) remove_host(item)
# write on db # write on db
if item.channel in channels and item.channel != 'download': if item.channel in channels and item.channel != 'download':
channels_url = [u.url for u in channels[item.channel]] 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 return 0, 0, -1, path # Salimos sin guardar
contentTypeBackup = item.contentType # Fix errors in some channels 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 item.contentType = contentTypeBackup # Fix errors in some channels
# At this point we can have: # At this point we can have:
# scraper_return = True: An item with infoLabels with the updated information of the series # 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) # 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 # 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") logger.debug("NOT FOUND IN SCRAPER OR DO NOT HAVE code")
return 0, 0, -1, path return 0, 0, -1, path
@@ -431,7 +424,7 @@ def save_tvshow(item, episodelist, silent=False):
tvshow_item.lang_list = [] tvshow_item.lang_list = []
item = remove_host(item) remove_host(item)
item.renumber = add_renumber_options(item) item.renumber = add_renumber_options(item)
# write on db # write on db
if item.channel in channels and item.channel != 'download': if item.channel in channels and item.channel != 'download':
@@ -552,7 +545,7 @@ def save_episodes(item, episodelist, silent=False, overwrite=True):
# else: # else:
epchannels = episode.get('channels',{}) epchannels = episode.get('channels',{})
e = remove_host(e) remove_host(e)
e.contentTitle = e.infoLabels['title'] e.contentTitle = e.infoLabels['title']
e.infoLabels = {} e.infoLabels = {}
@@ -882,17 +875,13 @@ def add_tvshow(item, channel=None):
def remove_host(item): def remove_host(item):
try : if PY3:
channel = __import__('channels.' + item.channel, None, None, ['channels.' + item.channel]) import urllib.parse as urlparse # It is very slow in PY2. In PY3 it is native
except: else:
channel = __import__('specials.' + item.channel, None, None, ['specials.' + item.channel]) 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): def get_id(item):
_id = '' _id = ''
+2 -2
View File
@@ -26,7 +26,7 @@ intervenido_sucuri = 'Access Denied - Sucuri Website Firewall'
def update_title(item): def update_title(item):
logger.debug() 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 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+\/') 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 # 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['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['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 if item.infoLabels['season']: del item.infoLabels['season'] # It works wrong with num. seasonal. Then we restore it
+1 -1
View File
@@ -62,7 +62,7 @@ class addVideo(object):
conn.close() conn.close()
def get_id(self): 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) 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) nun_records, records = execute_sql_kodi(sql, conn=conn)
if nun_records: return True, records[0][0] if nun_records: return True, records[0][0]
+2 -2
View File
@@ -1230,15 +1230,15 @@ def execute_sql_kodi(sql, params=None, conn=None):
cursor.execute(sql, params) cursor.execute(sql, params)
else: else:
cursor.execute(sql) cursor.execute(sql)
conn_internal.commit()
records = cursor.fetchall()
if sql.lower().startswith("select"): if sql.lower().startswith("select"):
records = cursor.fetchall()
nun_records = len(records) nun_records = len(records)
if nun_records == 1 and records[0][0] is None: if nun_records == 1 and records[0][0] is None:
nun_records = 0 nun_records = 0
records = [] records = []
else: else:
conn_internal.commit()
nun_records = conn.total_changes nun_records = conn.total_changes
if not conn: if not conn:
@@ -4853,7 +4853,7 @@ msgid "Searching in Mymovies"
msgstr "" msgstr ""
msgctxt "#70513" msgctxt "#70513"
msgid "" msgid "Choose another content, if it was wrongly identified"
msgstr "" msgstr ""
msgctxt "#70514" msgctxt "#70514"
@@ -4852,8 +4852,8 @@ msgid "Searching in Mymovies"
msgstr "Ricerca in Mymovies" msgstr "Ricerca in Mymovies"
msgctxt "#70513" msgctxt "#70513"
msgid "" msgid "Choose another content, if it was wrongly identified"
msgstr "" msgstr "Scegli un altro contenuto, se è stato erroneamente identificato"
msgctxt "#70514" msgctxt "#70514"
msgid "" msgid ""
+133 -129
View File
@@ -1,133 +1,137 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<window> <window>
<depth>0.52</depth> <depth>0.52</depth>
<coordinates> <coordinates>
<left>0</left> <left>0</left>
<top>0</top> <top>0</top>
</coordinates> </coordinates>
<controls> <controls>
<!-- GROUP CONTROLS --> <!-- GROUP CONTROLS -->
<control type="group"> <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>
<left>0</left> <left>0</left>
<width>180</width> <top>0</top>
<height>270</height> <animation type="WindowOpen" reversible="false">
<texture>$INFO[ListItem.Property(thumbnail)]</texture> <effect type="slide" start="0,100" end="0,0" delay="160" time="160"/>
<aspectratio>scale</aspectratio> <effect type="fade" delay="160" end="100" time="100"/>
<bordersize>10</bordersize> </animation>
</control> <animation type="WindowClose" reversible="false">
</itemlayout> <effect type="slide" start="0,0" end="0,100" delay="160" time="160"/>
<focusedlayout width="427"> <effect type="fade" delay="160" start="100" end="0" time="100"/>
<!-- Title --> </animation>
<control type="textbox">
<left>447</left> <!-- BACKGROUND -->
<top>10</top> <control type="image">
<width>783</width> <width>1280</width>
<height>30</height> <height>720</height>
<font>font13</font> <texture colordiffuse="FF232323">white.png</texture>
<textcolor>FFFFFFFF</textcolor> </control>
<shadowcolor>00000000</shadowcolor>
<label>[B]$INFO[ListItem.Label] [COLOR FFAAAAAA] $INFO[ListItem.Property(year)][/COLOR][/B] </label> <!-- FANART -->
<align>left</align> <control type="image" id='30000'>
<aligny>center</aligny> <width>1280</width>
</control> <height>720</height>
<!-- info --> <texture colordiffuse="FF555555"></texture>
<control type="textbox"> </control>
<left>447</left>
<top>50</top> <!-- LOADING -->
<width>783</width> <control type="image" id='30001'>
<height>30</height> <top>355</top>
<font>font13</font> <left>490</left>
<textcolor>FFFFFFFF</textcolor> <width>300</width>
<shadowcolor>00000000</shadowcolor> <height>10</height>
<label>$ADDON[plugin.video.kod 60382] $INFO[ListItem.Property(genre)] | $ADDON[plugin.video.kod 60380] [B]$INFO[ListItem.Property(rating)][/B]</label> <texture>white.png</texture>
<align>left</align> <animation effect="zoom" pulse="true" center="auto" start="0,100" end="100,100" time="1000"
</control> condition="Control.IsVisible(30001)">Conditional
<!-- Plot --> </animation>
<control type="textbox"> </control>
<left>447</left> <control type="button" id="30003">
<top>90</top> <top>40</top>
<width>783</width> <right>40</right>
<height>250</height> <height>50</height>
<font>font13</font> <width>50</width>
<textcolor>FFFFFFFF</textcolor> <textcolor>FFFFFFFF</textcolor>
<shadowcolor>00000000</shadowcolor> <aligny>center</aligny>
<label>$INFO[ListItem.Property(plot)]</label> <align>center</align>
<autoscroll time="3000" delay="3000" repeat="3000">True</autoscroll> <texturefocus colordiffuse="FFFFFFFF">close.png</texturefocus>
<align>left</align> <texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus>
</control> <ondown>30002</ondown>
<!-- Poster --> </control>
<control type="image">
<bottom>0</bottom> <!-- SELECTION -->
<left>0</left> <control type="fixedlist" id="30002">
<width>427</width> <top>40</top>
<height>640</height> <width>100%</width>
<texture>$INFO[ListItem.Property(thumbnail)]</texture> <height>640</height>
<aspectratio>scale</aspectratio> <viewtype>wrap</viewtype>
<bordersize>10</bordersize> <orientation>horizontal</orientation>
</control> <scrolltime tween="cubic" easing="out">300</scrolltime>
</focusedlayout> <onup>30003</onup>
</control> <itemlayout width="180">
</control> <!-- GROUP CONTROLS END --> <!-- Poster -->
</controls> <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> </window>