-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
167 lines (149 loc) · 4.89 KB
/
app.py
File metadata and controls
167 lines (149 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import json
from pypresence import Presence
import time
import os
import psutil
src = os.path.join(os.getenv("APPDATA"),"Activity-Condenser")
settingssrc = os.path.join(src,"settings.json")
datasrc = os.path.join(src,"data.json")
errors = os.path.join(src,"errors.json")
modified_path = ""
for process in psutil.process_iter():
if process.name() == "Discord.exe":
path = process.exe()
modified_path = path.replace("Discord.exe", "output.json")
if modified_path == "":
noplugin = 1
else:
noplugin = 0
if os.path.exists(modified_path):
noplugin = 0
else:
noplugin = 1
with open(settingssrc) as j:
settings = json.load(j)
print(settings)
try :
client_id = settings['Client_ID']
RPC = Presence(client_id )
RPC.connect()
except Exception as e:
print('______________________________________')
errorfinal = {"Errors":e}
jsonString = json.dumps(errorfinal, indent=4, default=str)
jsonFile = open(errors, "w")
jsonFile.write(jsonString)
print(e)
print('______________________________________')
exit()
while 1 == 1:
f = open(datasrc)
data = json.load(f)
if noplugin == 0:
o = open(modified_path)
btnlnk = json.load(o)
Idfinal = []
AppIDfinal = []
Namefinal = []
Urlfinal = []
Detailsfinal = []
Statefinal = []
Timestampsfinal = []
Assetsfinal = []
Buttonsfinal = []
Endfinal = []
Partyfinal = []
Startfinal = []
Large_imagefinal = []
Large_textfinal = []
Small_imagefinal = []
Small_textfinal = []
Party_debug = {}
buttons_tempfinal = []
Buttonslnk = []
x = 0
for i in data['Presence']:
Id = data['Presence'][x]['ID']
AppID = data['Presence'][x]['AppID']
Name = data['Presence'][x]['Name']
Url = data['Presence'][x]['URL']
Details = data['Presence'][x]['Details']
State = data['Presence'][x]['State']
Timestamps = data['Presence'][x]['Timestamps']
Large_image = data['Presence'][x]['large_image']
Large_text = data['Presence'][x]['large_text']
Small_image = data['Presence'][x]['small_image']
Small_text = data['Presence'][x]['small_text']
Buttons = data['Presence'][x]['Buttons']
End = data['Presence'][x]['End']
Party = data['Presence'][x]['Party']
Start = data['Presence'][x]['Start']
Idfinal.append(Id)
AppIDfinal.append(AppID)
Namefinal.append(Name)
Urlfinal.append(Url)
Detailsfinal.append(Details)
Statefinal.append(State)
Timestampsfinal.append(Timestamps)
Large_imagefinal.append(Large_image)
Large_textfinal.append(Large_text)
Small_imagefinal.append(Small_image)
Small_textfinal.append(Small_text)
Buttonsfinal.append(Buttons)
Endfinal.append(End)
Partyfinal.append(Party)
Startfinal.append(Start)
Testdebug = int(settings['Client_ID'])
x = x + 1
z = 0
while z < Idfinal[-1]:
if Testdebug == AppIDfinal[z]:
z = z + 1
continue
if noplugin == 0:
for app in btnlnk:
AppIDfinalint = int(AppIDfinal[z])
Appidpluginint = int(app['application_id'])
if Appidpluginint == AppIDfinalint:
Buttonslnk = app['buttons']
if "end" in Timestampsfinal[z]:
if "start" in Timestampsfinal[z]:
start_temp = Timestampsfinal[z]['start']
end_temp = Timestampsfinal[z]['end']
else :
start_temp = None
end_temp = Timestampsfinal[z]['end']
else :
if "start" in Timestampsfinal[z]:
start_temp = Timestampsfinal[z]['start']
end_temp = None
else :
start_temp = None
end_temp = None
if Partyfinal[z] == Party_debug:
party_id_temp = None
party_size_temp = None
else:
party_id_temp = Partyfinal[z]['id']
party_size_temp = Partyfinal[z]['size']
if Buttonsfinal[z] == []:
buttons_temp = None
buttons_temp2 = None
buttons_tempfinal = None
else :
w = len(Buttonsfinal[z])
y = 0
buttons_tempfinal = []
while y < w:
buttons_temp = Buttonsfinal[z][y]
if noplugin == 0:
buttons_temp2 = {"label": buttons_temp, "url": Buttonslnk[y]}
else:
buttons_temp2 = {"label": buttons_temp, "url": settings['defaultlink']}
buttons_tempfinal.append(buttons_temp2)
print(buttons_tempfinal)
y = y + 1
print(RPC.update(buttons=buttons_tempfinal, party_id=party_id_temp, party_size=party_size_temp, details=Detailsfinal[z], state=Statefinal[z],start = start_temp,end = end_temp, large_image=Large_imagefinal[z], large_text=Large_textfinal[z], small_image=Small_imagefinal[z], small_text=Small_textfinal[z]))
z = z + 1
time.sleep(settings['refresh_time'])
f.close()