Test Semplificazione Ordine server e piccoli fix
This commit is contained in:
@@ -39,14 +39,14 @@ def start(itemlist, item):
|
||||
if not config.is_xbmc():
|
||||
return itemlist
|
||||
|
||||
# Save the current value of "Action and Player Mode" in preferences
|
||||
user_config_setting_action = config.get_setting("default_action")
|
||||
# user_config_setting_player = config.get_setting("player_mode")
|
||||
|
||||
# Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive)
|
||||
if not user_config_setting_action: config.set_setting("default_action", 2)
|
||||
|
||||
if config.get_setting('autoplay'):
|
||||
# Save the current value of "Action and Player Mode" in preferences
|
||||
user_config_setting_action = config.get_setting("default_action")
|
||||
# user_config_setting_player = config.get_setting("player_mode")
|
||||
|
||||
# Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive)
|
||||
if not user_config_setting_action: config.set_setting("default_action", 2)
|
||||
|
||||
from core.servertools import sort_servers
|
||||
autoplay_list = sort_servers(itemlist)
|
||||
|
||||
|
||||
@@ -695,28 +695,19 @@ def sort_servers(servers_list):
|
||||
'sd', '480p', '480', '360p', '360', '240p', '240']
|
||||
|
||||
sorted_list = []
|
||||
url_list_valid = []
|
||||
if config.get_setting('default_action') == 1:
|
||||
favorite_quality.reverse()
|
||||
inverted = False
|
||||
|
||||
if config.get_setting('default_action') == 2:
|
||||
inverted = True
|
||||
|
||||
# Priorities when ordering itemlist:
|
||||
# 0: Servers and Qualities
|
||||
# 1: Qualities and Servers
|
||||
# 2: Servers only
|
||||
# 3: Only qualities
|
||||
# 4: Do not order
|
||||
|
||||
if config.get_setting('favorites_servers') and favorite_servers and config.get_setting('default_action') and not config.get_setting('quality_priority'):
|
||||
priority = 0 # 0: Servers and Qualities
|
||||
elif config.get_setting('favorites_servers') and favorite_servers and config.get_setting('default_action') and config.get_setting('quality_priority'):
|
||||
priority = 1 # 0: Qualities and Servers
|
||||
elif config.get_setting('favorites_servers') and favorite_servers:
|
||||
priority = 2 # Servers only
|
||||
elif config.get_setting('default_action'):
|
||||
priority = 3 # Only qualities
|
||||
else:
|
||||
priority = 4 # Do not order
|
||||
# 0: Only Qualities
|
||||
# 1: Servers and Qualities
|
||||
# 2: Qualities and Servers
|
||||
|
||||
priority = 0
|
||||
if config.get_setting('favorites_servers') and favorite_servers: priority = 1
|
||||
if config.get_setting('quality_priority'): priority = 2
|
||||
|
||||
for item in servers_list:
|
||||
element = dict()
|
||||
@@ -728,24 +719,16 @@ def sort_servers(servers_list):
|
||||
if item.server.lower() in blacklisted_servers:
|
||||
continue
|
||||
|
||||
|
||||
# if priority < 2: # 0: Servers and qualities or 1: Qualities and servers
|
||||
element["index_server"] = index(favorite_servers, item.server.lower())
|
||||
element["index_quality"] = index(favorite_quality, item.quality.lower())
|
||||
|
||||
|
||||
|
||||
element["index_quality"] = platformtools.calcResolution(item.quality)
|
||||
element['index_language'] = 0 if item.contentLanguage == 'ITA' else 1
|
||||
|
||||
element['videoitem'] = item
|
||||
sorted_list.append(element)
|
||||
|
||||
# We order according to priority
|
||||
if priority == 0: sorted_list.sort(key=lambda row: (row['index_language'], row['index_server'], row['index_quality'])) # Servers and Qualities
|
||||
elif priority == 1: sorted_list.sort(key=lambda row: (row['index_language'], row['index_quality'], row['index_server'])) # Qualities and Servers
|
||||
elif priority == 2: sorted_list.sort(key=lambda row: (row['index_language'], row['index_server'])) # Servers only
|
||||
elif priority == 3: sorted_list.sort(key=lambda row: (row['index_language'], row['index_quality'])) # Only qualities
|
||||
else: sorted_list.sort(key=lambda row: (row['index_language'], row['index_quality']))
|
||||
if priority == 0: sorted_list.sort(key=lambda element: (element['index_language'], -element['index_quality'] if inverted else element['index_quality'] , element['videoitem'].server))
|
||||
elif priority == 1: sorted_list.sort(key=lambda element: (element['index_language'], element['index_server'], -element['index_quality'] if inverted else element['index_quality'])) # Servers and Qualities
|
||||
elif priority == 2: sorted_list.sort(key=lambda element: (element['index_language'], -element['index_quality'] if inverted else element['index_quality'], element['index_server'])) # Qualities and Servers
|
||||
|
||||
return [v['videoitem'] for v in sorted_list if v]
|
||||
|
||||
|
||||
@@ -1564,10 +1564,12 @@ class Tmdb(object):
|
||||
:rtype: list of Dict
|
||||
"""
|
||||
ret = []
|
||||
|
||||
if self.result['id']:
|
||||
if self.result['videos']:
|
||||
self.result["videos"] = self.result["videos"]['results']
|
||||
else:
|
||||
self.result["videos"] = []
|
||||
# First video search in the search language
|
||||
url = "{}/{}/{}/videos?api_key={}&language={}".format(host, self.search_type, self.result['id'], api, self.search_language)
|
||||
|
||||
|
||||
@@ -1057,23 +1057,23 @@ def get_seleccion(default_action, opciones, seleccion, video_urls):
|
||||
|
||||
|
||||
def calcResolution(option):
|
||||
match = scrapertools.find_single_match(option, '([0-9]{2,4})x([0-9]{2,4})')
|
||||
resolution = False
|
||||
match = scrapertools.find_single_match(option, '([0-9]{2,4})(?:p|i|x[0-9]{2,4}|)')
|
||||
resolution = 0
|
||||
|
||||
if match:
|
||||
resolution = int(match[0]) * int(match[1])
|
||||
else:
|
||||
if '240p' in option:
|
||||
resolution = 320 * 240
|
||||
elif '360p' in option:
|
||||
resolution = 480 * 360
|
||||
elif ('480p' in option) or ('480i' in option):
|
||||
resolution = 720 * 480
|
||||
elif ('576p' in option) or ('576p' in option):
|
||||
resolution = 720 * 576
|
||||
elif ('720p' in option) or ('HD' in option):
|
||||
resolution = 1280 * 720
|
||||
elif ('1080p' in option) or ('1080i' in option) or ('Full HD' in option):
|
||||
resolution = 1920 * 1080
|
||||
resolution = int(match)
|
||||
elif 'sd' in option.lower():
|
||||
resolution = 480
|
||||
elif 'hd' in option.lower():
|
||||
resolution = 720
|
||||
if 'full' in option.lower():
|
||||
resolution = 1080
|
||||
elif '2k' in option.lower():
|
||||
resolution = 1440
|
||||
elif '4k' in option.lower():
|
||||
resolution = 2160
|
||||
elif 'auto' in option.lower():
|
||||
resolution = 10000
|
||||
|
||||
return resolution
|
||||
|
||||
|
||||
Reference in New Issue
Block a user