Use the new JSON string returned by read()
* Adapt the code for the new information returned by read() * Display a warning if there are more than 1 file in the torrent because the add-on will play only the first file * Manage the error use case when calling write() * Remove the "start downloading" notification since an equivalent message is now displayed by vfs.libtorrent
This commit is contained in:
parent
4a1a02afef
commit
5eb7a46f34
|
@ -137,13 +137,9 @@ msgctxt "#30413"
|
||||||
msgid "PeerTube cannot play videos without libtorrent\nPlease follow the instructions at {}"
|
msgid "PeerTube cannot play videos without libtorrent\nPlease follow the instructions at {}"
|
||||||
msgstr "PeerTube kann keine Videos ohne libtorrent abspielen\nBitte folgen Sie den Anweisungen unter {}"
|
msgstr "PeerTube kann keine Videos ohne libtorrent abspielen\nBitte folgen Sie den Anweisungen unter {}"
|
||||||
|
|
||||||
msgctxt "#30414"
|
# 30414 is not used anymore
|
||||||
msgid "Download started"
|
|
||||||
msgstr "Download gestartet"
|
|
||||||
|
|
||||||
msgctxt "#30415"
|
# 30415 is not used anymore
|
||||||
msgid "The video will be played soon."
|
|
||||||
msgstr "Das Video wird in kürze abgespielt."
|
|
||||||
|
|
||||||
msgctxt "#30416"
|
msgctxt "#30416"
|
||||||
msgid "Download timeout"
|
msgid "Download timeout"
|
||||||
|
@ -164,3 +160,11 @@ msgstr "{} ist nun die ausgewählte Instanz."
|
||||||
msgctxt "#30420"
|
msgctxt "#30420"
|
||||||
msgid "You can still browse and search videos but you will not be able to play them (except live videos).\nPlease follow the instructions at {}"
|
msgid "You can still browse and search videos but you will not be able to play them (except live videos).\nPlease follow the instructions at {}"
|
||||||
msgstr "Sie können weiterhin Videos durchsuchen und suchen, aber Sie können sie nicht abspielen (außer Live-Videos).\nBefolgen Sie bitte die Anweisungen unter {}"
|
msgstr "Sie können weiterhin Videos durchsuchen und suchen, aber Sie können sie nicht abspielen (außer Live-Videos).\nBefolgen Sie bitte die Anweisungen unter {}"
|
||||||
|
|
||||||
|
msgctxt "#30421"
|
||||||
|
msgid "Download error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30422"
|
||||||
|
msgid "Error when trying to download the video. Check the log for more information."
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -137,13 +137,9 @@ msgctxt "#30413"
|
||||||
msgid "PeerTube cannot play videos without libtorrent\nPlease follow the instructions at {}"
|
msgid "PeerTube cannot play videos without libtorrent\nPlease follow the instructions at {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#30414"
|
# 30414 is not used anymore
|
||||||
msgid "Download started"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgctxt "#30415"
|
# 30415 is not used anymore
|
||||||
msgid "The video will be played soon."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgctxt "#30416"
|
msgctxt "#30416"
|
||||||
msgid "Download timeout"
|
msgid "Download timeout"
|
||||||
|
@ -164,3 +160,11 @@ msgstr ""
|
||||||
msgctxt "#30420"
|
msgctxt "#30420"
|
||||||
msgid "You can still browse and search videos but you will not be able to play them (except live videos).\nPlease follow the instructions at {}"
|
msgid "You can still browse and search videos but you will not be able to play them (except live videos).\nPlease follow the instructions at {}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30421"
|
||||||
|
msgid "Download error"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#30422"
|
||||||
|
msgid "Error when trying to download the video. Check the log for more information."
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -137,13 +137,9 @@ msgctxt "#30413"
|
||||||
msgid "PeerTube cannot play videos without libtorrent\nPlease follow the instructions at {}"
|
msgid "PeerTube cannot play videos without libtorrent\nPlease follow the instructions at {}"
|
||||||
msgstr "PeerTube ne peut pas lire de vidéos sans libtorrent.\nMerci de suivre les instructions depuis {}"
|
msgstr "PeerTube ne peut pas lire de vidéos sans libtorrent.\nMerci de suivre les instructions depuis {}"
|
||||||
|
|
||||||
msgctxt "#30414"
|
# 30414 is not used anymore
|
||||||
msgid "Download started"
|
|
||||||
msgstr "Démarrage du téléchargement"
|
|
||||||
|
|
||||||
msgctxt "#30415"
|
# 30415 is not used anymore
|
||||||
msgid "The video will be played soon."
|
|
||||||
msgstr "La video va être bientôt lue."
|
|
||||||
|
|
||||||
msgctxt "#30416"
|
msgctxt "#30416"
|
||||||
msgid "Download timeout"
|
msgid "Download timeout"
|
||||||
|
@ -164,3 +160,11 @@ msgstr "{} est maintenant l'instance sélectionnée."
|
||||||
msgctxt "#30420"
|
msgctxt "#30420"
|
||||||
msgid "You can still browse and search videos but you will not be able to play them (except live videos).\nPlease follow the instructions at {}"
|
msgid "You can still browse and search videos but you will not be able to play them (except live videos).\nPlease follow the instructions at {}"
|
||||||
msgstr "Vous pouvez parcourir ou chercher des vidéos mais vous ne pourrez pas les lire (sauf les live).\nMerci de suivre les instructions depuis {}"
|
msgstr "Vous pouvez parcourir ou chercher des vidéos mais vous ne pourrez pas les lire (sauf les live).\nMerci de suivre les instructions depuis {}"
|
||||||
|
|
||||||
|
msgctxt "#30421"
|
||||||
|
msgid "Download error"
|
||||||
|
msgstr "Erreur de téléchargement"
|
||||||
|
|
||||||
|
msgctxt "#30422"
|
||||||
|
msgid "Error when trying to download the video. Check the log for more information."
|
||||||
|
msgstr "Une erreur est survenue pendant le téléchargement de la vidéo. Voir le journal pour plus d'informations."
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
SPDX-License-Identifier: GPL-3.0-only
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
See LICENSE.txt for more information.
|
See LICENSE.txt for more information.
|
||||||
"""
|
"""
|
||||||
|
import json
|
||||||
import os.path
|
import os.path
|
||||||
from urllib import quote_plus
|
from urllib import quote_plus
|
||||||
|
|
||||||
|
@ -342,24 +343,32 @@ class PeerTubeAddon():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
kodi.debug("Starting torrent download ({})".format(torrent_url))
|
kodi.debug("Starting torrent download ({})".format(torrent_url))
|
||||||
kodi.notif_info(title=kodi.get_string(30414),
|
|
||||||
message=kodi.get_string(30415))
|
|
||||||
|
|
||||||
# Download the torrent using vfs.libtorrent: the torrent URL must be
|
# Download the torrent using vfs.libtorrent: the torrent URL must be
|
||||||
# URL encoded to be correctly read by vfs.libtorrent
|
# URL encoded to be correctly read by vfs.libtorrent
|
||||||
vfs_url = "torrent://{}".format(quote_plus(torrent_url))
|
vfs_url = "torrent://{}".format(quote_plus(torrent_url))
|
||||||
kodi.debug("URL sent to vfs.libtorrent = {}".format(vfs_url))
|
|
||||||
torrent = xbmcvfs.File(vfs_url)
|
torrent = xbmcvfs.File(vfs_url)
|
||||||
|
|
||||||
# Get the path of the downloaded file
|
# Download the file
|
||||||
self.torrent_file = torrent.read()
|
if(torrent.write("download")):
|
||||||
|
|
||||||
# Close the file handler because no other information is required
|
# Get information about the torrent
|
||||||
torrent.close()
|
torrent_info = json.loads(torrent.read())
|
||||||
|
|
||||||
|
# Build the path of the downloaded file
|
||||||
|
self.torrent_file = os.path.join(torrent_info["save_path"],
|
||||||
|
torrent_info["files"][0]["path"])
|
||||||
|
|
||||||
|
if torrent_info["nb_files"] > 1:
|
||||||
|
kodi.warning("There are more than 1 file in {} but only the"
|
||||||
|
" first one will be played.".format(torrent_url))
|
||||||
|
|
||||||
# Play the file
|
# Play the file
|
||||||
kodi.debug("Starting video playback of {}".format(self.torrent_file))
|
kodi.debug("Starting video playback of {}".format(self.torrent_file))
|
||||||
kodi.play(self.torrent_file)
|
kodi.play(self.torrent_file)
|
||||||
|
else:
|
||||||
|
kodi.notif_error(title=kodi.get_string(30421),
|
||||||
|
message=kodi.get_string(30422))
|
||||||
|
|
||||||
def _select_instance(self, instance):
|
def _select_instance(self, instance):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -281,4 +281,18 @@ class KodiUtils:
|
||||||
self.addon_handle = int(argv[1])
|
self.addon_handle = int(argv[1])
|
||||||
self.addon_parameters = argv[2]
|
self.addon_parameters = argv[2]
|
||||||
|
|
||||||
|
def warning(self, message, prefix=None):
|
||||||
|
"""Log a message in Kodi's log with the level xbmc.LOGWARNING
|
||||||
|
|
||||||
|
The message will be prefixed with the prefix passed as argument or with
|
||||||
|
the name of the add-on.
|
||||||
|
|
||||||
|
:param str message: Message to log
|
||||||
|
:param str prefix: String to prefix the message with
|
||||||
|
"""
|
||||||
|
if not prefix:
|
||||||
|
prefix = self.addon_name
|
||||||
|
|
||||||
|
xbmc.log("[{}] {}".format(prefix, message), xbmc.LOGWARNING)
|
||||||
|
|
||||||
kodi = KodiUtils()
|
kodi = KodiUtils()
|
||||||
|
|
Loading…
Reference in New Issue