mirror of
https://github.com/correl/Transmission-XBMC.git
synced 2025-01-06 19:08:53 +00:00
Added option to show/hide notifications on screen
This commit is contained in:
parent
a5c1e17be8
commit
e2fb283f00
4 changed files with 23 additions and 9 deletions
|
@ -192,8 +192,12 @@ msgctxt "#32810"
|
||||||
msgid "Don't pause seeding torrents"
|
msgid "Don't pause seeding torrents"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgctxt "#32811"
|
||||||
|
msgid "Show notifications on screen"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#Errors
|
#Errors
|
||||||
#empty strings from id 32811 to 32899
|
#empty strings from id 32812 to 32899
|
||||||
|
|
||||||
msgctxt "#32900"
|
msgctxt "#32900"
|
||||||
msgid "An unexpected error occurred"
|
msgid "An unexpected error occurred"
|
||||||
|
|
|
@ -14,7 +14,8 @@ def get_settings():
|
||||||
'password': __settings__.getSetting('rpc_password'),
|
'password': __settings__.getSetting('rpc_password'),
|
||||||
'action_on_playback': __settings__.getSetting('action_on_playback'),
|
'action_on_playback': __settings__.getSetting('action_on_playback'),
|
||||||
'seconds_playback_finished': __settings__.getSetting('seconds_playback_finished'),
|
'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
|
return params
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ class SubstitutePlayer(xbmc.Player):
|
||||||
self.refreshSettings()
|
self.refreshSettings()
|
||||||
if self.mode != '0' and xbmc.Player().isPlayingVideo() == True and self.TimerON == False:
|
if self.mode != '0' and xbmc.Player().isPlayingVideo() == True and self.TimerON == False:
|
||||||
if self.mode == '1':
|
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()
|
self.stopAllTorrents()
|
||||||
elif self.mode == '2':
|
elif self.mode == '2':
|
||||||
self.enableSpeedLimit()
|
self.enableSpeedLimit()
|
||||||
|
@ -38,9 +39,11 @@ class SubstitutePlayer(xbmc.Player):
|
||||||
xbmc.sleep(1)
|
xbmc.sleep(1)
|
||||||
self.refreshSettings()
|
self.refreshSettings()
|
||||||
if self.mode == '1' and not xbmc.Player().isPlayingVideo():
|
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():
|
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
|
self.TimerON = True
|
||||||
xbmc.sleep(int(self.seconds))
|
xbmc.sleep(int(self.seconds))
|
||||||
self.TimerON = False
|
self.TimerON = False
|
||||||
|
@ -49,7 +52,8 @@ class SubstitutePlayer(xbmc.Player):
|
||||||
elif self.mode == '2' and xbmc.Player().isPlayingVideo() == False:
|
elif self.mode == '2' and xbmc.Player().isPlayingVideo() == False:
|
||||||
self.disableSpeedLimit()
|
self.disableSpeedLimit()
|
||||||
else:
|
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):
|
def onPlayBackEnded(self):
|
||||||
self.ResumingTorrents()
|
self.ResumingTorrents()
|
||||||
|
@ -59,7 +63,8 @@ class SubstitutePlayer(xbmc.Player):
|
||||||
|
|
||||||
def startAllTorrents(self):
|
def startAllTorrents(self):
|
||||||
if self.transmission:
|
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()
|
torrents = self.transmission.list()
|
||||||
for tid, torrent in torrents.iteritems():
|
for tid, torrent in torrents.iteritems():
|
||||||
self.transmission.start(tid)
|
self.transmission.start(tid)
|
||||||
|
@ -86,6 +91,7 @@ class SubstitutePlayer(xbmc.Player):
|
||||||
if settings != self.prev_settings:
|
if settings != self.prev_settings:
|
||||||
self.mode = settings['action_on_playback']
|
self.mode = settings['action_on_playback']
|
||||||
self.keep_seeding = settings['seeding_torrents']
|
self.keep_seeding = settings['seeding_torrents']
|
||||||
|
self.show_notifications = settings['show_notifications']
|
||||||
self.seconds = int(settings['seconds_playback_finished'])*1000
|
self.seconds = int(settings['seconds_playback_finished'])*1000
|
||||||
try:
|
try:
|
||||||
self.transmission = common.get_rpc_client()
|
self.transmission = common.get_rpc_client()
|
||||||
|
@ -95,12 +101,14 @@ class SubstitutePlayer(xbmc.Player):
|
||||||
|
|
||||||
def enableSpeedLimit(self):
|
def enableSpeedLimit(self):
|
||||||
if self.transmission:
|
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)
|
self.transmission.set_session(alt_speed_enabled=True)
|
||||||
|
|
||||||
def disableSpeedLimit(self):
|
def disableSpeedLimit(self):
|
||||||
if self.transmission:
|
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)
|
self.transmission.set_session(alt_speed_enabled=False)
|
||||||
|
|
||||||
player = SubstitutePlayer()
|
player = SubstitutePlayer()
|
||||||
|
|
|
@ -8,4 +8,5 @@
|
||||||
<setting id="action_on_playback" type="enum" label="32805" lvalues="32806|32807|32808" />
|
<setting id="action_on_playback" type="enum" label="32805" lvalues="32806|32807|32808" />
|
||||||
<setting id="seconds_playback_finished" type="slider" label="32809" range="1,60" default="1" option="int" />
|
<setting id="seconds_playback_finished" type="slider" label="32809" range="1,60" default="1" option="int" />
|
||||||
<setting id="seeding_torrents" type="bool" label="32810" default="true" />
|
<setting id="seeding_torrents" type="bool" label="32810" default="true" />
|
||||||
|
<setting id="show_notifications" type="bool" label="32811" default="false" />
|
||||||
</settings>
|
</settings>
|
||||||
|
|
Loading…
Reference in a new issue