diff --git a/core/support.py b/core/support.py index 7e89e295..1e7b21e7 100755 --- a/core/support.py +++ b/core/support.py @@ -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() diff --git a/core/tmdb.py b/core/tmdb.py index c919688b..583c7d36 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -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] diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index 6cf16386..e1aae0ad 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -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 = '' diff --git a/lib/generictools.py b/lib/generictools.py index 382eda66..909b8474 100644 --- a/lib/generictools.py +++ b/lib/generictools.py @@ -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 diff --git a/platformcode/dbconverter.py b/platformcode/dbconverter.py index 0c4cce1e..f15870b0 100644 --- a/platformcode/dbconverter.py +++ b/platformcode/dbconverter.py @@ -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] diff --git a/platformcode/xbmc_videolibrary.py b/platformcode/xbmc_videolibrary.py index ae817ebf..7e2cc0ba 100644 --- a/platformcode/xbmc_videolibrary.py +++ b/platformcode/xbmc_videolibrary.py @@ -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: diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 1f5c4554..ce55a8e8 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -4853,7 +4853,7 @@ msgid "Searching in Mymovies" msgstr "" msgctxt "#70513" -msgid "" +msgid "Choose another content, if it was wrongly identified" msgstr "" msgctxt "#70514" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index 9edf874c..40d5c4a9 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -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 "" diff --git a/resources/skins/Default/720p/InfoWindow.xml b/resources/skins/Default/720p/InfoWindow.xml index 949ca6a9..198bf053 100644 --- a/resources/skins/Default/720p/InfoWindow.xml +++ b/resources/skins/Default/720p/InfoWindow.xml @@ -1,133 +1,137 @@ - 0.52 - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - - - - 1280 - 720 - white.png - - - - - 1280 - 720 - - - - - - 355 - 490 - 300 - 10 - white.png - Conditional - - - - 40 - 40 - 50 - 50 - FFFFFFFF - center - center - close.png - close.png - 30002 - - - - - 40 - 100% - 640 - wrap - horizontal - 300 - 30003 - - - - 370 + 0.52 + + 0 + 0 + + + + 0 - 180 - 270 - $INFO[ListItem.Property(thumbnail)] - scale - 10 - - - - - - 447 - 10 - 783 - 30 - font13 - FFFFFFFF - 00000000 - - left - center - - - - 447 - 50 - 783 - 30 - font13 - FFFFFFFF - 00000000 - - left - - - - 447 - 90 - 783 - 250 - font13 - FFFFFFFF - 00000000 - - True - left - - - - 0 - 0 - 427 - 640 - $INFO[ListItem.Property(thumbnail)] - scale - 10 - - - - - + 0 + + + + + + + + + + + + 1280 + 720 + white.png + + + + + 1280 + 720 + + + + + + 355 + 490 + 300 + 10 + white.png + Conditional + + + + 40 + 40 + 50 + 50 + FFFFFFFF + center + center + close.png + close.png + 30002 + + + + + 40 + 100% + 640 + wrap + horizontal + 300 + 30003 + + + + 370 + 0 + 180 + 270 + $INFO[ListItem.Property(thumbnail)] + scale + 10 + + + + + + 447 + 10 + 783 + 30 + font13 + FFFFFFFF + 00000000 + + left + center + + + + 447 + 50 + 783 + 30 + font13 + FFFFFFFF + 00000000 + + left + + + + 447 + 90 + 783 + 250 + font13 + FFFFFFFF + 00000000 + + True + left + + + + 0 + 0 + 427 + 640 + $INFO[ListItem.Property(thumbnail)] + scale + 10 + + + + +