get tmdb from imdb or title/year

This commit is contained in:
fatshotty
2021-04-19 16:20:55 +02:00
parent 722c7b63a9
commit 67a3335346
2 changed files with 21 additions and 15 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
</item> </item>
<item library="externalsearch.py"> <item library="externalsearch.py">
<label>90001</label> <label>90001</label>
<visible>!String.IsEmpty(ListItem.Property(tmdb_id))</visible> <visible>String.IsEqual(ListItem.dbtype,tvshow) | String.IsEqual(ListItem.dbtype,movie)</visible>
</item> </item>
</menu> </menu>
</extension> </extension>
+20 -14
View File
@@ -6,6 +6,7 @@ librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
sys.path.insert(0, librerias) sys.path.insert(0, librerias)
from core import tmdb
from core.item import Item from core.item import Item
@@ -21,30 +22,34 @@ def execute_search():
# These following lines are commented and keep in the code just as reminder. # These following lines are commented and keep in the code just as reminder.
# In future, they could be used to filter the search outcome # 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? # 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 # we could skip the ContextMenu if we already are in KOD's window
# #
# addon = xbmc.getInfoLabel('ListItem.Property(Addon.ID)') # 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')
tmdbid = xbmc.getInfoLabel('ListItem.Property(tmdb_id)')
tmdb = xbmc.getInfoLabel('ListItem.Property(tmdb_id)')
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE') mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
title = xbmc.getInfoLabel('ListItem.Title') 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)
logstr = "Selected ListItem is: 'TMDB: {}' - 'Title: {}' - 'Type: {}'".format(tmdb, title, mediatype)
logger.info(logstr) 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( item = Item(
action="Search", action="Search",
channel="globalsearch", channel="globalsearch",
@@ -53,7 +58,8 @@ def execute_search():
text= title, text= title,
type= mediatype, type= mediatype,
infoLabels= { infoLabels= {
'tmdb_id': tmdb 'tmdb_id': tmdbid,
'year': year
}, },
folder= False folder= False
) )