Update code for python 3

Drop support of python 2 and make the code compatible with python 3 so that the add-on works on Kodi 19.

Update Kodistubs version in the CI and get rid of the python 2 actions.

Note: script.module.libtorrent is disabled because it will not be used on Matrix (and is not compatible).
It will be replaced by vfs.libtorrent[1] when ready.

[1]: https://framagit.org/thombet/vfs.libtorrent
This commit is contained in:
Thomas 2021-09-01 22:17:39 +00:00
parent b629ee43a6
commit 8dec0f316e
7 changed files with 19 additions and 25 deletions

View File

@ -12,7 +12,7 @@ stages:
.apt_get_update: &apt_get_update
- apt-get update > /dev/null
.python3_prep: &python3_prep
.python_prep: &python_prep
- apt-get install --yes python3-dev python3-pip > /dev/null
- python3 -m pip --quiet install -r misc/python_requirements.txt
@ -34,7 +34,7 @@ quality:
when: manual
before_script:
- *apt_get_update
- *python3_prep
- *python_prep
script:
- find . -iname '*.py' | xargs -t python3 -m pylint --rcfile=misc/pylint-rcfile.txt | tee pylint.log
artifacts:

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.peertube" name="PeerTube" version="1.2.0" provider-name="Cyrille B. + Thomas B.">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.addon.signals" version="0.0.3"/>
<import addon="script.module.requests" version="2.22.0"/>
<import addon="script.module.libtorrent" version="1.2.0"/>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.addon.signals" version="0.0.6"/>
<import addon="script.module.requests" version="2.25.1"/>
<!-- <import addon="script.module.libtorrent" version="1.2.0"/> -->
</requires>
<extension point="xbmc.python.pluginsource" library="main.py">
<provides>video</provides>

View File

@ -1,3 +1,3 @@
Kodistubs==18.0.0
Kodistubs>=19.0.0
pylint
requests

View File

@ -195,13 +195,13 @@ class PeerTubeAddon():
"""
next_index = current_index + self.items_per_page
if total > next_index:
next_page = (next_index / self.items_per_page) + 1
total_pages = (total / self.items_per_page) + 1
next_page = (next_index // self.items_per_page) + 1
total_pages = (total // self.items_per_page) + 1
next_page_item = kodi.generate_item_info(
name=u"{} ({}/{})".format(kodi.get_string(30405),
next_page,
total_pages),
name="{} ({}/{})".format(kodi.get_string(30405),
next_page,
total_pages),
url=url
)

View File

@ -8,18 +8,13 @@
See LICENSE.txt for more information.
"""
import os
try:
# Python 3.x
from urllib.parse import parse_qsl
except ImportError:
# Python 2.x
from urlparse import parse_qsl
from requests.compat import urlencode
from urllib.parse import parse_qsl
import xbmc # Kodistubs for Leia is not compatible with python3 / pylint: disable=syntax-error
import xbmc
import xbmcaddon
import xbmcgui # Kodistubs for Leia is not compatible with python3 / pylint: disable=syntax-error
import xbmcgui
import xbmcplugin
@ -210,7 +205,7 @@ class KodiUtils:
:param str title: Title of the box
:param str message: Message in the box
"""
xbmcgui.Dialog().ok(heading=title, line1=message)
xbmcgui.Dialog().ok(heading=title, message=message)
def open_input_box(self, title):
"""Open a box for the user to input alphanumeric data

View File

@ -112,8 +112,7 @@ class PeerTube:
params = self.list_settings.copy()
# Add all the arguments to the dict
for param in kwargs:
params[param] = kwargs[param]
params.update(kwargs)
return params

View File

@ -11,8 +11,8 @@
import AddonSignals # Module exists only in Kodi - pylint: disable=import-error
from threading import Thread
import xbmc # Kodistubs for Leia is not compatible with python3 / pylint: disable=syntax-error
import xbmcvfs # Kodistubs for Leia is not compatible with python3 / pylint: disable=syntax-error
import xbmc
import xbmcvfs
from resources.lib.kodi_utils import kodi