Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major upgrade from Python 2 to Python 3, allowing use of Kodi 19 Matrix #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
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.movies" name="PlexKodiConnect Helper Movies" version="2.1.3" provider-name="croneter">
<addon id="plugin.video.plexkodiconnect.movies" name="PlexKodiConnect Helper Movies" 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 movies</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
27 changes: 10 additions & 17 deletions default.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@
# -*- 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__)
sys.path.append(__base__)

import transfer, loghandler
from tools import unicode_paths

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

HANDLE = int(sys.argv[1])


def play():
"""
Start up playback_starter in main Python thread
"""
LOG.debug('Full sys.argv received: %s', sys.argv)
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'
# Put the request into the 'queue'
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