diff --git a/addon.xml b/addon.xml index 68d0cd20..ea492595 100644 --- a/addon.xml +++ b/addon.xml @@ -16,6 +16,10 @@ String.IsEqual(ListItem.dbtype,tvshow) + + + !String.IsEmpty(ListItem.Property(tmdb_id)) + diff --git a/externalsearch.py b/externalsearch.py new file mode 100644 index 00000000..d6312ca8 --- /dev/null +++ b/externalsearch.py @@ -0,0 +1,68 @@ +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.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 + + # IMDB: the imdb of the selected ListItem + # this field is the Kodi's core field (not TMDB) + # + # imdb = xbmc.getInfoLabel('ListItem.IMDBNumber') + + # 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 + # + # addon = xbmc.getInfoLabel('ListItem.Property(Addon.ID)') + + # YEAR: the year of the selected ListItem + # this field is the Kodi's core field + # + # year = xbmc.getInfoLabel('ListItem.Year') + + + tmdb = xbmc.getInfoLabel('ListItem.Property(tmdb_id)') + mediatype = xbmc.getInfoLabel('ListItem.DBTYPE') + title = xbmc.getInfoLabel('ListItem.Title') + + + logstr = "Selected ListItem is: 'TMDB: {}' - 'Title: {}' - 'Type: {}'".format(tmdb, title, mediatype) + logger.info(logstr) + + item = Item( + action="Search", + channel="globalsearch", + contentType= mediatype, + mode="search", + text= title, + type= mediatype, + infoLabels= { + 'tmdb_id': tmdb + }, + 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() diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 08bf7ce2..fb0adeb1 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -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 "" \ No newline at end of file +msgstr "" + +msgctxt "#90001" +msgid "Search on KOD" +msgstr "Search on KOD..." diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index a1e89d49..307be3f8 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -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..." diff --git a/updatetvshow.py b/updatetvshow.py index f0b9287f..159009a3 100644 --- a/updatetvshow.py +++ b/updatetvshow.py @@ -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()