2016-01-11 16:53:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2016-10-22 17:15:10 +02:00
|
|
|
###############################################################################
|
2018-02-15 19:47:01 +01:00
|
|
|
from sys import listitem
|
2020-12-18 17:10:20 +01:00
|
|
|
from urllib.parse import urlencode
|
2016-01-11 16:53:41 +01:00
|
|
|
|
2018-02-15 19:47:01 +01:00
|
|
|
from xbmc import getCondVisibility, sleep
|
2017-09-10 15:09:32 +02:00
|
|
|
from xbmcgui import Window
|
2016-01-11 16:53:41 +01:00
|
|
|
|
2018-02-15 19:47:01 +01:00
|
|
|
###############################################################################
|
|
|
|
|
2016-04-07 08:34:01 +02:00
|
|
|
|
2018-02-15 19:47:01 +01:00
|
|
|
def _get_kodi_type():
|
|
|
|
kodi_type = listitem.getVideoInfoTag().getMediaType().decode('utf-8')
|
|
|
|
if not kodi_type:
|
|
|
|
if getCondVisibility('Container.Content(albums)'):
|
|
|
|
kodi_type = "album"
|
|
|
|
elif getCondVisibility('Container.Content(artists)'):
|
|
|
|
kodi_type = "artist"
|
|
|
|
elif getCondVisibility('Container.Content(songs)'):
|
|
|
|
kodi_type = "song"
|
|
|
|
elif getCondVisibility('Container.Content(pictures)'):
|
|
|
|
kodi_type = "picture"
|
|
|
|
return kodi_type
|
2016-01-11 16:53:41 +01:00
|
|
|
|
2016-08-29 18:44:27 +02:00
|
|
|
|
2018-02-22 18:13:38 +01:00
|
|
|
def main():
|
|
|
|
"""
|
|
|
|
Grabs kodi_id and kodi_type and sends a request to our main python instance
|
|
|
|
that context menu needs to be displayed
|
|
|
|
"""
|
|
|
|
window = Window(10000)
|
|
|
|
kodi_id = listitem.getVideoInfoTag().getDbId()
|
|
|
|
if kodi_id == -1:
|
|
|
|
# There is no getDbId() method for getMusicInfoTag
|
|
|
|
# YET TO BE IMPLEMENTED - lookup ID using path
|
|
|
|
kodi_id = listitem.getMusicInfoTag().getURL()
|
|
|
|
kodi_type = _get_kodi_type()
|
|
|
|
args = {
|
|
|
|
'kodi_id': kodi_id,
|
|
|
|
'kodi_type': kodi_type
|
2018-02-15 19:47:01 +01:00
|
|
|
}
|
2019-01-26 08:43:51 +01:00
|
|
|
while window.getProperty('plexkodiconnect.command'):
|
2017-09-10 15:09:32 +02:00
|
|
|
sleep(20)
|
2019-01-26 08:43:51 +01:00
|
|
|
window.setProperty('plexkodiconnect.command',
|
|
|
|
'CONTEXT_menu?%s' % urlencode(args))
|
2018-02-22 18:13:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|