forked from croneter/PlexKodiConnect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contextmenu.py
50 lines (42 loc) · 1.61 KB
/
contextmenu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
###############################################################################
from __future__ import absolute_import, division, unicode_literals
from sys import listitem
from urllib import urlencode
from xbmc import getCondVisibility, sleep
from xbmcgui import Window
###############################################################################
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
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
}
while window.getProperty('plexkodiconnect.command'):
sleep(20)
window.setProperty('plexkodiconnect.command',
'CONTEXT_menu?%s' % urlencode(args))
if __name__ == "__main__":
main()