Skip to content

Commit

Permalink
Bump version. Fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiumee committed Sep 30, 2024
1 parent fdf01e5 commit 1cf727d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="service.discord.richpresence"
name="Discord Rich Presence"
version="1.7.4"
version="1.7.5"
provider-name="Hiumee">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand Down
55 changes: 27 additions & 28 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,34 +264,33 @@ def updatePresence(self):
log("Using workaround")

if self.settings['display_time']:
if self.paused:
activity['assets']['small_image'] = 'paused'
# Works for
# xx:xx/xx:xx
# xx:xx/xx:xx:xx
# xx:xx:xx/xx:xx:xx
currentTime = player.getTime()
hours = int(currentTime/3600)
minutes = int(currentTime/60) - hours*60
seconds = int(currentTime) - minutes*60 - hours*3600

fullTime = player.getTotalTime()
fhours = int(fullTime/3600)
fminutes = int(fullTime/60) - fhours*60
fseconds = int(fullTime) - fminutes*60 - fhours*3600
activity['assets']['small_text'] = "{}{:02}:{:02}/{}{:02}:{:02}".format('{}:'.format(hours) if hours>0 else '',
minutes,
seconds,
'{}:'.format(fhours) if fhours>0 else '',
fminutes,
fseconds
)

else:
currentTime = player.getTime()
fullTime = player.getTotalTime()
remainingTime = fullTime - currentTime
activity['timestamps'] = {'start': int(time.time()-currentTime ), 'end' : int(time.time()+remainingTime)}
currentTime = player.getTime()
fullTime = player.getTotalTime()
if fullTime is not None and currentTime is not None and currentTime > 0 and fullTime > 0:
if self.paused:
activity['assets']['small_image'] = 'paused'
# Works for
# xx:xx/xx:xx
# xx:xx/xx:xx:xx
# xx:xx:xx/xx:xx:xx
hours = int(currentTime/3600)
minutes = int(currentTime/60) - hours*60
seconds = int(currentTime) - minutes*60 - hours*3600

fhours = int(fullTime/3600)
fminutes = int(fullTime/60) - fhours*60
fseconds = int(fullTime) - fminutes*60 - fhours*3600
activity['assets']['small_text'] = "{}{:02}:{:02}/{}{:02}:{:02}".format('{}:'.format(hours) if hours>0 else '',
minutes,
seconds,
'{}:'.format(fhours) if fhours>0 else '',
fminutes,
fseconds
)

else:
remainingTime = fullTime - currentTime
activity['timestamps'] = {'start': int(time.time()-currentTime ), 'end' : int(time.time()+remainingTime)}

if activity == None:
try:
Expand Down

0 comments on commit 1cf727d

Please sign in to comment.