Improve the settings layout and translation

* Turn the name of the main category of the settings into a localized
  string
* Add separators to group settings per theme
* Make some settings name more explicit
* Translate the possible values of the settings video_filter and
  video_sort_method

See merge request StCyr/plugin.video.peertube!20 for more information
This commit is contained in:
Thomas 2021-04-27 20:24:24 +00:00
parent 50a886d8cd
commit 13186dc697
6 changed files with 123 additions and 41 deletions

View File

@ -24,15 +24,19 @@ If you want to contribute, please start with the
# User settings
* Preferred PeerTube instance
* Preferred video resolution
* Number of items to display per page
* Value used to sort items when listing/searching videos:
* `views`: sort by number of views (ascending only)
* `likes`: sort by number of likes (ascending only)
* Select the filter to use when browsing the videos on an instance:
* local will only display the videos which are local to the selected instance
* all-local will only display the videos which are local to the selected
instance plus the private and unlisted videos **(requires admin privileges)**
* Browsing/Searching:
* Number of items to show per page (max 100)
* Field used to sort items when listing/searching videos:
* `views`: sort by number of views (ascending only)
* `likes`: sort by number of likes (ascending only)
* Select the filter to use when browsing and searching the videos on an instance:
* `local` will only display the videos which are local to the selected
instance
* `all-local` will only display the videos which are local to the selected
instance **plus** the private and unlisted videos
**(requires admin privileges)**
* Video playback:
* Preferred video resolution
# API

View File

@ -21,11 +21,11 @@ msgid "Preferred instance"
msgstr ""
msgctxt "#30001"
msgid "Number of videos to show per page"
msgid "Number of items to show per page"
msgstr ""
msgctxt "#30002"
msgid "Sort method to be used when listing videos"
msgid "Sort videos by"
msgstr ""
msgctxt "#30003"
@ -37,5 +37,33 @@ msgstr ""
#msgstr ""
msgctxt "#30005"
msgid "Filter local or all videos (for browsing only)"
msgid "List only videos with scope"
msgstr ""
msgctxt "#30006"
msgid "General"
msgstr ""
msgctxt "#30007"
msgid "Browsing/Searching"
msgstr ""
msgctxt "#30008"
msgid "Video playback"
msgstr ""
msgctxt "#30009"
msgid "local"
msgstr ""
msgctxt "#30010"
msgid "all-local (admins only)"
msgstr ""
msgctxt "#30011"
msgid "likes"
msgstr ""
msgctxt "#30012"
msgid "views"
msgstr ""

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Kodi Addons\n"
"Report-Msgid-Bugs-To: https://framagit.org/StCyr/plugin.video.peertube\n"
"Last-Translator: DavidHenryThoreau\n"
"Last-Translator: Thomas B.\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@ -21,12 +21,12 @@ msgid "Preferred instance"
msgstr "Instance préférée"
msgctxt "#30001"
msgid "Number of videos to show per page"
msgstr "Nombre de vidéos à afficher par page"
msgid "Number of items to show per page"
msgstr "Nombre d'éléments à afficher par page"
msgctxt "#30002"
msgid "Sort method to be used when listing videos"
msgstr "Méthode de tri pour lister les vidéos"
msgid "Sort videos by"
msgstr "Trier les vidéos par"
msgctxt "#30003"
msgid "Preferred video resolution"
@ -37,5 +37,33 @@ msgstr "Résolution vidéo préférée"
#msgstr "Supprimer les vidéos téléchargées à la fermeture de Kodi"
msgctxt "#30005"
msgid "Filter local or all videos (for browsing only)"
msgstr "Filtre local ou toutes les vidéos (pour la navigation seulement)"
msgid "List only videos with scope"
msgstr "Afficher uniquement les vidéos de type"
msgctxt "#30006"
msgid "General"
msgstr "Général"
msgctxt "#30007"
msgid "Browsing/Searching"
msgstr "Navigation/Recherche"
msgctxt "#30008"
msgid "Video playback"
msgstr "Lecture"
msgctxt "#30009"
msgid "local"
msgstr "local"
msgctxt "#30010"
msgid "all-local (admins only)"
msgstr "all-local (admins seulement)"
msgctxt "#30011"
msgid "likes"
msgstr "nombre de j'aime"
msgctxt "#30012"
msgid "views"
msgstr "nombre de vues"

View File

@ -49,9 +49,7 @@ class PeerTubeAddon():
# only by this object are directly retrieved from the settings
self.peertube = PeerTube(
instance=kodi.get_setting("preferred_instance"),
count=self.items_per_page,
sort=kodi.get_setting("video_sort_method"),
video_filter=kodi.get_setting("video_filter"))
count=self.items_per_page)
def _browse_videos(self, start):
"""Display the list of all the videos published on a PeerTube instance

View File

@ -17,27 +17,23 @@ from resources.lib.kodi_utils import kodi
class PeerTube:
"""A class to interact easily with PeerTube instances using REST APIs"""
def __init__(self, instance, sort, count, video_filter):
"""Constructor
def __init__(self, instance, count):
"""Initialize the parameters that will be used in the requests
Some values are retrieved directly from the settings, others come as
arguments because they are used somewhere else in the add-on.
:param str instance: URL of the PeerTube instance
:param str sort: sort method to use when listing items
:param int count: number of items to display
:param str video_filter: filter to apply when listing/searching videos
"""
self.set_instance(instance)
self.list_settings = {
"sort": sort,
"sort": self._get_sort_method(),
"count": count
}
# The value "video_filter" is directly retrieved from the settings so
# it must be converted into one of the expected values by the REST APIs
if "all-local" in video_filter:
self.filter = "all-local"
else:
self.filter = "local"
self.filter = self._get_video_filter()
def _request(self, method, url, params=None, data=None, instance=None):
"""Call a REST API on the instance
@ -117,6 +113,32 @@ class PeerTube:
return params
def _get_video_filter(self):
"""Get the video filter from the settings
The value of the associated setting is localized so a list is used to
get the value expected by the API based on the index of the value used.
:return: value of the video_filter setting
:rtype: str
"""
filters = ["local", "all-local"]
return filters[int(kodi.get_setting("video_filter"))]
def _get_sort_method(self):
"""Get the sort method from the settings
The value of the associated setting is localized so a list is used to
get the value expected by the API based on the index of the value used.
:return: value of the video_sort_method setting
:rtype: str
"""
sort_methods = ["likes", "views"]
return sort_methods[int(kodi.get_setting("video_sort_method"))]
def get_video_urls(self, video_id, instance=None):
"""Return the URLs of a video

View File

@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<setting id="preferred_instance" type="text" default="framatube.org" label="30000"/>
<setting type="sep"/>
<setting id="items_per_page" type="select" values="10|20|50|100" default="20" label="30001"/>
<setting id="video_sort_method" type="select" values="likes|views" default='views' label="30002"/>
<setting id="preferred_resolution" type="select" values="1080|720|480|360|240" default='480' label="30003"/>
<setting type="sep"/>
<!--<setting id="delete_files" type="bool" default="true" label="30004"/>-->
<setting id="video_filter" type="select" values="local|all-local (requires admin privileges)" default="local" label="30005"/>
<category label="30006">
<setting id="preferred_instance" type="text" default="framatube.org" label="30000"/>
<setting label="30007" type="lsep"/>
<setting id="items_per_page" type="select" values="10|20|50|100" default="20" label="30001"/>
<setting id="video_sort_method" type="select" lvalues="30011|30012" default=1 label="30002"/>
<setting id="video_filter" type="select" lvalues="30009|30010" default="0" label="30005"/>
<setting label="30008" type="lsep"/>
<setting id="preferred_resolution" type="select" values="1080|720|480|360|240" default='480' label="30003"/>
<!--<setting id="delete_files" type="bool" default="true" label="30004"/>-->
</category>
</settings>