Skip to content

Commit

Permalink
Unsupported media types display their Label
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiumee committed Oct 10, 2019
1 parent b732bf3 commit 5c97628
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 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="0.2.0"
version="1.1.3"
provider-name="Hiumee">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
Expand Down
20 changes: 14 additions & 6 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"0":'544620244014989312',
"1":'570950300446359552'}

SUPPORTED_TYPES = ['episode', 'movie']
SETT = ['state', 'details']
SUPPORTED_TYPES = ['episode', 'movie', 'unknown']
SETT = ['state', 'details', '']

getsetting = {
'movie': {
Expand Down Expand Up @@ -68,12 +68,16 @@ def get_data():
data = data['item']
data2 = json.loads(xbmc.executeJSONRPC('{"command": "Player.GetProperties", "jsonrpc": "2.0", "method": "Player.GetProperties", "id": 1, "params": {"playerid": 1, "properties": ["speed", "time", "totaltime"]}}'))['result']

if data['type'] in SUPPORTED_TYPES:
xbmc.log("[Discord RP] "+str(data))
if data['type'] in SUPPORTED_TYPES or True: # TODO: Return to only supported types

for pres in SETT:
setting = getsetting[data['type']][pres][xbmcaddon.Addon().getSetting(data['type']+'_'+pres)](data)
if setting:
act[pres] = setting
try:
setting = getsetting[data['type']][pres][xbmcaddon.Addon().getSetting(data['type']+'_'+pres)](data)
if setting:
act[pres] = setting
except:
act['details'] = data['label']

if data['type'] == 'episode':
act['assets']['large_text'] = data['showtitle']
Expand All @@ -83,6 +87,10 @@ def get_data():
act['assets']['large_text'] = data['title']
act['assets']['large_image'] = 'default'

else:
act['assets']['large_text'] = data['label'][:-4]
act['assets']['large_image'] = 'default'

if data2['speed'] == 0:
act['assets']['small_image'] = 'paused'
# Works for
Expand Down

0 comments on commit 5c97628

Please sign in to comment.