Convert code to Python 3-compatible
This commit is contained in:
parent
3833a3e2ac
commit
1fad214fc0
|
|
@ -5,6 +5,7 @@ name="Example Kodi Video Plugin"
|
||||||
provider-name="Roman_V_M">
|
provider-name="Roman_V_M">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.25.0"/>
|
<import addon="xbmc.python" version="2.25.0"/>
|
||||||
|
<import addon="script.module.future" />
|
||||||
</requires>
|
</requires>
|
||||||
<extension point="xbmc.python.pluginsource" library="main.py">
|
<extension point="xbmc.python.pluginsource" library="main.py">
|
||||||
<provides>video</provides>
|
<provides>video</provides>
|
||||||
|
|
|
||||||
20
main.py
20
main.py
|
|
@ -3,10 +3,23 @@
|
||||||
# Author: Roman V. M.
|
# Author: Roman V. M.
|
||||||
# Created on: 28.11.2014
|
# Created on: 28.11.2014
|
||||||
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
|
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
|
||||||
|
"""
|
||||||
|
Example video plugin that is compatible with both Python 2 and 3
|
||||||
|
|
||||||
|
Compatibility features are provided by ``script.module.future`` library addon.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Enable unicode strings by default as in Python 3
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
# Monkey-patch standard libary names to enable Python 3-like behavior
|
||||||
|
from future import standard_library
|
||||||
|
standard_library.install_aliases()
|
||||||
|
# The above strings provide compatibility layer for Python 2
|
||||||
|
# so the code can work in both versions.
|
||||||
|
# In Python 3 they do nothing and can be safely removed.
|
||||||
|
# Normal imports for your addon:
|
||||||
import sys
|
import sys
|
||||||
from urllib import urlencode
|
from urllib.parse import urlencode, parse_qsl
|
||||||
from urlparse import parse_qsl
|
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
|
|
||||||
|
|
@ -65,7 +78,6 @@ def get_url(**kwargs):
|
||||||
Create a URL for calling the plugin recursively from the given set of keyword arguments.
|
Create a URL for calling the plugin recursively from the given set of keyword arguments.
|
||||||
|
|
||||||
:param kwargs: "argument=value" pairs
|
:param kwargs: "argument=value" pairs
|
||||||
:type kwargs: dict
|
|
||||||
:return: plugin call URL
|
:return: plugin call URL
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
|
|
@ -86,7 +98,7 @@ def get_categories():
|
||||||
:return: The list of video categories
|
:return: The list of video categories
|
||||||
:rtype: types.GeneratorType
|
:rtype: types.GeneratorType
|
||||||
"""
|
"""
|
||||||
return VIDEOS.iterkeys()
|
return VIDEOS.keys()
|
||||||
|
|
||||||
|
|
||||||
def get_videos(category):
|
def get_videos(category):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue