Skip to content

Commit

Permalink
Added context menu implementation for kodi 15 (isengard)
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed May 18, 2015
1 parent bd24584 commit 943524b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
14 changes: 13 additions & 1 deletion addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.trakt" name="Trakt" version="3.0.1" provider-name="Trakt.tv">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="xbmc.python" version="2.20.0"/>

This comment has been minimized.

Copy link
@tknorris

tknorris May 21, 2015

Hey, are you sure you want to force the update on the xbmc.python dependency now? The updated dependency will also force everyone to update to Isengard ASAP if they want fixes to 3.0.1. From what I can tell, if you are still running helix everything still works, and since the contextmenu is new for Isengard anyway, it's no issue on Helix if it doesn't work. (I'm still doing dev on Helix)

This comment has been minimized.

Copy link
@razzeee

razzeee May 21, 2015

Author Owner

Why does it force everyone to update? Like you said it's still working on helix?

This comment has been minimized.

Copy link
@tknorris

tknorris May 21, 2015

Because the python version is tied to the xbmc release. Helix and below are 2.1.0 while Isengard is 2.20.0. So, no one will be able to install the addon w/ that import unless they are on Isengard or better.

This comment has been minimized.

Copy link
@razzeee

razzeee May 21, 2015

Author Owner

Ah okay I may have tested it on isengard and then downgraded. So it stayed working. Anyway, it's a bug that two extension points are working, so I will have to split this to their own addons. See the kodi forum http://forum.kodi.tv/showthread.php?tid=227271

This comment has been minimized.

Copy link
@tknorris

tknorris May 21, 2015

Here's the wiki link on how that import works. Check out section 2.3.2.1.

I'm really worried about this new context menu deal. People's menus are going to get overloaded fast...

This comment has been minimized.

Copy link
@razzeee

razzeee May 21, 2015

Author Owner

Yeah, I also think so. But let's lead with an example ;)
Anyway we could probably drop Frodo?

This comment has been minimized.

Copy link
@tknorris

tknorris May 21, 2015

Yep, I agree, drop Frodo.

<import addon="script.module.simplejson" version="3.3.0"/>
<import addon="script.module.trakt" version="2.3.1"/>
<import addon="script.module.dateutil" version="2.4.2"/>
Expand All @@ -10,6 +10,18 @@
<provides>executable</provides>
</extension>
<extension point="xbmc.service" name="trakt.service" library="default.py" start="login" />
<extension point="kodi.context.item" library="rateContextMenu.py">
<item>
<label>32150</label>
<visible>StringCompare(ListItem.dbtype,movie) | StringCompare(ListItem.dbtype,tvshow) | StringCompare(ListItem.dbtype,season) | StringCompare(ListItem.dbtype,episode)</visible>
</item>
</extension>
<extension point="kodi.context.item" library="toggleWatchedContextMenu.py">
<item>
<label>32151</label>
<visible>StringCompare(ListItem.dbtype,movie) | StringCompare(ListItem.dbtype,tvshow) | StringCompare(ListItem.dbtype,season) | StringCompare(ListItem.dbtype,episode)</visible>
</item>
</extension>
<extension point="xbmc.addon.metadata" name="trakt.metadata">
<summary lang="da">TV og film program for Trakt.tv</summary>
<summary lang="de">TV und Film Scrobbler für Trakt.tv</summary>
Expand Down
7 changes: 7 additions & 0 deletions rateContextMenu.py
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-

import xbmc
import utilities

if __name__ == '__main__':
xbmc.executebuiltin("RunScript(script.trakt,action=rate,media_type=%s,dbid=%s)" % (utilities.getMediaType(), xbmc.getInfoLabel("ListItem.DBID")))
8 changes: 8 additions & 0 deletions resources/language/English/strings.po
Expand Up @@ -604,4 +604,12 @@ msgstr ""

msgctxt "#32149"
msgid "Rate this Season"
msgstr ""

msgctxt "#32150"
msgid "Trakt - Toggle Watched"
msgstr ""

msgctxt "#32151"
msgid "Trakt - Rate"
msgstr ""
18 changes: 2 additions & 16 deletions script.py
Expand Up @@ -6,25 +6,11 @@
import logging
import xbmcgui
import xbmcaddon
from traktContextMenu import traktContextMenu

logger = logging.getLogger(__name__)

__addon__ = xbmcaddon.Addon("script.trakt")

def __getMediaType():

if xbmc.getCondVisibility('Container.Content(tvshows)'):
return "show"
elif xbmc.getCondVisibility('Container.Content(seasons)'):
return "season"
elif xbmc.getCondVisibility('Container.Content(episodes)'):
return "episode"
elif xbmc.getCondVisibility('Container.Content(movies)'):
return "movie"
else:
return None

def __getArguments():
data = None
default_actions = {0: "sync"}
Expand Down Expand Up @@ -108,7 +94,7 @@ def Main():
except KeyError:
pass
else:
media_type = __getMediaType()
media_type = utils.getMediaType()
if not utils.isValidMediaType(media_type):
logger.debug("Error, not in video library.")
return
Expand Down Expand Up @@ -162,7 +148,7 @@ def Main():
logger.debug("Manual %s of '%s' is unsupported." % (args['action'], media_type))

elif args['action'] == 'togglewatched':
media_type = __getMediaType()
media_type = utils.getMediaType()
if media_type in ['movie', 'show', 'season', 'episode']:
data = {'media_type': media_type}
if utils.isMovie(media_type):
Expand Down
6 changes: 6 additions & 0 deletions toggleWatchedContextMenu.py
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

import xbmc

if __name__ == '__main__':
xbmc.executebuiltin("RunScript(script.trakt,action=togglewatched)")
14 changes: 13 additions & 1 deletion utilities.py
Expand Up @@ -481,4 +481,16 @@ def parseIdToTraktIds(id, type):
elif id.isdigit():
data['tvdb'] = id
id_type = 'tvdb'
return data, id_type
return data, id_type

def getMediaType():
if xbmc.getCondVisibility('Container.Content(tvshows)'):
return "show"
elif xbmc.getCondVisibility('Container.Content(seasons)'):
return "season"
elif xbmc.getCondVisibility('Container.Content(episodes)'):
return "episode"
elif xbmc.getCondVisibility('Container.Content(movies)'):
return "movie"
else:
return None

0 comments on commit 943524b

Please sign in to comment.