1
0
mirror of https://framagit.org/StCyr/plugin.video.peertube synced 2025-06-05 22:09:16 +02:00

Guide the user when libtorrent cannot be imported

Libtorrent is required to play videos but its installation is still
manual so now a message is displayed when libtorrent could not be
imported instead of having a "service could not start" error at Kodi
startup.
The message contains a link to a page which explains how to install
libtorrent. It will be displayed when:
* the add-on starts
* the user selects a video to play (including when called externally)

Other additions:
* Create a kodi_utils module to centralize some calls to the Kodi API
* Add license information in the header of the files
* Ignore some files in Git (python cache and Mac OS system file)
This commit is contained in:
Thomas
2021-04-02 22:07:35 +00:00
committed by Thomas Bétous
parent 7a21bd92ac
commit 4346178db9
6 changed files with 222 additions and 92 deletions

View File

@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
"""
Utility functions to interact easily with Kodi
Copyright (C) 2021 Thomas Bétous
SPDX-License-Identifier: GPL-3.0-only
See LICENSE.txt for more information.
"""
import xbmc
import xbmcgui
def debug(message):
"""Log a message in Kodi's log with the level xbmc.LOGDEBUG
:param str message: Message to log
"""
xbmc.log(message, xbmc.LOGDEBUG)
def get_property(name):
"""Retrieve the value of a window property related to the add-on
:param str name: name of the property which value will be retrieved (the
actual name of the property is prefixed with "peertube_")
:return: the value of the window property
:rtype: str
"""
return xbmcgui.Window(10000).getProperty('peertube_{}'.format(name))
def notif_error(title, message):
"""Display a notification with the error icon
:param str title: Title of the notification
:param str message: Message of the notification
"""
xbmcgui.Dialog().notification(heading=title,
message=message,
icon=xbmcgui.NOTIFICATION_ERROR)
def notif_info(title, message):
"""Display a notification with the info icon
:param str title: Title of the notification
:param str message: Message of the notification
"""
xbmcgui.Dialog().notification(heading=title,
message=message,
icon=xbmcgui.NOTIFICATION_INFO)
def notif_warning(title, message):
"""Display a notification with the warning icon
:param str title: Title of the notification
:param str message: Message of the notification
"""
xbmcgui.Dialog().notification(heading=title,
message=message,
icon=xbmcgui.NOTIFICATION_WARNING)
def open_dialog(title, message):
"""Open a dialog box with an "OK" button
:param str title: Title of the box
:param str message: Message in the box
"""
xbmcgui.Dialog().ok(heading=title, line1=message)
def set_property(name, value):
"""Modify the value of a window property related to the add-on
:param str name: Name of the property which value will be modified (the
actual name of the property is prefixed with "peertube_")
:param str value: New value of the property
"""
xbmcgui.Window(10000).setProperty('peertube_{}'.format(name), value)