KoD 1.6.1

-Migliorata l'efficacia del riconoscimento dei contenuti in ricerca film/serie
- corretti alcuni bug e fatti alcuni fix per i soliti cambi di struttura
This commit is contained in:
mac12m99
2021-03-09 22:08:09 +01:00
parent f1da5c7a0b
commit fa0fe6e534
29 changed files with 377 additions and 330 deletions

View File

@@ -191,20 +191,20 @@ class autorenumber():
seasons =[]
groupedSeasons = tmdb.get_group(self.group.replace('\n','').split('/')[-1])
for groupedSeason in groupedSeasons:
seasons.append({'season_number':groupedSeason['order'], 'episode_count':len(groupedSeason['episodes'])})
seasons.append({'season_number':groupedSeason['order'], 'episode_count':len(groupedSeason['episodes']), 'start_from':groupedSeason['episodes'][0]['episode_number']})
else:
seasons = tmdb.Tmdb(id_Tmdb=self.id).get_list_episodes()
count = 0
for season in seasons:
s = season['season_number']
c = season['episode_count']
fe = season['start_from']
self.seasonsdict[str(s)] = c
if s > 0:
for e in range(1, c + 1):
count += 1
self.epdict[count] = '{}x{:02d}'.format(s,e)
self.epdict[count] = '{}x{:02d}'.format(s, e + fe - 1)
if self.item.renumber or self.manual:
self.item.renumber = False

View File

@@ -170,13 +170,13 @@ def enable_disable_autorun(is_enabled):
set_setting('autostart', True)
return True
def get_all_settings_addon():
# Read the settings.xml file and return a dictionary with {id: value}
from core import scrapertools
infile = open(os.path.join(get_data_path(), "settings.xml"), "r")
data = infile.read()
infile.close()
with open(os.path.join(get_data_path(), "settings.xml"), "rb") as infile:
data = infile.read().decode('utf-8')
ret = {}
matches = scrapertools.find_multiple_matches(data, '<setting id=\"([^\"]+)\"[^>]*>([^<]*)</setting>')

View File

@@ -134,8 +134,8 @@ def run(item=None):
elif item.action == "script":
from core import tmdb
if tmdb.drop_bd():
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False)
tmdb.clean_cache()
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False)
elif item.action == "itemInfo":
platformtools.dialog_textviewer('Item info', item.parent)
elif item.action == "open_browser":
@@ -332,7 +332,7 @@ def run(item=None):
platformtools.dialog_ok(config.get_localized_string(60087) % Channel, config.get_localized_string(60014))
else:
if platformtools.dialog_yesno(config.get_localized_string(60038), config.get_localized_string(60015)):
run(Item(channel="setting", action="report_menu"))
platformtools.itemlist_update(Item(channel="setting", action="report_menu"), True)
finally:
# db need to be closed when not used, it will cause freezes
from core import db

View File

@@ -239,9 +239,14 @@ def dialog_select_group(heading, _list, preselect=0):
def onInit(self):
self.getControl(1).setText(self.heading)
itemlist = []
for n, text in enumerate(self.list):
for n, it in enumerate(self.list):
logger.debug(it)
item = xbmcgui.ListItem(str(n))
item.setProperty('title', text)
item.setProperty('title', it[0])
item.setProperty('seasons', str(it[1]))
item.setProperty('episodes', str(it[2]))
item.setProperty('description', '\n' + it[3])
item.setProperty('thumb', it[4])
itemlist.append(item)
self.getControl(2).addItems(itemlist)
@@ -441,13 +446,13 @@ def set_view_mode(item, parent_item):
def set_infolabels(listitem, item, player=False):
"""
Method to pass the information to the listitem (see tmdb.set_InfoLabels())
    item.infoLabels is a dictionary with the key / value pairs described in:
    http://mirrors.xbmc.org/docs/python-docs/14.x-helix/xbmcgui.html#ListItem-setInfo
    https://kodi.wiki/view/InfoLabels
    @param listitem: xbmcgui.ListItem object
    @type listitem: xbmcgui.ListItem
    @param item: Item object that represents a movie, series or chapter
    @type item: item
item.infoLabels is a dictionary with the key / value pairs described in:
http://mirrors.xbmc.org/docs/python-docs/14.x-helix/xbmcgui.html#ListItem-setInfo
https://kodi.wiki/view/InfoLabels
@param listitem: xbmcgui.ListItem object
@type listitem: xbmcgui.ListItem
@param item: Item object that represents a movie, series or chapter
@type item: item
"""
infoLabels_dict = {'aired': 'aired', 'album': 'album', 'artist': 'artist', 'cast': 'cast',
@@ -482,31 +487,30 @@ def set_infolabels(listitem, item, player=False):
def set_context_commands(item, item_url, parent_item, **kwargs):
"""
Function to generate context menus.
        1. Based on the data in item.context
            a. Old method item.context type str separating options by "|" (example: item.context = "1 | 2 | 3")
                (only predefined)
            b. List method: item.context is a list with the different menu options:
                - Predefined: A predefined option will be loaded with a name.
                    item.context = ["1", "2", "3"]
1. Based on the data in item.context
a. Old method item.context type str separating options by "|" (example: item.context = "1 | 2 | 3")
(only predefined)
b. List method: item.context is a list with the different menu options:
- Predefined: A predefined option will be loaded with a name.
item.context = ["1", "2", "3"]
                - dict (): The current item will be loaded modifying the fields included in the dict () in case of
                    modify the channel and action fields these will be saved in from_channel and from_action.
                    item.context = [{"title": "Name of the menu", "action": "action of the menu", "channel": "menu channel"}, {...}]
- dict (): The current item will be loaded modifying the fields included in the dict () in case of
modify the channel and action fields these will be saved in from_channel and from_action.
item.context = [{"title": "Name of the menu", "action": "action of the menu", "channel": "menu channel"}, {...}]
        2. Adding options according to criteria
            Options can be added to the context menu to items that meet certain conditions.
2. Adding options according to criteria
Options can be added to the context menu to items that meet certain conditions.
3. Adding options to all items
Options can be added to the context menu for all items
        3. Adding options to all items
            Options can be added to the context menu for all items
4. You can disable the context menu options by adding a command 'no_context' to the item.context.
The options that Kodi, the skin or another added add to the contextual menu cannot be disabled.
        4. You can disable the context menu options by adding a command 'no_context' to the item.context.
            The options that Kodi, the skin or another added add to the contextual menu cannot be disabled.
    @param item: element that contains the contextual menus
    @type item: item
    @param parent_item:
    @type parent_item: item
@param item: element that contains the contextual menus
@type item: item
@param parent_item:
@type parent_item: item
"""
context_commands = []
# num_version_xbmc = config.get_platform(True)['num_version']
@@ -821,9 +825,9 @@ def show_channel_settings(**kwargs):
def show_video_info(*args, **kwargs):
"""
It shows a window with the info of the video.
    The parameters passed to it can be seen in the method that is called
The parameters passed to it can be seen in the method that is called
    @return: returns the window with the elements
@return: returns the window with the elements
@rtype: InfoWindow
"""
@@ -1420,6 +1424,7 @@ def get_played_time(item):
logger.debug()
from core import db
played_time = 0
if not item.infoLabels:
return 0
ID = item.infoLabels.get('tmdb_id', '')
@@ -1430,13 +1435,18 @@ def get_played_time(item):
E = item.infoLabels.get('episode')
result = None
if item.contentType == 'movie':
result = db['viewed'].get(ID)
elif S and E:
result = db['viewed'].get(ID, {}).get(str(S)+'x'+str(E))
try:
if item.contentType == 'movie':
result = db['viewed'].get(ID)
elif S and E:
result = db['viewed'].get(ID, {}).get(str(S)+'x'+str(E))
if not result: played_time = 0
else: played_time = result
if result:
played_time = result
except:
import traceback
logger.error(traceback.format_exc())
del db['viewed'][ID]
return played_time
@@ -1456,13 +1466,17 @@ def set_played_time(item):
S = item.infoLabels.get('season', 0)
E = item.infoLabels.get('episode')
if item.contentType == 'movie':
db['viewed'][ID] = played_time
elif E:
newDict = db['viewed'].get(ID, {})
newDict[str(S) + 'x' + str(E)] = played_time
db['viewed'][ID] = newDict
try:
if item.contentType == 'movie':
db['viewed'][ID] = played_time
elif E:
newDict = db['viewed'].get(ID, {})
newDict[str(S) + 'x' + str(E)] = played_time
db['viewed'][ID] = newDict
except:
import traceback
logger.error(traceback.format_exc())
del db['viewed'][ID]
def prevent_busy(item):

View File

@@ -132,7 +132,7 @@ def SettingOnPosition(item):
def select(item):
from core.support import dbg;dbg()
# from core.support import dbg;dbg()
from platformcode import config, platformtools
# item.id = setting ID
# item.type = labels or values

View File

@@ -104,7 +104,7 @@ def check(background=False):
patch_url = commitJson['html_url'] + '.patch'
logger.info('applicando ' + patch_url)
from lib import patch
patch.fromurl(patch_url).apply(root=addonDir)
patchOk = patch.fromurl(patch_url).apply(root=addonDir)
for file in commitJson['files']:
if file["filename"] == trackingFile: # il file di tracking non si modifica
@@ -115,7 +115,7 @@ def check(background=False):
poFilesChanged = True
if 'service.py' in file["filename"]:
serviceChanged = True
if (file['status'] == 'modified' and 'patch' not in file) or file['status'] == 'added':
if (file['status'] == 'modified' and 'patch' not in file) or file['status'] == 'added' or (file['status'] == 'modified' and not patchOk):
# è un file NON testuale che è stato modificato, oppure è un file nuovo (la libreria non supporta la creazione di un nuovo file)
# lo devo scaricare
filename = os.path.join(addonDir, file['filename'])