-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-api.js
More file actions
38 lines (35 loc) · 1.12 KB
/
test-api.js
File metadata and controls
38 lines (35 loc) · 1.12 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
const serverUrl = process.env.VITE_JELLYFIN_SERVER_URL;
const apiKey = process.env.VITE_JELLYFIN_API_KEY;
(async () => {
// Check plugin status
const res = await fetch(`${serverUrl}/Plugins`, {
headers: { 'X-Emby-Token': apiKey }
});
const plugins = await res.json();
const playback = plugins.find(p => p.Name === 'Playback Reporting');
console.log('Playback Reporting status:', playback?.Status);
// Test the query endpoint
const r = await fetch(`${serverUrl}/user_usage_stats/submit_custom_query`, {
method: 'POST',
headers: {
'X-Emby-Token': apiKey,
'Content-Type': 'application/json',
},
body: JSON.stringify({
CustomQueryString: 'SELECT * FROM PlaybackActivity LIMIT 1',
ReplaceUserId: false,
}),
});
console.log('Query endpoint status:', r.status);
const text = await r.text();
if (text) {
console.log('Response:', text.substring(0, 300));
try {
const json = JSON.parse(text);
console.log('✓ JSON parsed successfully');
console.log('Keys:', Object.keys(json));
} catch (e) {
console.log('✗ Not valid JSON');
}
}
})();