(url, needsUser = false, filterByUser = false)
| 319 | |
| 320 | // Helper |
| 321 | async function apiCall(url, needsUser = false, filterByUser = false) { |
| 322 | const apiKey = await getApiKey(); |
| 323 | const base = await getBase(); |
| 324 | let pre; |
| 325 | if (url.indexOf('?') !== -1) { |
| 326 | pre = '&'; |
| 327 | } else { |
| 328 | pre = '?'; |
| 329 | } |
| 330 | if (needsUser) { |
| 331 | const user = await getUser(); |
| 332 | url = `/Users/${user}${url}`; |
| 333 | } |
| 334 | url = `${base + url + pre}api_key=${apiKey}`; |
| 335 | if (filterByUser) { |
| 336 | const user = await getUser(); |
| 337 | url = `${url}&ControllableByUserId=${user}`; |
| 338 | } |
| 339 | con.log('Api Call', url); |
| 340 | return api.request.xhr('GET', url).then(res => { |
| 341 | if (res.status === 500) { |
| 342 | con.error('Something went wrong', url, res); |
| 343 | throw 'Something went wrong'; |
| 344 | } |
| 345 | return res; |
| 346 | }); |
| 347 | } |
| 348 | |
| 349 | export const Jellyfin: pageInterface = { |
| 350 | name: 'Jellyfin', |
no test coverage detected