Merge pull request #297 from fatshotty/master

Aggiunto menu contestuale  "Cerca in KoD"
This commit is contained in:
Alhaziel01
2021-04-20 12:42:40 +02:00
committed by GitHub
5 changed files with 101 additions and 5 deletions

View File

@@ -14,7 +14,11 @@
<menu id="kodi.core.main">
<item library="updatetvshow.py">
<label>70269</label>
<visible>String.IsEqual(ListItem.dbtype,tvshow)</visible>
<visible>String.StartsWith(ListItem.FileNameAndPath, 'plugin://plugin.video.kod/') + String.IsEqual(ListItem.dbtype,tvshow)</visible>
</item>
<item library="externalsearch.py">
<label>90001</label>
<visible>!String.StartsWith(ListItem.FileNameAndPath, 'plugin://plugin.video.kod/') + [String.IsEqual(ListItem.dbtype,tvshow) | String.IsEqual(ListItem.dbtype,movie)]</visible>
</item>
</menu>
</extension>

82
externalsearch.py Normal file
View File

@@ -0,0 +1,82 @@
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)
from core import tmdb
from core.item import Item
def execute_search():
"""
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')
# folderPath = xbmc.getInfoLabel('Container.FolderPath')
# filePath = xbmc.getInfoLabel('ListItem.FileNameAndPath')
# logger.info("****")
# logger.info( xbmc.getCondVisibility("String.Contains(Container.FolderPath, 'plugin.video.kod')") )
# logger.info( xbmc.getCondVisibility("String.Contains(ListItem.FileNameAndPath, 'plugin.video.kod')") )
# logger.info( xbmc.getCondVisibility("String.IsEqual(ListItem.dbtype,tvshow)") )
# logger.info( xbmc.getCondVisibility("String.IsEqual(ListItem.dbtype,movie)") )
# logger.info("****")
# visible = xbmc.getCondVisibility("!String.StartsWith(ListItem.FileNameAndPath, 'plugin://plugin.video.kod/') + [String.IsEqual(ListItem.dbtype,tvshow) | String.IsEqual(ListItem.dbtype,movie)]")
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})
tmdb.set_infoLabels(it)
tmdbid = it.infoLabels.get('tmdb_id', '')
if not tmdbid:
logger.info('No TMDBid found. Try to get by Title/Year')
it = Item(contentTitle= title, contentType= mediatype, infoLabels={'year' : year})
tmdb.set_infoLabels(it)
tmdbid = it.infoLabels.get('tmdb_id', '')
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: {}".format(item.tostring()))
itemurl = item.tourl()
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + itemurl + ")")
if __name__ == '__main__':
execute_search()

View File

@@ -3975,7 +3975,7 @@ msgstr ""
msgctxt "#70292"
msgid "[%s] File no longer exist on this server."
msgstr ""
msgctxt "#70293"
msgid "[%s] The file is processing or has been deleted."
msgstr ""
@@ -6478,4 +6478,8 @@ msgstr ""
msgctxt "#80050"
msgid "Downloading..."
msgstr ""
msgstr ""
msgctxt "#90001"
msgid "Search on KOD"
msgstr "Search on KOD..."

View File

@@ -3974,7 +3974,7 @@ msgstr "Errore, in conversione"
msgctxt "#70292"
msgid "[%s] File no longer exist on this server."
msgstr "[%s] Il file non è più presente nel server."
msgctxt "#70293"
msgid "[%s] The file is processing or has been deleted."
msgstr "[%s] Il file video è ancora in elaborazione o è stato rimosso."
@@ -6480,3 +6480,8 @@ msgstr "Rimuovi episodi in locale"
msgctxt "#80050"
msgid "Downloading..."
msgstr "Download in corso..."
msgctxt "#90001"
msgid "Search on KOD"
msgstr "Cerca con KOD..."

View File

@@ -107,7 +107,8 @@ if __name__ == '__main__':
path = search_paths(sys.listitem.getVideoInfoTag().getDbId())
if path:
item = Item(action="update_tvshow", channel="videolibrary", path=path)
item.tourl()
# Why? I think it is not necessary, just commented
# item.tourl()
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + item.tourl() + ")")
else:
dialog = xbmcgui.Dialog()