Skip to content
17 changes: 14 additions & 3 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.plexkodiconnect.tvshows" name="PlexKodiConnect Helper TV Shows" version="2.1.3" provider-name="croneter">
<addon id="plugin.video.plexkodiconnect.tvshows" name="PlexKodiConnect Helper TV Shows" version="3.0.2" provider-name="croneter">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="xbmc.python" version="3.0.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="default.py">
<provides></provides>
</extension>
<extension point="xbmc.addon.metadata">
<!-- see e.g. https://github.com/xbmc/xbmc/pull/14136 -->
<reuselanguageinvoker>true</reuselanguageinvoker>
<summary lang="en">PKC Dependency Add-On</summary>
<description lang="en">PlexKodiConnect add-on for tv shows</description>
<platform>all</platform>
Expand All @@ -15,7 +17,16 @@
<forum></forum>
<website>https://github.com/croneter/PlexKodiConnect</website>
<source></source>
<news>version 2.1.3
<news>version 3.0.2
- Use addon.xml `reuselanguageinvoker` to turn add-on snappier

version 3.0.1
- Make PKC compatible with Kodi 20 N* by using xbmcvfs for translatePath

version 3.0.0
- Initial version for Kodi 19 Matrix using Python 3

version 2.1.3
- Fix UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

version 2.1.2
Expand Down
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
version 3.0.2
- Use addon.xml `reuselanguageinvoker` to turn add-on snappier

version 3.0.1
- Make PKC compatible with Kodi 20 N* by using xbmcvfs for translatePath

version 3.0.0
- Initial version for Kodi 19 Matrix using Python 3

version 2.1.3
- Fix UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

Expand Down
29 changes: 11 additions & 18 deletions default.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
# -*- coding: utf-8 -*-
# We need this in order to use add-on paths like
# 'plugin://plugin.video.plexkodiconnect.MOVIES' in the Kodi video database
###############################################################################
from __future__ import absolute_import, division, unicode_literals
from logging import getLogger
import sys
import os

import xbmc
import xbmcvfs
import xbmcgui
import xbmcplugin
import xbmcaddon

# Import from the main pkc add-on
__addon__ = xbmcaddon.Addon(id='plugin.video.plexkodiconnect')
__temp_path__ = os.path.join(__addon__.getAddonInfo('path').decode('utf-8'), 'resources', 'lib')
__base__ = xbmc.translatePath(__temp_path__.encode('utf-8')).decode('utf-8')
__temp_path__ = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')
__base__ = xbmcvfs.translatePath(__temp_path__.encode('utf-8'))
sys.path.append(__base__)

import transfer, loghandler
from tools import unicode_paths

###############################################################################
loghandler.config()
LOG = getLogger('PLEX.TVSHOWS')
###############################################################################

HANDLE = int(sys.argv[1])


def play():
Expand All @@ -38,26 +31,26 @@ def play():
if not sys.argv[2]:
# Browsing to a tv show from a tv show info dialog - picked up
# by kodimonitor.py and its method OnAdd
xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
return
else:
request = '%s&handle=%s' % (unicode_paths.decode(sys.argv[2]), HANDLE)
if b'resume:true' in sys.argv:
request = f'{sys.argv[2]}&handle={int(sys.argv[1])}'
if 'resume:true' in sys.argv:
request += '&resume=1'
elif b'resume:false' in sys.argv:
elif 'resume:false' in sys.argv:
request += '&resume=0'
transfer.plex_command('PLAY-%s' % request)
if HANDLE == -1:
transfer.plex_command(f'PLAY-{request}')
if int(sys.argv[1]) == -1:
# Handle -1 received, not waiting for main thread
return
# Wait for the result
result = transfer.wait_for_transfer(source='main')
if result is True:
xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem())
# Tell main thread that we're done
transfer.send(True, target='main')
else:
xbmcplugin.setResolvedUrl(HANDLE, True, result)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, result)


if __name__ == '__main__':
Expand Down