From e2fb283f00630a3c97d3d900eca2351e85a25859 Mon Sep 17 00:00:00 2001 From: fernandog Date: Sat, 18 Oct 2014 21:09:55 -0300 Subject: [PATCH] Added option to show/hide notifications on screen --- resources/language/English/strings.po | 6 +++++- resources/lib/common.py | 3 ++- resources/lib/player.py | 22 +++++++++++++++------- resources/settings.xml | 1 + 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index 52af412..57c2a01 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -192,8 +192,12 @@ msgctxt "#32810" msgid "Don't pause seeding torrents" msgstr "" +msgctxt "#32811" +msgid "Show notifications on screen" +msgstr "" + #Errors -#empty strings from id 32811 to 32899 +#empty strings from id 32812 to 32899 msgctxt "#32900" msgid "An unexpected error occurred" diff --git a/resources/lib/common.py b/resources/lib/common.py index 8267f49..ba6fbe8 100644 --- a/resources/lib/common.py +++ b/resources/lib/common.py @@ -14,7 +14,8 @@ def get_settings(): 'password': __settings__.getSetting('rpc_password'), 'action_on_playback': __settings__.getSetting('action_on_playback'), 'seconds_playback_finished': __settings__.getSetting('seconds_playback_finished'), - 'seeding_torrents': __settings__.getSetting('seeding_torrents') + 'seeding_torrents': __settings__.getSetting('seeding_torrents'), + 'show_notifications': __settings__.getSetting('show_notifications') } return params diff --git a/resources/lib/player.py b/resources/lib/player.py index d43cc28..05d39b4 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -29,7 +29,8 @@ class SubstitutePlayer(xbmc.Player): self.refreshSettings() if self.mode != '0' and xbmc.Player().isPlayingVideo() == True and self.TimerON == False: if self.mode == '1': - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Pausing torrents...",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Pausing torrents...",5000, __icon__)) self.stopAllTorrents() elif self.mode == '2': self.enableSpeedLimit() @@ -38,9 +39,11 @@ class SubstitutePlayer(xbmc.Player): xbmc.sleep(1) self.refreshSettings() if self.mode == '1' and not xbmc.Player().isPlayingVideo(): - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Torrents will be started in " + str(self.seconds/1000) + " seconds",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Torrents will be started in " + str(self.seconds/1000) + " seconds",5000, __icon__)) elif self.mode == '2' and not xbmc.Player().isPlayingVideo(): - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Speed limited will be disabled in " + str(self.seconds/1000) + " seconds",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Speed limited will be disabled in " + str(self.seconds/1000) + " seconds",5000, __icon__)) self.TimerON = True xbmc.sleep(int(self.seconds)) self.TimerON = False @@ -49,7 +52,8 @@ class SubstitutePlayer(xbmc.Player): elif self.mode == '2' and xbmc.Player().isPlayingVideo() == False: self.disableSpeedLimit() else: - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Still watching. Torrents still paused/limited",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Still watching. Torrents still paused/limited",5000, __icon__)) def onPlayBackEnded(self): self.ResumingTorrents() @@ -59,7 +63,8 @@ class SubstitutePlayer(xbmc.Player): def startAllTorrents(self): if self.transmission: - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Starting torrents...",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Starting torrents...",5000, __icon__)) torrents = self.transmission.list() for tid, torrent in torrents.iteritems(): self.transmission.start(tid) @@ -86,6 +91,7 @@ class SubstitutePlayer(xbmc.Player): if settings != self.prev_settings: self.mode = settings['action_on_playback'] self.keep_seeding = settings['seeding_torrents'] + self.show_notifications = settings['show_notifications'] self.seconds = int(settings['seconds_playback_finished'])*1000 try: self.transmission = common.get_rpc_client() @@ -95,12 +101,14 @@ class SubstitutePlayer(xbmc.Player): def enableSpeedLimit(self): if self.transmission: - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Enabling speed limit...",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Enabling speed limit...",5000, __icon__)) self.transmission.set_session(alt_speed_enabled=True) def disableSpeedLimit(self): if self.transmission: - xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Disabling speed limit...",5000, __icon__)) + if self.show_notifications == 'true': + xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(__addonname__,"Disabling speed limit...",5000, __icon__)) self.transmission.set_session(alt_speed_enabled=False) player = SubstitutePlayer() diff --git a/resources/settings.xml b/resources/settings.xml index 7c2f489..4cb7d38 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -8,4 +8,5 @@ +