Contextmenu (#307)
* contextmenu in Kod Options * remove single quote for menu * fix reviews changes * merge commit from alpha * check if item is already managed by kod * added episode and season as dbtype for showing menu * move context into platform * refactor get_menu_items() Co-authored-by: mac12m99 <10120390+mac12m99@users.noreply.github.com>
This commit is contained in:
@@ -16,10 +16,10 @@
|
|||||||
<label>70269</label>
|
<label>70269</label>
|
||||||
<visible>String.IsEqual(ListItem.dbtype,tvshow)</visible>
|
<visible>String.IsEqual(ListItem.dbtype,tvshow)</visible>
|
||||||
</item>
|
</item>
|
||||||
<!-- <item library="externalsearch.py">-->
|
<item library="contextmenu.py">
|
||||||
<!-- <label>90001</label>-->
|
<label>90001</label>
|
||||||
<!-- <visible>!String.StartsWith(ListItem.FileNameAndPath, plugin://plugin.video.kod/) + [String.IsEqual(ListItem.dbtype,tvshow) | String.IsEqual(ListItem.dbtype,movie)]</visible>-->
|
<visible>!String.StartsWith(ListItem.FileNameAndPath, plugin://plugin.video.kod/) + [ String.IsEqual(ListItem.dbtype, tvshow) | String.IsEqual(ListItem.dbtype, movie) | String.IsEqual(ListItem.dbtype, season) | String.IsEqual(ListItem.dbtype, episode) ]</visible>
|
||||||
<!-- </item>-->
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
</extension>
|
</extension>
|
||||||
<extension point="xbmc.addon.metadata">
|
<extension point="xbmc.addon.metadata">
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import os
|
||||||
|
from platformcode import config, logger
|
||||||
|
import xbmc, sys, xbmcgui, os
|
||||||
|
|
||||||
|
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
|
||||||
|
sys.path.insert(0, librerias)
|
||||||
|
|
||||||
|
from core import jsontools, support
|
||||||
|
|
||||||
|
addon_id = config.get_addon_core().getAddonInfo('id')
|
||||||
|
|
||||||
|
LOCAL_FILE = os.path.join(config.get_runtime_path(), "platformcode/contextmenu/contextmenu.json")
|
||||||
|
f = open(LOCAL_FILE)
|
||||||
|
try:
|
||||||
|
contextmenu_settings = jsontools.load( f.read() )
|
||||||
|
except:
|
||||||
|
contextmenu_settings = []
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def build_menu():
|
||||||
|
|
||||||
|
tmdbid = xbmc.getInfoLabel('ListItem.Property(tmdb_id)')
|
||||||
|
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||||
|
title = xbmc.getInfoLabel('ListItem.Title')
|
||||||
|
year = xbmc.getInfoLabel('ListItem.Year')
|
||||||
|
imdb = xbmc.getInfoLabel('ListItem.IMDBNumber')
|
||||||
|
filePath = xbmc.getInfoLabel('ListItem.FileNameAndPath')
|
||||||
|
containerPath = xbmc.getInfoLabel('Container.FolderPath')
|
||||||
|
|
||||||
|
logstr = "Selected ListItem is: 'IMDB: {}' - TMDB: {}' - 'Title: {}' - 'Year: {}'' - 'Type: {}'".format(imdb, tmdbid, title, year, mediatype)
|
||||||
|
logger.info(logstr)
|
||||||
|
logger.info(filePath)
|
||||||
|
logger.info(containerPath)
|
||||||
|
|
||||||
|
contextmenumodules = []
|
||||||
|
contextmenu = []
|
||||||
|
|
||||||
|
for itemmodule in contextmenu_settings:
|
||||||
|
logger.debug('check contextmenu', itemmodule )
|
||||||
|
module = __import__(itemmodule, None, None, [ itemmodule] )
|
||||||
|
|
||||||
|
# if module.check_condition():
|
||||||
|
logger.info('Add contextmenu item ->',itemmodule )
|
||||||
|
contextmenumodules.append( module )
|
||||||
|
|
||||||
|
|
||||||
|
contextmenuitems = []
|
||||||
|
contextmenuactions = []
|
||||||
|
empty = False
|
||||||
|
if len(contextmenumodules) == 0:
|
||||||
|
logger.info('No contextmodule found, build an empty one')
|
||||||
|
contextmenucontextmenuitems.append( empty_item() )
|
||||||
|
empty = True
|
||||||
|
else:
|
||||||
|
support.dbg()
|
||||||
|
for itemmodule in contextmenumodules:
|
||||||
|
module_item_actions = itemmodule.get_menu_items()
|
||||||
|
contextmenuitems = contextmenuitems + [item for item, fn in module_item_actions ]
|
||||||
|
contextmenuactions = contextmenuactions + [fn for item, fn in module_item_actions ]
|
||||||
|
|
||||||
|
ret = xbmcgui.Dialog().contextmenu( contextmenuitems )
|
||||||
|
|
||||||
|
if not empty and ret > -1:
|
||||||
|
module_function = contextmenuactions[ ret ]
|
||||||
|
logger.info( 'Contextmenu module index', ret, 'for -> {}', itemmodule )
|
||||||
|
if module_function:
|
||||||
|
module_function()
|
||||||
|
else:
|
||||||
|
logger.warn('No function for menu item: {}'.format(contextmenuitems[ret]) )
|
||||||
|
|
||||||
|
|
||||||
|
def empty_item():
|
||||||
|
return config.get_localized_string(90004)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
build_menu()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[
|
||||||
|
"platformcode.contextmenu.search_on_kod",
|
||||||
|
"platformcode.contextmenu.search_on_channels",
|
||||||
|
"platformcode.contextmenu.update_tv_show"
|
||||||
|
]
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import xbmc, sys, os
|
||||||
|
from platformcode import config, logger
|
||||||
|
import re
|
||||||
|
# incliuding folder libraries
|
||||||
|
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
|
||||||
|
sys.path.insert(0, librerias)
|
||||||
|
|
||||||
|
|
||||||
|
from core import tmdb
|
||||||
|
from core.item import Item
|
||||||
|
|
||||||
|
addon_id = config.get_addon_core().getAddonInfo('id')
|
||||||
|
|
||||||
|
|
||||||
|
def check_condition():
|
||||||
|
logger.debug('check item condition')
|
||||||
|
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||||
|
|
||||||
|
folderPath = xbmc.getInfoLabel('Container.FolderPath')
|
||||||
|
filePath = xbmc.getInfoLabel('ListItem.Path')
|
||||||
|
fileNameAndPath = xbmc.getInfoLabel('ListItem.FileNameAndPath')
|
||||||
|
|
||||||
|
logger.debug('Container:',folderPath )
|
||||||
|
logger.debug('listitem mediatype:',mediatype )
|
||||||
|
logger.debug('filenamepath:', fileNameAndPath )
|
||||||
|
logger.info('filepath:', filePath )
|
||||||
|
|
||||||
|
item_is_coming_from_kod = addon_id in filePath
|
||||||
|
if not item_is_coming_from_kod:
|
||||||
|
videolibpath = config.get_setting("videolibrarypath")
|
||||||
|
if filePath.startswith(videolibpath):
|
||||||
|
pattern = re.compile("\[.*\][\\\/]?$")
|
||||||
|
item_is_coming_from_kod = pattern.search(filePath)
|
||||||
|
|
||||||
|
if item_is_coming_from_kod:
|
||||||
|
logger.debug("item IS already managed by KOD", item_is_coming_from_kod)
|
||||||
|
|
||||||
|
# logger.info('container is KOD? {}'.format(we_are_in_kod) )
|
||||||
|
|
||||||
|
return mediatype and item_is_coming_from_kod # and not we_are_in_kod
|
||||||
|
|
||||||
|
|
||||||
|
def get_menu_items():
|
||||||
|
logger.debug('get menu item')
|
||||||
|
if check_condition():
|
||||||
|
return config.get_localized_string(90003) , execute
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
"""
|
||||||
|
Gather the selected ListItem's attributes in order to compute the `Item` parameters
|
||||||
|
and perform the KOD's globalsearch.
|
||||||
|
Globalsearch will be executed specifing the content-type of the selected ListItem
|
||||||
|
|
||||||
|
NOTE: this method needs the DBTYPE and TMDB_ID specified as ListItem's properties
|
||||||
|
"""
|
||||||
|
|
||||||
|
# These following lines are commented and keep in the code just as reminder.
|
||||||
|
# In future, they could be used to filter the search outcome
|
||||||
|
|
||||||
|
# ADDON: maybe can we know if the current windows is related to a specific addon?
|
||||||
|
# we could skip the ContextMenu if we already are in KOD's window
|
||||||
|
|
||||||
|
tmdbid = xbmc.getInfoLabel('ListItem.Property(tmdb_id)')
|
||||||
|
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||||
|
title = xbmc.getInfoLabel('ListItem.Title')
|
||||||
|
year = xbmc.getInfoLabel('ListItem.Year')
|
||||||
|
imdb = xbmc.getInfoLabel('ListItem.IMDBNumber')
|
||||||
|
|
||||||
|
logstr = "Selected ListItem is: 'IMDB: {}' - TMDB: {}' - 'Title: {}' - 'Year: {}'' - 'Type: {}'".format(imdb, tmdbid, title, year, mediatype)
|
||||||
|
logger.info(logstr)
|
||||||
|
|
||||||
|
if not tmdbid and imdb:
|
||||||
|
logger.info('No TMDBid found. Try to get by IMDB')
|
||||||
|
it = Item(contentType= mediatype, infoLabels={'imdb_id' : imdb})
|
||||||
|
try:
|
||||||
|
tmdb.set_infoLabels(it)
|
||||||
|
tmdbid = it.infoLabels.get('tmdb_id', '')
|
||||||
|
except:
|
||||||
|
logger.info("Cannot find TMDB via imdb")
|
||||||
|
|
||||||
|
if not tmdbid:
|
||||||
|
logger.info('No TMDBid found. Try to get by Title/Year')
|
||||||
|
it = Item(contentTitle= title, contentType= mediatype, infoLabels={'year' : year})
|
||||||
|
try:
|
||||||
|
tmdb.set_infoLabels(it)
|
||||||
|
tmdbid = it.infoLabels.get('tmdb_id', '')
|
||||||
|
except:
|
||||||
|
logger.info("Cannot find TMDB via title/year")
|
||||||
|
|
||||||
|
|
||||||
|
if not tmdbid:
|
||||||
|
# We can continue searching by 'title (year)'
|
||||||
|
logger.info( "No TMDB found, proceed with title/year:", title , "(" , year, ")" )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# User wants to search on other channels
|
||||||
|
logger.info("Search on other channels")
|
||||||
|
|
||||||
|
item = Item(
|
||||||
|
action="from_context",
|
||||||
|
channel="search",
|
||||||
|
contentType= mediatype,
|
||||||
|
mode="search",
|
||||||
|
contextual= True,
|
||||||
|
text= title,
|
||||||
|
type= mediatype,
|
||||||
|
infoLabels= {
|
||||||
|
'tmdb_id': tmdbid,
|
||||||
|
'year': year,
|
||||||
|
'mediatype': mediatype
|
||||||
|
},
|
||||||
|
folder= False
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info("Invoking Item: ", item.tostring() )
|
||||||
|
|
||||||
|
itemurl = item.tourl()
|
||||||
|
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + itemurl + ")")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import xbmc, sys, xbmcgui, os
|
||||||
|
from platformcode import config, logger
|
||||||
|
|
||||||
|
# incliuding folder libraries
|
||||||
|
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
|
||||||
|
sys.path.insert(0, librerias)
|
||||||
|
import re
|
||||||
|
|
||||||
|
from core import tmdb
|
||||||
|
from core.item import Item
|
||||||
|
|
||||||
|
addon_id = config.get_addon_core().getAddonInfo('id')
|
||||||
|
|
||||||
|
|
||||||
|
def check_condition():
|
||||||
|
logger.debug('[SOK] check item condition')
|
||||||
|
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||||
|
|
||||||
|
folderPath = xbmc.getInfoLabel('Container.FolderPath')
|
||||||
|
filePath = xbmc.getInfoLabel('ListItem.Path')
|
||||||
|
fileNameAndPath = xbmc.getInfoLabel('ListItem.FileNameAndPath')
|
||||||
|
|
||||||
|
logger.debug('Container:',folderPath )
|
||||||
|
logger.debug('listitem mediatype:',mediatype )
|
||||||
|
logger.debug('filenamepath:', fileNameAndPath )
|
||||||
|
logger.info('filepath:', filePath )
|
||||||
|
|
||||||
|
item_is_coming_from_kod = addon_id in filePath
|
||||||
|
if not item_is_coming_from_kod:
|
||||||
|
videolibpath = config.get_setting("videolibrarypath")
|
||||||
|
if filePath.startswith(videolibpath):
|
||||||
|
pattern = re.compile("\[.*\][\\\/]?$")
|
||||||
|
item_is_coming_from_kod = pattern.search(filePath)
|
||||||
|
|
||||||
|
if item_is_coming_from_kod:
|
||||||
|
logger.debug("item IS already managed by KOD", item_is_coming_from_kod)
|
||||||
|
|
||||||
|
# logger.info('[SOK] container is KOD? {}'.format(we_are_in_kod) )
|
||||||
|
|
||||||
|
return mediatype and not item_is_coming_from_kod # and not we_are_in_kod
|
||||||
|
|
||||||
|
def get_menu_items():
|
||||||
|
logger.debug('get menu item')
|
||||||
|
if check_condition():
|
||||||
|
return config.get_localized_string(90005) , execute
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
"""
|
||||||
|
Gather the selected ListItem's attributes in order to compute the `Item` parameters
|
||||||
|
and perform the KOD's globalsearch.
|
||||||
|
Globalsearch will be executed specifing the content-type of the selected ListItem
|
||||||
|
|
||||||
|
NOTE: this method needs the DBTYPE and TMDB_ID specified as ListItem's properties
|
||||||
|
"""
|
||||||
|
|
||||||
|
# These following lines are commented and keep in the code just as reminder.
|
||||||
|
# In future, they could be used to filter the search outcome
|
||||||
|
|
||||||
|
# ADDON: maybe can we know if the current windows is related to a specific addon?
|
||||||
|
# we could skip the ContextMenu if we already are in KOD's window
|
||||||
|
|
||||||
|
tmdbid = xbmc.getInfoLabel('ListItem.Property(tmdb_id)')
|
||||||
|
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
|
||||||
|
title = xbmc.getInfoLabel('ListItem.Title')
|
||||||
|
year = xbmc.getInfoLabel('ListItem.Year')
|
||||||
|
imdb = xbmc.getInfoLabel('ListItem.IMDBNumber')
|
||||||
|
|
||||||
|
logstr = "Selected ListItem is: 'IMDB: {}' - TMDB: {}' - 'Title: {}' - 'Year: {}'' - 'Type: {}'".format(imdb, tmdbid, title, year, mediatype)
|
||||||
|
logger.info(logstr)
|
||||||
|
|
||||||
|
if not tmdbid and imdb:
|
||||||
|
logger.info('No TMDBid found. Try to get by IMDB')
|
||||||
|
it = Item(contentType= mediatype, infoLabels={'imdb_id' : imdb})
|
||||||
|
try:
|
||||||
|
tmdb.set_infoLabels(it)
|
||||||
|
tmdbid = it.infoLabels.get('tmdb_id', '')
|
||||||
|
except:
|
||||||
|
logger.info("Cannot find TMDB via imdb")
|
||||||
|
|
||||||
|
if not tmdbid:
|
||||||
|
logger.info('No TMDBid found. Try to get by Title/Year')
|
||||||
|
it = Item(contentTitle= title, contentType= mediatype, infoLabels={'year' : year})
|
||||||
|
try:
|
||||||
|
tmdb.set_infoLabels(it)
|
||||||
|
tmdbid = it.infoLabels.get('tmdb_id', '')
|
||||||
|
except:
|
||||||
|
logger.info("Cannot find TMDB via title/year")
|
||||||
|
|
||||||
|
|
||||||
|
if not tmdbid:
|
||||||
|
# We can continue searching by 'title (year)'
|
||||||
|
logger.info( "No TMDB found, proceed with title/year:", title , "(" , year, ")" )
|
||||||
|
|
||||||
|
|
||||||
|
logger.info("Search on KOD (gobalsearch)")
|
||||||
|
|
||||||
|
item = Item(
|
||||||
|
action="Search",
|
||||||
|
channel="globalsearch",
|
||||||
|
contentType= mediatype,
|
||||||
|
mode="search",
|
||||||
|
text= title,
|
||||||
|
type= mediatype,
|
||||||
|
infoLabels= {
|
||||||
|
'tmdb_id': tmdbid,
|
||||||
|
'year': year
|
||||||
|
},
|
||||||
|
folder= False
|
||||||
|
)
|
||||||
|
|
||||||
|
logger.info("Invoking Item:", item.tostring() )
|
||||||
|
|
||||||
|
itemurl = item.tourl()
|
||||||
|
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + itemurl + ")")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import xbmc, sys, xbmcgui, os, xbmcvfs, traceback
|
||||||
|
from platformcode import config, logger
|
||||||
|
|
||||||
|
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
|
||||||
|
sys.path.insert(0, librerias)
|
||||||
|
|
||||||
|
from core.item import Item
|
||||||
|
from lib.sambatools import libsmb as samba
|
||||||
|
from core import scrapertools, support
|
||||||
|
|
||||||
|
|
||||||
|
def exists(path, silent=False, vfs=True):
|
||||||
|
path = xbmc.translatePath(path)
|
||||||
|
try:
|
||||||
|
if vfs:
|
||||||
|
result = bool(xbmcvfs.exists(path))
|
||||||
|
if not result and not path.endswith('/') and not path.endswith('\\'):
|
||||||
|
result = bool(xbmcvfs.exists(join(path, ' ').rstrip()))
|
||||||
|
return result
|
||||||
|
elif path.lower().startswith("smb://"):
|
||||||
|
return samba.exists(path)
|
||||||
|
else:
|
||||||
|
return os.path.exists(path)
|
||||||
|
except:
|
||||||
|
logger.error("ERROR when checking the path: %s" % path)
|
||||||
|
if not silent:
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def join(*paths):
|
||||||
|
list_path = []
|
||||||
|
if paths[0].startswith("/"):
|
||||||
|
list_path.append("")
|
||||||
|
for path in paths:
|
||||||
|
if path:
|
||||||
|
list_path += path.replace("\\", "/").strip("/").split("/")
|
||||||
|
|
||||||
|
if scrapertools.find_single_match(paths[0], r'(^\w+:\/\/)'):
|
||||||
|
return str("/".join(list_path))
|
||||||
|
else:
|
||||||
|
return str(os.sep.join(list_path))
|
||||||
|
|
||||||
|
|
||||||
|
def search_paths(Id):
|
||||||
|
records = execute_sql('SELECT idPath FROM tvshowlinkpath WHERE idShow LIKE "%s"' % Id)
|
||||||
|
if len(records) >= 1:
|
||||||
|
for record in records:
|
||||||
|
path_records = execute_sql('SELECT strPath FROM path WHERE idPath LIKE "%s"' % record[0])
|
||||||
|
for path in path_records:
|
||||||
|
if config.get_setting('videolibrarypath') in path[0] and exists(join(path[0], 'tvshow.nfo')):
|
||||||
|
return path[0]
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
def execute_sql(sql):
|
||||||
|
logger.debug()
|
||||||
|
file_db = ""
|
||||||
|
records = None
|
||||||
|
|
||||||
|
# We look for the archive of the video database according to the version of kodi
|
||||||
|
video_db = config.get_platform(True)['video_db']
|
||||||
|
if video_db:
|
||||||
|
file_db = os.path.join(xbmc.translatePath("special://userdata/Database"), video_db)
|
||||||
|
|
||||||
|
# alternative method to locate the database
|
||||||
|
if not file_db or not os.path.exists(file_db):
|
||||||
|
file_db = ""
|
||||||
|
for f in os.path.listdir(xbmc.translatePath("special://userdata/Database")):
|
||||||
|
path_f = os.path.join(xbmc.translatePath("special://userdata/Database"), f)
|
||||||
|
|
||||||
|
if os.path.pathoos.pathols.isfile(path_f) and f.lower().startswith('myvideos') and f.lower().endswith('.db'):
|
||||||
|
file_db = path_f
|
||||||
|
break
|
||||||
|
|
||||||
|
if file_db:
|
||||||
|
logger.debug("DB file: %s" % file_db)
|
||||||
|
conn = None
|
||||||
|
try:
|
||||||
|
import sqlite3
|
||||||
|
conn = sqlite3.connect(file_db)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
logger.debug("Running sql: %s" % sql)
|
||||||
|
cursor.execute(sql)
|
||||||
|
conn.commit()
|
||||||
|
|
||||||
|
records = cursor.fetchall()
|
||||||
|
if sql.lower().startswith("select"):
|
||||||
|
if len(records) == 1 and records[0][0] is None:
|
||||||
|
records = []
|
||||||
|
|
||||||
|
conn.close()
|
||||||
|
logger.debug("Query executed. Records: %s" % len(records))
|
||||||
|
|
||||||
|
except:
|
||||||
|
logger.error("Error executing sql query")
|
||||||
|
if conn:
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
else:
|
||||||
|
logger.debug("Database not found")
|
||||||
|
|
||||||
|
return records
|
||||||
|
|
||||||
|
|
||||||
|
def check_condition():
|
||||||
|
# support.dbg()
|
||||||
|
dbid = xbmc.getInfoLabel('ListItem.DBID')
|
||||||
|
path = search_paths( dbid )
|
||||||
|
if path:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def get_menu_items():
|
||||||
|
logger.debug('get menu item')
|
||||||
|
if check_condition():
|
||||||
|
return config.get_localized_string(70269) , execute
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
dbid = xbmc.getInfoLabel('ListItem.DBID')
|
||||||
|
path = search_paths( dbid )
|
||||||
|
if path:
|
||||||
|
item = Item(action="update_tvshow", channel="videolibrary", path=path)
|
||||||
|
# Why? I think it is not necessary, just commented
|
||||||
|
# item.tourl()
|
||||||
|
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")")
|
||||||
@@ -322,13 +322,6 @@ def render_items(itemlist, parent_item):
|
|||||||
default_fanart = config.get_fanart()
|
default_fanart = config.get_fanart()
|
||||||
def_context_commands = shortcuts.context()
|
def_context_commands = shortcuts.context()
|
||||||
|
|
||||||
# for adding extendedinfo to contextual menu, if it's used
|
|
||||||
has_extendedinfo = xbmc.getCondVisibility('System.HasAddon(script.extendedinfo)')
|
|
||||||
# for adding superfavourites to contextual menu, if it's used
|
|
||||||
sf_file_path = xbmc.translatePath("special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py")
|
|
||||||
check_sf = os.path.exists(sf_file_path)
|
|
||||||
superfavourites = check_sf and xbmc.getCondVisibility('System.HasAddon("plugin.program.super.favourites")')
|
|
||||||
|
|
||||||
# if there's no item, add "no elements" item
|
# if there's no item, add "no elements" item
|
||||||
if not len(itemlist):
|
if not len(itemlist):
|
||||||
itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
|
itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
|
||||||
@@ -343,8 +336,11 @@ def render_items(itemlist, parent_item):
|
|||||||
if not item.title:
|
if not item.title:
|
||||||
item.title = ''
|
item.title = ''
|
||||||
# If there is no action or it is findvideos / play, folder = False because no listing will be returned
|
# If there is no action or it is findvideos / play, folder = False because no listing will be returned
|
||||||
|
if item.folder == "": # not set
|
||||||
if item.action in ['play', '']:
|
if item.action in ['play', '']:
|
||||||
item.folder = False
|
item.folder = False
|
||||||
|
else:
|
||||||
|
item.folder = True
|
||||||
if item.fanart == "":
|
if item.fanart == "":
|
||||||
item.fanart = parent_item.fanart
|
item.fanart = parent_item.fanart
|
||||||
if item.action == 'play' and thumb_type == 1 and not item.forcethumb:
|
if item.action == 'play' and thumb_type == 1 and not item.forcethumb:
|
||||||
@@ -365,14 +361,13 @@ def render_items(itemlist, parent_item):
|
|||||||
listitem.setArt({'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail,
|
listitem.setArt({'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail,
|
||||||
'fanart': item.fanart if item.fanart else default_fanart})
|
'fanart': item.fanart if item.fanart else default_fanart})
|
||||||
|
|
||||||
if config.get_setting("player_mode") == 1 and item.action == "play" and not item.nfo:
|
listitem.setProperty('IsPlayable', str(config.get_setting("player_mode") == 1 and item.action == "play" and not item.nfo).lower())
|
||||||
listitem.setProperty('IsPlayable', 'true')
|
|
||||||
|
|
||||||
set_infolabels(listitem, item)
|
set_infolabels(listitem, item)
|
||||||
|
|
||||||
# context menu
|
# context menu
|
||||||
if parent_item.channel != 'special':
|
if parent_item.channel != 'special':
|
||||||
context_commands = def_context_commands + set_context_commands(item, item_url, parent_item, has_extendedinfo=has_extendedinfo, superfavourites=superfavourites)
|
context_commands = def_context_commands + set_context_commands(item, item_url, parent_item)
|
||||||
else:
|
else:
|
||||||
context_commands = def_context_commands
|
context_commands = def_context_commands
|
||||||
listitem.addContextMenuItems(context_commands)
|
listitem.addContextMenuItems(context_commands)
|
||||||
@@ -594,25 +589,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
|||||||
# if item.infoLabels['plot'] and (num_version_xbmc < 17.0 or item.contentType == 'season'):
|
# if item.infoLabels['plot'] and (num_version_xbmc < 17.0 or item.contentType == 'season'):
|
||||||
# context_commands.append((config.get_localized_string(60348), "Action(Info)"))
|
# context_commands.append((config.get_localized_string(60348), "Action(Info)"))
|
||||||
|
|
||||||
# ExtendedInfo: If the addon is installed and a series of conditions are met
|
|
||||||
if kwargs.get('has_extendedinfo') \
|
|
||||||
and config.get_setting("extended_info") == True:
|
|
||||||
if item.contentType == "episode" and item.contentEpisodeNumber and item.contentSeason and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
|
||||||
param = "tvshow_id =%s, tvshow=%s, season=%s, episode=%s" % (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason, item.contentEpisodeNumber)
|
|
||||||
context_commands.append(("ExtendedInfo", "RunScript(script.extendedinfo,info=extendedepisodeinfo,%s)" % param))
|
|
||||||
|
|
||||||
elif item.contentType == "season" and item.contentSeason and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
|
||||||
param = "tvshow_id =%s,tvshow=%s, season=%s" % (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason)
|
|
||||||
context_commands.append(("ExtendedInfo", "RunScript(script.extendedinfo,info=seasoninfo,%s)" % param))
|
|
||||||
|
|
||||||
elif item.contentType == "tvshow" and (item.infoLabels['tmdb_id'] or item.infoLabels['tvdb_id'] or item.infoLabels['imdb_id'] or item.contentSerieName):
|
|
||||||
param = "id =%s,tvdb_id=%s,imdb_id=%s,name=%s" % (item.infoLabels['tmdb_id'], item.infoLabels['tvdb_id'], item.infoLabels['imdb_id'], item.contentSerieName)
|
|
||||||
context_commands.append(("ExtendedInfo", "RunScript(script.extendedinfo,info=extendedtvinfo,%s)" % param))
|
|
||||||
|
|
||||||
elif item.contentType == "movie" and (item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.contentTitle):
|
|
||||||
param = "id =%s,imdb_id=%s,name=%s" % (item.infoLabels['tmdb_id'], item.infoLabels['imdb_id'], item.contentTitle)
|
|
||||||
context_commands.append(("ExtendedInfo", "RunScript(script.extendedinfo,info=extendedinfo,%s)" % param))
|
|
||||||
|
|
||||||
# InfoPlus
|
# InfoPlus
|
||||||
if config.get_setting("infoplus"):
|
if config.get_setting("infoplus"):
|
||||||
#if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id'] or \
|
#if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id'] or \
|
||||||
@@ -622,8 +598,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
|||||||
|
|
||||||
# Open in browser and previous menu
|
# Open in browser and previous menu
|
||||||
if parent_item.channel not in ["news", "channelselector", "downloads", "search"] and item.action != "mainlist" and not parent_item.noMainMenu:
|
if parent_item.channel not in ["news", "channelselector", "downloads", "search"] and item.action != "mainlist" and not parent_item.noMainMenu:
|
||||||
if parent_item.action != "mainlist":
|
|
||||||
context_commands.insert(0, (config.get_localized_string(60349), "Container.Refresh (%s?%s)" % (sys.argv[0], Item(channel=item.channel, action="mainlist").tourl())))
|
|
||||||
context_commands.insert(1, (config.get_localized_string(70739), "Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())))
|
context_commands.insert(1, (config.get_localized_string(70739), "Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())))
|
||||||
|
|
||||||
# Add to kodfavoritos (My links)
|
# Add to kodfavoritos (My links)
|
||||||
@@ -683,9 +657,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
|||||||
if (item.contentTitle and item.contentType in ['movie', 'tvshow']) or "buscar_trailer" in context:
|
if (item.contentTitle and item.contentType in ['movie', 'tvshow']) or "buscar_trailer" in context:
|
||||||
context_commands.append((config.get_localized_string(60359), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({ 'channel': "trailertools", 'action': "buscartrailer", 'search_title': item.contentTitle if item.contentTitle else item.fulltitle, 'contextual': True}))))
|
context_commands.append((config.get_localized_string(60359), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({ 'channel': "trailertools", 'action': "buscartrailer", 'search_title': item.contentTitle if item.contentTitle else item.fulltitle, 'contextual': True}))))
|
||||||
|
|
||||||
if kwargs.get('superfavourites'):
|
|
||||||
context_commands.append((config.get_localized_string(60361), "RunScript(special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py)"))
|
|
||||||
|
|
||||||
if config.dev_mode():
|
if config.dev_mode():
|
||||||
context_commands.insert(0, ("item info", "Container.Update (%s?%s)" % (sys.argv[0], Item(action="itemInfo", parent=item.tojson()).tourl())))
|
context_commands.insert(0, ("item info", "Container.Update (%s?%s)" % (sys.argv[0], Item(action="itemInfo", parent=item.tojson()).tourl())))
|
||||||
return context_commands
|
return context_commands
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def context():
|
|||||||
|
|
||||||
# pre-serialised
|
# pre-serialised
|
||||||
if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaG9ydGN1dF9tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
|
if config.get_setting('quick_menu'): context.append((config.get_localized_string(60360), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzaG9ydGN1dF9tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
|
||||||
if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
|
# if config.get_setting('kod_menu'): context.append((config.get_localized_string(60026), 'RunPlugin(plugin://plugin.video.kod/?ewogICAgImFjdGlvbiI6ICJzZXR0aW5nc19tZW51IiwgCiAgICAiY2hhbm5lbCI6ICJzaG9ydGN1dHMiLCAKICAgICJpbmZvTGFiZWxzIjoge30KfQ%3D%3D)'))
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|||||||
@@ -6481,5 +6481,21 @@ msgid "Downloading..."
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#90001"
|
msgctxt "#90001"
|
||||||
|
msgid "KOD options"
|
||||||
|
msgstr "KOD options..."
|
||||||
|
|
||||||
|
msgctxt "#90002"
|
||||||
|
msgid "No TMDB found"
|
||||||
|
msgstr "No TmdbId found, cannot continue"
|
||||||
|
|
||||||
|
msgctxt "#90003"
|
||||||
|
msgid "Already on KOD, continue searching on other channels?"
|
||||||
|
msgstr "Item is coming from KOD, continue searching on other channels?"
|
||||||
|
|
||||||
|
msgctxt "#90004"
|
||||||
|
msgid "No contextmenu option"
|
||||||
|
msgstr "No options"
|
||||||
|
|
||||||
|
msgctxt "#90005"
|
||||||
msgid "Search on KOD"
|
msgid "Search on KOD"
|
||||||
msgstr "Search on KOD..."
|
msgstr "Search with KOD"
|
||||||
|
|||||||
@@ -6481,7 +6481,22 @@ msgctxt "#80050"
|
|||||||
msgid "Downloading..."
|
msgid "Downloading..."
|
||||||
msgstr "Download in corso..."
|
msgstr "Download in corso..."
|
||||||
|
|
||||||
|
|
||||||
msgctxt "#90001"
|
msgctxt "#90001"
|
||||||
|
msgid "KOD options"
|
||||||
|
msgstr "Opzioni di KOD..."
|
||||||
|
|
||||||
|
msgctxt "#90002"
|
||||||
|
msgid "No TMDB found"
|
||||||
|
msgstr "Non sono riuscito a trovare le informazioni su TMDB"
|
||||||
|
|
||||||
|
msgctxt "#90003"
|
||||||
|
msgid "Already on KOD, continue searching on other channels?"
|
||||||
|
msgstr "Preferisci cercare su altri canali?"
|
||||||
|
|
||||||
|
msgctxt "#90004"
|
||||||
|
msgid "No contextmenu option"
|
||||||
|
msgstr "Nessuna opzione possibile"
|
||||||
|
|
||||||
|
msgctxt "#90005"
|
||||||
msgid "Search on KOD"
|
msgid "Search on KOD"
|
||||||
msgstr "Cerca con KOD..."
|
msgstr "Cerca con KOD"
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
<setting label="30024" type="lsep"/>
|
<setting label="30024" type="lsep"/>
|
||||||
<setting id="quick_menu" type="bool" label="60360" default="true"/>
|
<setting id="quick_menu" type="bool" label="60360" default="true"/>
|
||||||
<!-- <setting id="side_menu" type="bool" label="70737" default="false"/> -->
|
<!-- <setting id="side_menu" type="bool" label="70737" default="false"/> -->
|
||||||
<setting id="kod_menu" type="bool" label="60026" default="true"/>
|
<!-- <setting id="kod_menu" type="bool" label="60026" default="true"/>-->
|
||||||
<setting id="infoplus" type="bool" label="70151" default="false"/>
|
<setting id="infoplus" type="bool" label="70151" default="false"/>
|
||||||
<!-- <setting id="infoplus_set" type="bool" label="70128" visible="eq(-1,true)" default="false" subsetting="true"/> -->
|
<!-- <setting id="infoplus_set" type="bool" label="70128" visible="eq(-1,true)" default="false" subsetting="true"/> -->
|
||||||
<setting id="extended_info" type="bool" label="70152" default="false"/>
|
<setting id="extended_info" type="bool" label="70152" default="false"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user